Move to checker qual nullability annotations

This commit is contained in:
KennyTV 2021-04-02 14:19:24 +02:00
parent 8d7ed4c16c
commit 066fef0513
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
21 changed files with 47 additions and 73 deletions

View File

@ -7,7 +7,7 @@ object Versions {
const val guava = "17.0"
const val fabricLoader = "0.4.8+build.154"
const val log4j = "2.8.1"
const val jetbrainsAnnotations = "20.1.0"
const val checkerQual = "3.12.0"
// Platforms
const val spigot = "1.16.5-R0.1-SNAPSHOT"

View File

@ -11,5 +11,5 @@ dependencies {
compileOnly("io.netty", "netty-all", Versions.netty)
compileOnlyApi("us.myles", "viaversion", Versions.viaversion)
compileOnlyApi("com.google.guava", "guava", Versions.guava)
compileOnlyApi("org.jetbrains", "annotations", Versions.jetbrainsAnnotations)
compileOnlyApi("org.checkerframework", "checker-qual", Versions.checkerQual)
}

View File

@ -19,7 +19,7 @@ package nl.matsv.viabackwards.api;
import nl.matsv.viabackwards.api.data.BackwardsMappings;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
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 us.myles.ViaVersion.api.protocol.ClientboundPacketType;

View File

@ -19,7 +19,7 @@ package nl.matsv.viabackwards.api.data;
import com.google.common.base.Preconditions;
import nl.matsv.viabackwards.api.BackwardsProtocol;
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.Mappings;
@ -71,8 +71,7 @@ public class BackwardsMappings extends MappingData {
}
@Override
@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;
@ -80,8 +79,7 @@ public class BackwardsMappings extends MappingData {
}
@Override
@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;
@ -124,13 +122,11 @@ public class BackwardsMappings extends MappingData {
return checkValidity(id, this.itemMappings.inverse().get(id), "item");
}
@Nullable
public MappedItem getMappedItem(int id) {
public @Nullable MappedItem getMappedItem(int id) {
return backwardsItemMappings != null ? backwardsItemMappings.get(id) : null;
}
@Nullable
public String getMappedNamedSound(String id) {
public @Nullable String getMappedNamedSound(String id) {
if (backwardsItemMappings == null) {
return null;
}
@ -142,13 +138,11 @@ public class BackwardsMappings extends MappingData {
return backwardsSoundMappings.get(id);
}
@Nullable
public Int2ObjectMap<MappedItem> getBackwardsItemMappings() {
public @Nullable Int2ObjectMap<MappedItem> getBackwardsItemMappings() {
return backwardsItemMappings;
}
@Nullable
public Map<String, String> getBackwardsSoundMappings() {
public @Nullable Map<String, String> getBackwardsSoundMappings() {
return backwardsSoundMappings;
}
}

View File

@ -18,7 +18,7 @@
package nl.matsv.viabackwards.api.data;
import nl.matsv.viabackwards.utils.Block;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
public class MappedLegacyBlockItem {
@ -60,8 +60,7 @@ public class MappedLegacyBlockItem {
return blockEntityHandler != null;
}
@Nullable
public BlockEntityHandler getBlockEntityHandler() {
public @Nullable BlockEntityHandler getBlockEntityHandler() {
return blockEntityHandler;
}

View File

@ -20,7 +20,7 @@ package nl.matsv.viabackwards.api.entities.meta;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
@ -87,8 +87,7 @@ public class MetaHandlerEvent {
/**
* May be null, use {@link #createMeta(Metadata)} for adding metadata.
*/
@Nullable
public List<Metadata> getExtraData() {
public @Nullable List<Metadata> getExtraData() {
return extraData;
}
}

View File

@ -19,7 +19,7 @@
package nl.matsv.viabackwards.api.entities.meta;
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.entities.EntityType;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
@ -109,8 +109,7 @@ public class MetaHandlerSettings {
return filterIndex;
}
@Nullable
public MetaHandler getHandler() {
public @Nullable MetaHandler getHandler() {
return handler;
}

View File

@ -18,7 +18,7 @@
package nl.matsv.viabackwards.api.entities.storage;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
public class EntityData {
@ -58,8 +58,7 @@ public class EntityData {
/**
* @return custom mobname, can be either a String or a JsonElement
*/
@Nullable
public Object getMobName() {
public @Nullable Object getMobName() {
return mobName;
}
@ -67,8 +66,7 @@ public class EntityData {
return replacementId;
}
@Nullable
public MetaCreator getDefaultMeta() {
public @Nullable MetaCreator getDefaultMeta() {
return defaultMeta;
}

View File

@ -19,7 +19,7 @@
package nl.matsv.viabackwards.api.entities.storage;
import nl.matsv.viabackwards.api.BackwardsProtocol;
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;
import us.myles.ViaVersion.api.entities.EntityType;
@ -41,8 +41,7 @@ public class EntityTracker extends StoredObject {
trackers.put(protocol, new ProtocolEntityTracker());
}
@Nullable
public ProtocolEntityTracker get(BackwardsProtocol protocol) {
public @Nullable ProtocolEntityTracker get(BackwardsProtocol protocol) {
return trackers.get(protocol);
}

View File

@ -18,7 +18,7 @@
package nl.matsv.viabackwards.api.entities.storage;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import java.util.List;
@ -46,8 +46,7 @@ public class MetaStorage {
this.metaDataList.add(data);
}
@Nullable
public Metadata get(int index) {
public @Nullable Metadata get(int index) {
for (Metadata meta : this.metaDataList) {
if (index == meta.getId()) {
return meta;

View File

@ -26,7 +26,7 @@ import nl.matsv.viabackwards.api.entities.storage.EntityData;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
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.ParticleMappings;
@ -91,8 +91,7 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
return entityTypes.containsKey(type);
}
@Nullable
protected EntityData getEntityData(EntityType type) {
protected @Nullable EntityData getEntityData(EntityType type) {
return entityTypes.get(type);
}

View File

@ -19,7 +19,7 @@ package nl.matsv.viabackwards.api.rewriters;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.data.MappedItem;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.viaversion.libs.opennbt.tag.builtin.ByteTag;
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
@ -38,8 +38,7 @@ public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewr
}
@Override
@Nullable
public Item handleItemToClient(Item item) {
public @Nullable Item handleItemToClient(Item item) {
if (item == null) return null;
CompoundTag display = item.getTag() != null ? item.getTag().get("display") : null;
@ -100,8 +99,7 @@ public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewr
}
@Override
@Nullable
public Item handleItemToServer(Item item) {
public @Nullable Item handleItemToServer(Item item) {
if (item == null) return null;
super.handleItemToServer(item);

View File

@ -18,7 +18,7 @@
package nl.matsv.viabackwards.api.rewriters;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
@ -36,8 +36,7 @@ public abstract class ItemRewriterBase<T extends BackwardsProtocol> extends Rewr
nbtTagName = "VB|" + protocol.getClass().getSimpleName();
}
@Nullable
public Item handleItemToClient(Item item) {
public @Nullable Item handleItemToClient(Item item) {
if (item == null) return null;
if (protocol.getMappingData() != null && protocol.getMappingData().getItemMappings() != null) {
item.setIdentifier(protocol.getMappingData().getNewItemId(item.getIdentifier()));
@ -45,8 +44,7 @@ public abstract class ItemRewriterBase<T extends BackwardsProtocol> extends Rewr
return item;
}
@Nullable
public Item handleItemToServer(Item item) {
public @Nullable Item handleItemToServer(Item item) {
if (item == null) return null;
if (protocol.getMappingData() != null && protocol.getMappingData().getItemMappings() != null) {
item.setIdentifier(protocol.getMappingData().getOldItemId(item.getIdentifier()));

View File

@ -23,7 +23,7 @@ import nl.matsv.viabackwards.api.data.MappedLegacyBlockItem;
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.BlockColors;
import nl.matsv.viabackwards.utils.Block;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.minecraft.item.Item;
@ -92,8 +92,7 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
}
@Override
@Nullable
public Item handleItemToClient(Item item) {
public @Nullable Item handleItemToClient(Item item) {
if (item == null) return null;
MappedLegacyBlockItem data = replacementData.get(item.getIdentifier());
@ -145,8 +144,7 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
return (b.getId() << 4 | (b.getData() & 15));
}
@Nullable
public Block handleBlock(int blockId, int data) {
public @Nullable Block handleBlock(int blockId, int data) {
MappedLegacyBlockItem settings = replacementData.get(blockId);
if (settings == null || !settings.isBlock()) return null;

View File

@ -22,7 +22,7 @@ import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.entities.storage.EntityData;
import nl.matsv.viabackwards.api.entities.storage.EntityObjectData;
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.entities.EntityType;
import us.myles.ViaVersion.api.entities.ObjectType;
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
@ -56,8 +56,7 @@ public abstract class LegacyEntityRewriter<T extends BackwardsProtocol> extends
return entData;
}
@Nullable
protected EntityData getObjectData(ObjectType type) {
protected @Nullable EntityData getObjectData(ObjectType type) {
return objectTypes.get(type);
}

View File

@ -21,7 +21,7 @@ package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
import nl.matsv.viabackwards.api.rewriters.LegacyBlockItemRewriter;
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.MapColorMapping;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;

View File

@ -20,7 +20,7 @@ package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.data.VBMappings;
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;
@ -95,8 +95,7 @@ public class BackwardsMappings extends nl.matsv.viabackwards.api.data.BackwardsM
}
@Override
@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 (key.equals("blockstates")) {
short[] oldToNew = new short[8582];
Arrays.fill(oldToNew, (short) -1);

View File

@ -17,7 +17,7 @@
*/
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.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;
import us.myles.ViaVersion.api.type.Type;
@ -37,8 +37,7 @@ public class CommandRewriter1_14 extends CommandRewriter {
}
@Override
@Nullable
protected String handleArgumentType(String argumentType) {
protected @Nullable String handleArgumentType(String argumentType) {
switch (argumentType) {
case "minecraft:nbt_compound_tag":
return "minecraft:nbt";

View File

@ -17,7 +17,7 @@
*/
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.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;
import us.myles.ViaVersion.api.type.Type;
@ -33,8 +33,7 @@ public class CommandRewriter1_13_1 extends CommandRewriter {
}
@Override
@Nullable
protected String handleArgumentType(String argumentType) {
protected @Nullable String handleArgumentType(String argumentType) {
if (argumentType.equals("minecraft:column_pos")) {
return "minecraft:vec2";
} else if (argumentType.equals("minecraft:dimension")) {

View File

@ -17,7 +17,7 @@
*/
package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.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_16 extends CommandRewriter {
}
@Override
@Nullable
protected String handleArgumentType(String argumentType) {
protected @Nullable String handleArgumentType(String argumentType) {
if (argumentType.equals("minecraft:uuid")) {
return "minecraft:game_profile";
}

View File

@ -17,7 +17,7 @@
*/
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_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;
import us.myles.ViaVersion.api.type.Type;
@ -33,8 +33,7 @@ public class CommandRewriter1_16_2 extends CommandRewriter {
}
@Override
@Nullable
protected String handleArgumentType(String argumentType) {
protected @Nullable String handleArgumentType(String argumentType) {
if (argumentType.equals("minecraft:angle")) {
return "brigadier:string";
}