Move to checker qual nullability annotations

This commit is contained in:
KennyTV 2021-04-02 14:15:30 +02:00
parent d79bd00f58
commit 070c7f5808
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
62 changed files with 219 additions and 224 deletions

View File

@ -16,5 +16,5 @@ dependencies {
compileOnlyApi("org.yaml", "snakeyaml", Versions.snakeYaml)
compileOnlyApi("io.netty", "netty-all", Versions.netty)
compileOnlyApi("com.google.guava", "guava", Versions.guava)
compileOnlyApi("org.jetbrains", "annotations", Versions.jetbrainsAnnotations)
compileOnlyApi("org.checkerframework", "checker-qual", Versions.checkerQual)
}

View File

@ -22,7 +22,7 @@
*/
package us.myles.ViaVersion.api;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Objects;

View File

@ -22,7 +22,7 @@
*/
package us.myles.ViaVersion.api;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Objects;
@ -37,18 +37,15 @@ public class Triple<A, B, C> {
this.third = third;
}
@Nullable
public A getFirst() {
public @Nullable A getFirst() {
return first;
}
@Nullable
public B getSecond() {
public @Nullable B getSecond() {
return second;
}
@Nullable
public C getThird() {
public @Nullable C getThird() {
return third;
}

View File

@ -22,7 +22,7 @@
*/
package us.myles.ViaVersion.api.command;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.List;
@ -49,8 +49,7 @@ public interface ViaVersionCommand {
* @param name subcommand name
* @return ViaSubCommand instance
*/
@Nullable
ViaSubCommand getSubCommand(String name);
@Nullable ViaSubCommand getSubCommand(String name);
/**
* Executed when the Command sender executes the commands

View File

@ -23,7 +23,7 @@
package us.myles.ViaVersion.api.data;
import com.google.gson.JsonObject;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.util.Int2IntBiMap;
@ -97,46 +97,38 @@ public class MappingData {
return checkValidity(id, particleMappings.getMappings().getNewId(id), "particles");
}
@Nullable
public Int2IntBiMap getItemMappings() {
public @Nullable Int2IntBiMap getItemMappings() {
return itemMappings;
}
@Nullable
public ParticleMappings getParticleMappings() {
public @Nullable ParticleMappings getParticleMappings() {
return particleMappings;
}
@Nullable
public Mappings getBlockMappings() {
public @Nullable Mappings getBlockMappings() {
return blockMappings;
}
@Nullable
public Mappings getBlockStateMappings() {
public @Nullable Mappings getBlockStateMappings() {
return blockStateMappings;
}
@Nullable
public Mappings getSoundMappings() {
public @Nullable Mappings getSoundMappings() {
return soundMappings;
}
@Nullable
public Mappings getStatisticsMappings() {
public @Nullable Mappings getStatisticsMappings() {
return statisticsMappings;
}
@Nullable
protected Mappings loadFromArray(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
protected @Nullable Mappings loadFromArray(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
return new Mappings(oldMappings.getAsJsonArray(key), newMappings.getAsJsonArray(key), diff);
}
@Nullable
protected Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
protected @Nullable Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;

View File

@ -29,7 +29,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.util.GsonUtil;
import us.myles.ViaVersion.util.Int2IntBiMap;
@ -73,8 +73,7 @@ public class MappingDataLoader {
/**
* Loads the file from the plugin folder if present, else from the bundled resources.
*/
@Nullable
public static JsonObject loadFromDataDir(String name) {
public static @Nullable JsonObject loadFromDataDir(String name) {
File file = new File(Via.getPlatform().getDataFolder(), name);
if (!file.exists()) return loadData(name);
@ -94,8 +93,7 @@ public class MappingDataLoader {
/**
* Loads the file from the bundled resources. Uses the cache if enabled.
*/
@Nullable
public static JsonObject loadData(String name) {
public static @Nullable JsonObject loadData(String name) {
return loadData(name, false);
}
@ -104,8 +102,7 @@ public class MappingDataLoader {
*
* @param cacheIfEnabled whether loaded files should be cached
*/
@Nullable
public static JsonObject loadData(String name, boolean cacheIfEnabled) {
public static @Nullable JsonObject loadData(String name, boolean cacheIfEnabled) {
if (cacheJsonMappings) {
JsonObject cached = MAPPINGS_CACHE.get(name);
if (cached != null) {
@ -233,8 +230,7 @@ public class MappingDataLoader {
return map;
}
@Nullable
public static InputStream getResource(String name) {
public static @Nullable InputStream getResource(String name) {
return MappingDataLoader.class.getClassLoader().getResourceAsStream("assets/viaversion/data/" + name);
}
}

View File

@ -24,7 +24,7 @@ package us.myles.ViaVersion.api.data;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Arrays;

View File

@ -27,7 +27,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.ViaVersionConfig;
@ -96,8 +96,7 @@ public class UserConnection {
* @param <T> The type of the class you want to get.
* @return The requested object
*/
@Nullable
public <T extends StoredObject> T get(Class<T> objectClass) {
public @Nullable <T extends StoredObject> T get(Class<T> objectClass) {
return (T) storedObjects.get(objectClass);
}
@ -453,13 +452,11 @@ public class UserConnection {
return id;
}
@Nullable
public Channel getChannel() {
public @Nullable Channel getChannel() {
return channel;
}
@Nullable
public ProtocolInfo getProtocolInfo() {
public @Nullable ProtocolInfo getProtocolInfo() {
return protocolInfo;
}
@ -492,8 +489,7 @@ public class UserConnection {
this.pendingDisconnect = pendingDisconnect;
}
@Nullable
public Object getLastPacket() {
public @Nullable Object getLastPacket() {
return lastPacket;
}

View File

@ -22,7 +22,7 @@
*/
package us.myles.ViaVersion.api.entities;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface EntityType {
@ -34,16 +34,16 @@ public interface EntityType {
/**
* @return parent entity type if present
*/
@Nullable
EntityType getParent();
@Nullable EntityType getParent();
String name();
default boolean is(EntityType... types) {
for (EntityType type : types)
for (EntityType type : types) {
if (this == type) {
return true;
}
}
return false;
}

View File

@ -23,7 +23,7 @@
package us.myles.ViaVersion.api.minecraft.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.BitSet;
import java.util.List;
@ -42,7 +42,7 @@ public class BaseChunk implements Chunk {
protected final List<CompoundTag> blockEntities;
public BaseChunk(int x, int z, boolean fullChunk, boolean ignoreOldLightData, @Nullable BitSet chunkSectionBitSet,
ChunkSection[] sections, @Nullable int[] biomeData, @Nullable CompoundTag heightMap, List<CompoundTag> blockEntities) {
ChunkSection[] sections, int @Nullable [] biomeData, @Nullable CompoundTag heightMap, List<CompoundTag> blockEntities) {
this.x = x;
this.z = z;
this.fullChunk = fullChunk;
@ -104,8 +104,7 @@ public class BaseChunk implements Chunk {
}
@Override
@Nullable
public BitSet getChunkMask() {
public @Nullable BitSet getChunkMask() {
return chunkSectionBitSet;
}
@ -125,13 +124,12 @@ public class BaseChunk implements Chunk {
}
@Override
@Nullable
public int[] getBiomeData() {
public int @Nullable [] getBiomeData() {
return biomeData;
}
@Override
public void setBiomeData(final int[] biomeData) {
public void setBiomeData(int @Nullable [] biomeData) {
this.biomeData = biomeData;
}

View File

@ -23,7 +23,7 @@
package us.myles.ViaVersion.api.minecraft.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.BitSet;
import java.util.List;
@ -65,8 +65,7 @@ public interface Chunk {
* @return chunk section bit mask, only non-null available for 1.17+ chunks
* @see #getBitmask()
*/
@Nullable
BitSet getChunkMask();
@Nullable BitSet getChunkMask();
void setChunkMask(BitSet chunkSectionMask);
@ -74,10 +73,9 @@ public interface Chunk {
void setSections(ChunkSection[] sections);
@Nullable
int[] getBiomeData();
int @Nullable [] getBiomeData();
void setBiomeData(int[] biomeData);
void setBiomeData(int @Nullable [] biomeData);
CompoundTag getHeightMap();

View File

@ -27,7 +27,7 @@ import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
public class ChunkSection {
@ -207,23 +207,19 @@ public class ChunkSection {
}
}
@Nullable
public byte[] getBlockLight() {
public @Nullable byte[] getBlockLight() {
return blockLight == null ? null : blockLight.getHandle();
}
@Nullable
public NibbleArray getBlockLightNibbleArray() {
public @Nullable NibbleArray getBlockLightNibbleArray() {
return blockLight;
}
@Nullable
public byte[] getSkyLight() {
public @Nullable byte[] getSkyLight() {
return skyLight == null ? null : skyLight.getHandle();
}
@Nullable
public NibbleArray getSkyLightNibbleArray() {
public @Nullable NibbleArray getSkyLightNibbleArray() {
return skyLight;
}

View File

@ -24,7 +24,7 @@ package us.myles.ViaVersion.api.minecraft.item;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.google.gson.annotations.SerializedName;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Objects;
@ -73,8 +73,7 @@ public class Item {
this.data = data;
}
@Nullable
public CompoundTag getTag() {
public @Nullable CompoundTag getTag() {
return tag;
}

View File

@ -24,7 +24,7 @@
package us.myles.ViaVersion.api.minecraft.nbt;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.jetbrains.annotations.NotNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.io.BufferedInputStream;
import java.io.DataInput;
@ -53,8 +53,7 @@ public final class BinaryTagIO {
* @return the compound tag
* @throws IOException if an exception was encountered while reading a compound tag
*/
@NotNull
public static CompoundTag readPath(final @NotNull Path path) throws IOException {
public static @NonNull CompoundTag readPath(final @NonNull Path path) throws IOException {
return readInputStream(Files.newInputStream(path));
}
@ -65,8 +64,7 @@ public final class BinaryTagIO {
* @return the compound tag
* @throws IOException if an exception was encountered while reading a compound tag
*/
@NotNull
public static CompoundTag readInputStream(final @NotNull InputStream input) throws IOException {
public static @NonNull CompoundTag readInputStream(final @NonNull InputStream input) throws IOException {
try (final DataInputStream dis = new DataInputStream(input)) {
return readDataInput(dis);
}
@ -79,8 +77,7 @@ public final class BinaryTagIO {
* @return the compound tag
* @throws IOException if an exception was encountered while reading a compound tag
*/
@NotNull
public static CompoundTag readCompressedPath(final @NotNull Path path) throws IOException {
public static @NonNull CompoundTag readCompressedPath(final @NonNull Path path) throws IOException {
return readCompressedInputStream(Files.newInputStream(path));
}
@ -91,8 +88,7 @@ public final class BinaryTagIO {
* @return the compound tag
* @throws IOException if an exception was encountered while reading a compound tag
*/
@NotNull
public static CompoundTag readCompressedInputStream(final @NotNull InputStream input) throws IOException {
public static @NonNull CompoundTag readCompressedInputStream(final @NonNull InputStream input) throws IOException {
try (final DataInputStream dis = new DataInputStream(new BufferedInputStream(new GZIPInputStream(input)))) {
return readDataInput(dis);
}
@ -105,8 +101,7 @@ public final class BinaryTagIO {
* @return the compound tag
* @throws IOException if an exception was encountered while reading a compound tag
*/
@NotNull
public static CompoundTag readDataInput(final @NotNull DataInput input) throws IOException {
public static @NonNull CompoundTag readDataInput(final @NonNull DataInput input) throws IOException {
byte type = input.readByte();
if (type != CompoundTag.ID) {
throw new IOException(String.format("Expected root tag to be a CompoundTag, was %s", type));
@ -125,7 +120,7 @@ public final class BinaryTagIO {
* @param path the path
* @throws IOException if an exception was encountered while writing the compound tag
*/
public static void writePath(final @NotNull CompoundTag tag, final @NotNull Path path) throws IOException {
public static void writePath(final @NonNull CompoundTag tag, final @NonNull Path path) throws IOException {
writeOutputStream(tag, Files.newOutputStream(path));
}
@ -136,7 +131,7 @@ public final class BinaryTagIO {
* @param output the output stream
* @throws IOException if an exception was encountered while writing the compound tag
*/
public static void writeOutputStream(final @NotNull CompoundTag tag, final @NotNull OutputStream output) throws IOException {
public static void writeOutputStream(final @NonNull CompoundTag tag, final @NonNull OutputStream output) throws IOException {
try (final DataOutputStream dos = new DataOutputStream(output)) {
writeDataOutput(tag, dos);
}
@ -149,7 +144,7 @@ public final class BinaryTagIO {
* @param path the path
* @throws IOException if an exception was encountered while writing the compound tag
*/
public static void writeCompressedPath(final @NotNull CompoundTag tag, final @NotNull Path path) throws IOException {
public static void writeCompressedPath(final @NonNull CompoundTag tag, final @NonNull Path path) throws IOException {
writeCompressedOutputStream(tag, Files.newOutputStream(path));
}
@ -160,7 +155,7 @@ public final class BinaryTagIO {
* @param output the output stream
* @throws IOException if an exception was encountered while writing the compound tag
*/
public static void writeCompressedOutputStream(final @NotNull CompoundTag tag, final @NotNull OutputStream output) throws IOException {
public static void writeCompressedOutputStream(final @NonNull CompoundTag tag, final @NonNull OutputStream output) throws IOException {
try (final DataOutputStream dos = new DataOutputStream(new GZIPOutputStream(output))) {
writeDataOutput(tag, dos);
}
@ -173,7 +168,7 @@ public final class BinaryTagIO {
* @param output the output
* @throws IOException if an exception was encountered while writing the compound tag
*/
public static void writeDataOutput(final @NotNull CompoundTag tag, final @NotNull DataOutput output) throws IOException {
public static void writeDataOutput(final @NonNull CompoundTag tag, final @NonNull DataOutput output) throws IOException {
output.writeByte(CompoundTag.ID);
output.writeUTF(""); // write empty name
tag.write(output);
@ -186,8 +181,7 @@ public final class BinaryTagIO {
* @return the compound tag
* @throws IOException if an exception was encountered while reading a compound tag
*/
@NotNull
public static CompoundTag readString(final @NotNull String input) throws IOException {
public static @NonNull CompoundTag readString(final @NonNull String input) throws IOException {
try {
final CharBuffer buffer = new CharBuffer(input);
final TagStringReader parser = new TagStringReader(buffer);
@ -208,8 +202,7 @@ public final class BinaryTagIO {
* @return the string
* @throws IOException if an exception was encountered while writing the compound tag
*/
@NotNull
public static String writeString(final @NotNull CompoundTag tag) throws IOException {
public static @NonNull String writeString(final @NonNull CompoundTag tag) throws IOException {
final StringBuilder sb = new StringBuilder();
try (final TagStringWriter emit = new TagStringWriter(sb)) {
emit.writeTag(tag);

View File

@ -23,11 +23,15 @@
package us.myles.ViaVersion.api.platform;
import io.netty.channel.ChannelFutureListener;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
import java.util.*;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
/**
@ -44,7 +48,7 @@ public class ViaConnectionManager {
if (isFrontEnd(connection)) {
UUID id = connection.getProtocolInfo().getUuid();
if (clients.put(id, connection) != null) {
Via.getPlatform().getLogger().warning("Duplicate UUID on frontend connection! ("+id+")");
Via.getPlatform().getLogger().warning("Duplicate UUID on frontend connection! (" + id + ")");
}
}
@ -90,8 +94,7 @@ public class ViaConnectionManager {
* Note that connections are removed as soon as their channel is closed,
* so avoid using this method during player quits for example.
*/
@Nullable
public UserConnection getConnectedClient(UUID clientIdentifier) {
public @Nullable UserConnection getConnectedClient(UUID clientIdentifier) {
return clients.get(clientIdentifier);
}
@ -104,8 +107,7 @@ public class ViaConnectionManager {
* Note that connections are removed as soon as their channel is closed,
* so avoid using this method during player quits for example.
*/
@Nullable
public UUID getConnectedClientId(UserConnection conn) {
public @Nullable UUID getConnectedClientId(UserConnection conn) {
if (conn.getProtocolInfo() == null) return null;
UUID uuid = conn.getProtocolInfo().getUuid();
UserConnection client = clients.get(uuid);

View File

@ -22,7 +22,7 @@
*/
package us.myles.ViaVersion.api.platform.providers;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.ArrayList;
import java.util.HashMap;
@ -46,8 +46,7 @@ public class ViaProviders {
providers.put(provider, value);
}
@Nullable
public <T extends Provider> T get(Class<T> provider) {
public @Nullable <T extends Provider> T get(Class<T> provider) {
Provider rawProvider = providers.get(provider);
if (rawProvider != null) {
return (T) rawProvider;

View File

@ -23,7 +23,7 @@
package us.myles.ViaVersion.api.protocol;
import com.google.common.base.Preconditions;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingData;
@ -472,8 +472,7 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
}
}
@Nullable
public <T> T get(Class<T> objectClass) {
public @Nullable <T> T get(Class<T> objectClass) {
return (T) storedObjects.get(objectClass);
}
@ -493,8 +492,7 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
return getMappingData() != null;
}
@Nullable
public MappingData getMappingData() {
public @Nullable MappingData getMappingData() {
return null; // Let the protocols hold the mappings to still have easy, static singleton access there
}

View File

@ -23,7 +23,7 @@
package us.myles.ViaVersion.api.protocol;
import com.google.common.collect.Range;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.List;
import java.util.SortedSet;
@ -44,8 +44,7 @@ public interface ProtocolManager {
* @param protocolClass class of the protocol
* @return protocol if present
*/
@Nullable
Protocol getProtocol(Class<? extends Protocol> protocolClass);
@Nullable Protocol getProtocol(Class<? extends Protocol> protocolClass);
Protocol getBaseProtocol();
@ -87,8 +86,7 @@ public interface ProtocolManager {
* @param serverVersion desired output server version
* @return path it generated, null if not supported
*/
@Nullable
List<ProtocolPathEntry> getProtocolPath(int clientVersion, int serverVersion);
@Nullable List<ProtocolPathEntry> getProtocolPath(int clientVersion, int serverVersion);
/**
* Returns the maximum protocol path size applied to {@link #getProtocolPath(int, int)}.
@ -159,6 +157,5 @@ public interface ProtocolManager {
* @param protocolClass protocol class
* @return data loading future bound to the protocol, or null if all loading is complete
*/
@Nullable
CompletableFuture<Void> getMappingLoaderFuture(Class<? extends Protocol> protocolClass);
@Nullable CompletableFuture<Void> getMappingLoaderFuture(Class<? extends Protocol> protocolClass);
}

View File

@ -23,7 +23,7 @@
package us.myles.ViaVersion.api.protocol;
import com.google.common.collect.Range;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.ViaManager;
import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.Via;
@ -103,8 +103,7 @@ public class ProtocolRegistry {
* @param serverVersion The desired output server version
* @return The path it generated, null if it failed.
*/
@Nullable
public static List<Pair<Integer, Protocol>> getProtocolPath(int clientVersion, int serverVersion) {
public static @Nullable List<Pair<Integer, Protocol>> getProtocolPath(int clientVersion, int serverVersion) {
List<ProtocolPathEntry> pathList = Via.getManager().getProtocolManager().getProtocolPath(clientVersion, serverVersion);
if (pathList == null) {
return null;
@ -123,8 +122,7 @@ public class ProtocolRegistry {
* @param protocolClass class of the protocol
* @return protocol if present
*/
@Nullable
public static Protocol getProtocol(Class<? extends Protocol> protocolClass) {
public static @Nullable Protocol getProtocol(Class<? extends Protocol> protocolClass) {
return Via.getManager().getProtocolManager().getProtocol(protocolClass);
}

View File

@ -25,8 +25,8 @@ package us.myles.ViaVersion.api.protocol;
import com.google.common.base.Preconditions;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.ArrayList;
import java.util.Collections;
@ -105,8 +105,7 @@ public class ProtocolVersion {
return versions.containsKey(id);
}
@NotNull
public static ProtocolVersion getProtocol(int id) {
public static @NonNull ProtocolVersion getProtocol(int id) {
ProtocolVersion protocolVersion = versions.get(id);
if (protocolVersion != null) {
return protocolVersion;
@ -123,8 +122,7 @@ public class ProtocolVersion {
return Collections.unmodifiableList(new ArrayList<>(versions.values()));
}
@Nullable
public static ProtocolVersion getClosest(String protocol) {
public static @Nullable ProtocolVersion getClosest(String protocol) {
for (ProtocolVersion version : versions.values()) {
String name = version.getName();
if (name.equals(protocol)) {
@ -211,6 +209,10 @@ public class ProtocolVersion {
return snapshotVersion == -1 ? version : ((1 << 30) | snapshotVersion);
}
public boolean isKnown() {
return version != -1;
}
/**
* @return true if the protocol includes a range of versions (but not an entire major version range), for example 1.7-1.7.5
* @see #getIncludedVersions()

View File

@ -49,7 +49,7 @@ public interface ServerProtocolVersion {
* Returns true if the actual protocol version has not yet been identified.
* In that case, all methods above will returns -1.
*
* @return true if unset
* @return true if set, false if unknown (yet)
*/
default boolean isKnown() {
return lowestSupportedVersion() != -1 && highestSupportedVersion() != -1;

View File

@ -22,7 +22,7 @@
*/
package us.myles.ViaVersion.api.remapper;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.exception.InformativeException;
@ -60,8 +60,7 @@ public abstract class ValueTransformer<T1, T2> implements ValueWriter<T1> {
}
}
@Nullable
public Type<T1> getInputType() {
public @Nullable Type<T1> getInputType() {
return inputType;
}

View File

@ -31,7 +31,28 @@ import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.api.minecraft.Vector;
import us.myles.ViaVersion.api.minecraft.VillagerData;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.type.types.*;
import us.myles.ViaVersion.api.type.types.ArrayType;
import us.myles.ViaVersion.api.type.types.BooleanType;
import us.myles.ViaVersion.api.type.types.ByteArrayType;
import us.myles.ViaVersion.api.type.types.ByteType;
import us.myles.ViaVersion.api.type.types.ComponentType;
import us.myles.ViaVersion.api.type.types.DoubleType;
import us.myles.ViaVersion.api.type.types.FloatType;
import us.myles.ViaVersion.api.type.types.IntType;
import us.myles.ViaVersion.api.type.types.LongArrayType;
import us.myles.ViaVersion.api.type.types.LongType;
import us.myles.ViaVersion.api.type.types.RemainingBytesType;
import us.myles.ViaVersion.api.type.types.ShortByteArrayType;
import us.myles.ViaVersion.api.type.types.ShortType;
import us.myles.ViaVersion.api.type.types.StringType;
import us.myles.ViaVersion.api.type.types.UUIDIntArrayType;
import us.myles.ViaVersion.api.type.types.UUIDType;
import us.myles.ViaVersion.api.type.types.UnsignedByteType;
import us.myles.ViaVersion.api.type.types.UnsignedShortType;
import us.myles.ViaVersion.api.type.types.VarIntArrayType;
import us.myles.ViaVersion.api.type.types.VarIntType;
import us.myles.ViaVersion.api.type.types.VarLongType;
import us.myles.ViaVersion.api.type.types.VoidType;
import us.myles.ViaVersion.api.type.types.minecraft.BlockChangeRecordType;
import us.myles.ViaVersion.api.type.types.minecraft.EulerAngleType;
import us.myles.ViaVersion.api.type.types.minecraft.FlatItemArrayType;

View File

@ -48,7 +48,7 @@ public class StringType extends Type<String> {
int len = Type.VAR_INT.readPrimitive(buffer);
Preconditions.checkArgument(len <= maxLength * maxJavaCharUtf8Length,
"Cannot receive string longer than Short.MAX_VALUE * " + maxJavaCharUtf8Length + " bytes (got %s bytes)", len);
"Cannot receive string longer than Short.MAX_VALUE * " + maxJavaCharUtf8Length + " bytes (got %s bytes)", len);
String string = buffer.toString(buffer.readerIndex(), len, StandardCharsets.UTF_8);
buffer.skipBytes(len);

View File

@ -46,7 +46,7 @@ public class CompactArrayUtil {
79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303,
0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0,
70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE,
0, 5 };
0, 5};
private CompactArrayUtil() {
throw new AssertionError();
@ -72,6 +72,7 @@ public class CompactArrayUtil {
return data;
}
public static void iterateCompactArrayWithPadding(int bitsPerEntry, int entries, long[] data, BiIntConsumer consumer) {
long maxEntryValue = (1L << bitsPerEntry) - 1;
char valuesPerLong = (char) (64 / bitsPerEntry);

View File

@ -27,7 +27,7 @@ import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntSet;
import it.unimi.dsi.fastutil.objects.ObjectSet;
import org.jetbrains.annotations.NotNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Map;
@ -106,7 +106,7 @@ public class Int2IntBiMap implements Int2IntMap {
@Override
@Deprecated
public void putAll(@NotNull Map<? extends Integer, ? extends Integer> m) {
public void putAll(@NonNull Map<? extends Integer, ? extends Integer> m) {
throw new UnsupportedOperationException();
}
@ -127,14 +127,12 @@ public class Int2IntBiMap implements Int2IntMap {
}
@Override
@NotNull
public IntSet keySet() {
public @NonNull IntSet keySet() {
return map.keySet();
}
@Override
@NotNull
public IntSet values() {
public @NonNull IntSet values() {
return inverse.map.keySet();
}

View File

@ -11,8 +11,8 @@ object Versions {
const val guava = "17.0"
const val snakeYaml = "1.18"
const val jetbrainsAnnotations = "20.1.0"
const val jUnit = "5.6.3"
const val checkerQual = "3.12.0"
// Platforms
const val spigot = "1.16.5-R0.1-SNAPSHOT"

View File

@ -71,7 +71,7 @@ public class BukkitEncodeHandler extends MessageToByteEncoder implements ViaHand
throw (Error) e.getCause();
}
}
} else {
bytebuf.writeBytes((ByteBuf) o);
}

View File

@ -32,7 +32,11 @@ import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.WeakHashMap;
public class PlayerSneakListener extends ViaBukkitListener {
private static final float STANDING_HEIGHT = 1.8F;

View File

@ -43,8 +43,8 @@ import us.myles.ViaVersion.dump.PluginInfo;
import us.myles.ViaVersion.util.GsonUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

View File

@ -22,8 +22,8 @@ import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.exception.CancelDecoderException;
import us.myles.ViaVersion.exception.CancelCodecException;
import us.myles.ViaVersion.exception.CancelDecoderException;
import java.util.List;

View File

@ -23,8 +23,8 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.bungee.util.BungeePipelineUtil;
import us.myles.ViaVersion.exception.CancelEncoderException;
import us.myles.ViaVersion.exception.CancelCodecException;
import us.myles.ViaVersion.exception.CancelEncoderException;
import java.util.List;

View File

@ -23,7 +23,11 @@ import us.myles.ViaVersion.bungee.providers.BungeeVersionProvider;
import java.io.File;
import java.net.URL;
import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
public class BungeeViaConfig extends AbstractViaConfig {
private static final List<String> UNSUPPORTED = Arrays.asList("nms-player-ticking", "item-cache", "anti-xray-patch", "quick-move-action-fix", "velocity-ping-interval", "velocity-ping-save", "velocity-servers", "blockconnection-method", "change-1_9-hitbox", "change-1_14-hitbox");

View File

@ -17,7 +17,7 @@
*/
package us.myles.ViaVersion.api;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol;
@ -37,8 +37,7 @@ public abstract class ViaListener {
* @param uuid UUID object
* @return The UserConnection
*/
@Nullable
protected UserConnection getUserConnection(UUID uuid) {
protected @Nullable UserConnection getUserConnection(UUID uuid) {
return Via.getManager().getConnectionManager().getConnectedClient(uuid);
}

View File

@ -23,7 +23,7 @@ import com.google.common.collect.Range;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingDataLoader;
@ -210,9 +210,8 @@ public class ProtocolManagerImpl implements ProtocolManager {
}
}
@Nullable
@Override
public List<ProtocolPathEntry> getProtocolPath(int clientVersion, int serverVersion) {
public @Nullable List<ProtocolPathEntry> getProtocolPath(int clientVersion, int serverVersion) {
ProtocolPathKey protocolKey = new ProtocolPathKeyImpl(clientVersion, serverVersion);
// Check cache
List<ProtocolPathEntry> protocolList = pathCache.get(protocolKey);
@ -237,8 +236,7 @@ public class ProtocolManagerImpl implements ProtocolManager {
* @param serverVersion desired output version
* @return path that has been generated, null if failed
*/
@Nullable
private List<ProtocolPathEntry> getProtocolPath(List<ProtocolPathEntry> current, int clientVersion, int serverVersion) {
private @Nullable List<ProtocolPathEntry> getProtocolPath(List<ProtocolPathEntry> current, int clientVersion, int serverVersion) {
if (clientVersion == serverVersion) return null; // We're already there
if (current.size() > maxProtocolPathSize) return null; // Fail safe, protocol too complicated.
@ -282,9 +280,8 @@ public class ProtocolManagerImpl implements ProtocolManager {
return shortest; // null if none found
}
@Nullable
@Override
public Protocol getProtocol(Class<? extends Protocol> protocolClass) {
public @Nullable Protocol getProtocol(Class<? extends Protocol> protocolClass) {
return protocols.get(protocolClass);
}
@ -406,9 +403,8 @@ public class ProtocolManagerImpl implements ProtocolManager {
}
}
@Nullable
@Override
public CompletableFuture<Void> getMappingLoaderFuture(Class<? extends Protocol> protocolClass) {
public @Nullable CompletableFuture<Void> getMappingLoaderFuture(Class<? extends Protocol> protocolClass) {
mappingLoaderLock.readLock().lock();
try {
return mappingsLoaded ? null : mappingLoaderFutures.get(protocolClass);

View File

@ -17,7 +17,7 @@
*/
package us.myles.ViaVersion.api.rewriters;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
import us.myles.ViaVersion.api.protocol.Protocol;
@ -122,8 +122,7 @@ public abstract class CommandRewriter {
* @param argumentType argument type
* @return new argument type, or null if it should be removed
*/
@Nullable
protected String handleArgumentType(String argumentType) {
protected @Nullable String handleArgumentType(String argumentType) {
return argumentType;
}

View File

@ -19,7 +19,7 @@ package us.myles.ViaVersion.api.rewriters;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.ParticleMappings;
import us.myles.ViaVersion.api.data.UserConnection;
@ -296,8 +296,7 @@ public abstract class MetadataRewriter {
*/
protected abstract void handleMetadata(int entityId, @Nullable EntityType type, Metadata metadata, List<Metadata> metadatas, UserConnection connection) throws Exception;
@Nullable
protected Metadata getMetaByIndex(int index, List<Metadata> metadataList) {
protected @Nullable Metadata getMetaByIndex(int index, List<Metadata> metadataList) {
for (Metadata metadata : metadataList) {
if (metadata.getId() == index) {
return metadata;

View File

@ -17,7 +17,7 @@
*/
package us.myles.ViaVersion.api.rewriters;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.HashMap;
import java.util.Map;
@ -43,8 +43,7 @@ public enum RegistryType {
return VALUES;
}
@Nullable
public static RegistryType getByKey(String resourceKey) {
public static @Nullable RegistryType getByKey(String resourceKey) {
return MAP.get(resourceKey);
}

View File

@ -17,7 +17,7 @@
*/
package us.myles.ViaVersion.api.rewriters;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
@ -74,8 +74,7 @@ public class StatisticsRewriter {
});
}
@Nullable
protected IdRewriteFunction getRewriter(RegistryType type) {
protected @Nullable IdRewriteFunction getRewriter(RegistryType type) {
switch (type) {
case BLOCK:
return protocol.getMappingData().getBlockMappings() != null ? id -> protocol.getMappingData().getNewBlockId(id) : null;
@ -87,8 +86,7 @@ public class StatisticsRewriter {
throw new IllegalArgumentException("Unknown registry type in statistics packet: " + type);
}
@Nullable
public RegistryType getRegistryTypeForStatistic(int statisticsId) {
public @Nullable RegistryType getRegistryTypeForStatistic(int statisticsId) {
switch (statisticsId) {
case 0:
return RegistryType.BLOCK;

View File

@ -19,7 +19,7 @@ package us.myles.ViaVersion.api.rewriters;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.MappingData;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
@ -162,8 +162,7 @@ public class TagRewriter {
}
}
@Nullable
public List<TagData> getNewTags(RegistryType tagType) {
public @Nullable List<TagData> getNewTags(RegistryType tagType) {
return newTags.get(tagType);
}
@ -171,8 +170,7 @@ public class TagRewriter {
return newTags.computeIfAbsent(tagType, type -> new ArrayList<>());
}
@Nullable
public IdRewriteFunction getRewriter(RegistryType tagType) {
public @Nullable IdRewriteFunction getRewriter(RegistryType tagType) {
MappingData mappingData = protocol.getMappingData();
switch (tagType) {
case BLOCK:

View File

@ -17,7 +17,7 @@
*/
package us.myles.ViaVersion.api.storage;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.data.ExternalJoinGameListener;
import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection;
@ -48,8 +48,7 @@ public abstract class EntityTracker extends StoredObject implements ExternalJoin
return clientEntityTypes.containsKey(entityId);
}
@Nullable
public EntityType getEntity(int entityId) {
public @Nullable EntityType getEntity(int entityId) {
return clientEntityTypes.get(entityId);
}

View File

@ -23,7 +23,11 @@ import us.myles.ViaVersion.api.command.ViaSubCommand;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
public class PPSSubCmd extends ViaSubCommand {
@Override

View File

@ -19,7 +19,13 @@ package us.myles.ViaVersion.handlers;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.*;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelProgressivePromise;
import io.netty.channel.ChannelPromise;
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;
import io.netty.util.concurrent.EventExecutor;

View File

@ -26,7 +26,8 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_
public class InventoryPackets {
public static void register(Protocol1_10To1_9_3_4 protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, item -> {}, InventoryPackets::toServerItem);
ItemRewriter itemRewriter = new ItemRewriter(protocol, item -> {
}, InventoryPackets::toServerItem);
itemRewriter.registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
}

View File

@ -26,7 +26,8 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_
public class InventoryPackets {
public static void register(Protocol1_11_1To1_11 protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, item -> {}, InventoryPackets::toServerItem);
ItemRewriter itemRewriter = new ItemRewriter(protocol, item -> {
}, InventoryPackets::toServerItem);
itemRewriter.registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
}

View File

@ -23,10 +23,10 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.EntityIdRewriter;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.Protocol1_11To1_10;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
public class InventoryPackets {

View File

@ -24,11 +24,11 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.BedRewriter;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.providers.InventoryQuickMoveProvider;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
public class InventoryPackets {

View File

@ -119,7 +119,7 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
wrapper.write(Type.VAR_INT, 2); // Size
// Write root node
wrapper.write(Type.BYTE, (byte) 0); // Mark as command
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[] {1}); // 1 child at index 1
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{1}); // 1 child at index 1
// Write arg node
wrapper.write(Type.BYTE, (byte) (0x02 | 0x04 | 0x10)); // Mark as command

View File

@ -24,7 +24,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.api.data.Mappings;

View File

@ -17,7 +17,12 @@
*/
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.blockentities;
import com.github.steveice10.opennbt.tag.builtin.*;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.Position;
@ -64,7 +69,7 @@ public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
if (pattern instanceof CompoundTag) {
Tag c = ((CompoundTag) pattern).get("Color");
if (c instanceof IntTag) {
((IntTag)c).setValue(15 - (int) c.getValue()); // Invert color id
((IntTag) c).setValue(15 - (int) c.getValue()); // Invert color id
}
}
}

View File

@ -17,7 +17,7 @@
*/
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.rewriters.CommandRewriter;
@ -28,8 +28,7 @@ public class CommandRewriter1_14 extends CommandRewriter {
}
@Override
@Nullable
protected String handleArgumentType(String argumentType) {
protected @Nullable String handleArgumentType(String argumentType) {
if (argumentType.equals("minecraft:nbt")) {
return "minecraft:nbt_compound_tag";
}

View File

@ -17,7 +17,11 @@
*/
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets;
import com.github.steveice10.opennbt.tag.builtin.*;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.DoubleTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.google.common.collect.Sets;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

View File

@ -18,7 +18,7 @@
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data;
import com.google.gson.JsonObject;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.data.Mappings;
public class MappingData extends us.myles.ViaVersion.api.data.MappingData {

View File

@ -109,7 +109,7 @@ public class EntityPackets {
CompoundTag tag = new CompoundTag();
tag.put("piglin_safe", new ByteTag((byte) 1));
tag.put("natural", new ByteTag((byte) 0));
tag.put("ambient_light",new FloatTag( 0.1F));
tag.put("ambient_light", new FloatTag(0.1F));
tag.put("infiniburn", new StringTag("minecraft:infiniburn_nether"));
tag.put("respawn_anchor_works", new ByteTag((byte) 1));
tag.put("has_skylight", new ByteTag((byte) 0));

View File

@ -17,7 +17,7 @@
*/
package us.myles.ViaVersion.protocols.protocol1_17to1_16_4;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingData;
import us.myles.ViaVersion.api.data.UserConnection;
@ -228,8 +228,7 @@ public class Protocol1_17To1_16_4 extends Protocol<ClientboundPackets1_16_2, Cli
}
@Override
@Nullable
public MappingData getMappingData() {
public @Nullable MappingData getMappingData() {
return MAPPINGS;
}
}

View File

@ -17,7 +17,7 @@
*/
package us.myles.ViaVersion.protocols.protocol1_17to1_16_4.storage;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection;
@ -33,8 +33,7 @@ public class BiomeStorage extends StoredObject {
super(user);
}
@Nullable
public String getWorld() {
public @Nullable String getWorld() {
return world;
}
@ -42,8 +41,7 @@ public class BiomeStorage extends StoredObject {
this.world = world;
}
@Nullable
public int[] getBiomes(int x, int z) {
public int @Nullable [] getBiomes(int x, int z) {
return chunkBiomes.get(getChunkSectionIndex(x, z));
}

View File

@ -343,7 +343,7 @@ public class EntityPackets {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
if(wrapper.get(Type.UNSIGNED_BYTE, 0) == 3) {
if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 3) {
wrapper.cancel();
}
}

View File

@ -21,6 +21,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk1_8;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.type.PartialType;
import us.myles.ViaVersion.api.type.Type;
@ -28,7 +29,6 @@ import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
import us.myles.ViaVersion.api.type.types.version.Types1_8;
import us.myles.ViaVersion.api.type.types.version.Types1_9;
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks;
import java.util.ArrayList;

View File

@ -19,7 +19,7 @@ package us.myles.ViaVersion.update;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.util.GsonUtil;
@ -57,8 +57,7 @@ public class UpdateUtil {
});
}
@Nullable
private static String getUpdateMessage(boolean console) {
private static @Nullable String getUpdateMessage(boolean console) {
if (Via.getPlatform().getPluginVersion().equals("${version}")) {
return "You are using a debug/custom version, consider updating.";
}
@ -89,8 +88,7 @@ public class UpdateUtil {
return null;
}
@Nullable
private static String getNewestVersion() {
private static @Nullable String getNewestVersion() {
try {
URL url = new URL(URL + PLUGIN + LATEST_VERSION + "?" + System.currentTimeMillis());
HttpURLConnection connection = (HttpURLConnection) url.openConnection();

View File

@ -22,7 +22,11 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.CharStreams;
import java.io.*;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

View File

@ -17,13 +17,17 @@
*/
package us.myles.ViaVersion.util;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.representer.Representer;
import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@ -142,8 +146,7 @@ public abstract class Config implements ConfigurationProvider {
return this.config;
}
@Nullable
public <T> T get(String key, Class<T> clazz, T def) {
public @Nullable <T> T get(String key, Class<T> clazz, T def) {
Object o = this.config.get(key);
if (o != null) {
return (T) o;
@ -161,8 +164,7 @@ public abstract class Config implements ConfigurationProvider {
}
}
@Nullable
public String getString(String key, @Nullable String def) {
public @Nullable String getString(String key, @Nullable String def) {
final Object o = this.config.get(key);
if (o != null) {
return (String) o;

View File

@ -17,7 +17,7 @@
*/
package us.myles.ViaVersion.sponge.commands;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.command.CommandCallable;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult;