This commit is contained in:
themode 2022-03-10 16:07:56 +01:00
parent c1d65071d3
commit b906bd89ce
16 changed files with 32 additions and 23 deletions

View File

@ -8,6 +8,7 @@ import net.minestom.server.permission.Permission;
import net.minestom.server.tag.Tag;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import org.jglrxavpok.hephaistos.nbt.mutable.MutableNBTCompound;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -53,7 +54,7 @@ public class ConsoleSender implements CommandSender {
}
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
return tag.read(nbtCompound);
}

View File

@ -6,6 +6,7 @@ import net.minestom.server.permission.Permission;
import net.minestom.server.tag.Tag;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import org.jglrxavpok.hephaistos.nbt.mutable.MutableNBTCompound;
import java.util.Collections;
@ -31,7 +32,7 @@ public class ServerSender implements CommandSender {
}
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
return tag.read(nbtCompound);
}

View File

@ -63,6 +63,7 @@ import net.minestom.server.utils.validate.Check;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import org.jglrxavpok.hephaistos.nbt.mutable.MutableNBTCompound;
import space.vectrix.flare.fastutil.Int2ObjectSyncMap;
@ -1538,7 +1539,7 @@ public class Entity implements Viewable, Tickable, Schedulable, Snapshotable, Ev
}
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
return tag.read(nbtCompound);
}

View File

@ -11,6 +11,7 @@ import net.minestom.server.tag.TagReadable;
import net.minestom.server.utils.collection.IntMappedArray;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import java.util.Collection;
import java.util.Objects;
@ -24,7 +25,7 @@ final class EntitySnapshotImpl {
int[] viewersId, int[] passengersId, int vehicleId,
TagReadable tagReadable) implements EntitySnapshot {
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
return tagReadable.getTag(tag);
}
@ -108,7 +109,7 @@ final class EntitySnapshotImpl {
}
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
return snapshot.getTag(tag);
}
}

View File

@ -9,6 +9,7 @@ import net.minestom.server.tag.Tag;
import net.minestom.server.tag.TagHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import org.jglrxavpok.hephaistos.nbt.mutable.MutableNBTCompound;
/**
@ -127,7 +128,7 @@ public class DamageType implements TagHandler {
}
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
synchronized (nbtLock) {
return tag.read(nbt);
}

View File

@ -16,6 +16,7 @@ import net.minestom.server.utils.chunk.ChunkUtils;
import net.minestom.server.world.biomes.Biome;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import org.jglrxavpok.hephaistos.nbt.mutable.MutableNBTCompound;
import java.util.List;
@ -283,7 +284,7 @@ public abstract class Chunk implements Block.Getter, Block.Setter, Biome.Getter,
}
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
return tag.read(nbt);
}

View File

@ -38,6 +38,7 @@ import net.minestom.server.world.DimensionType;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
import org.jglrxavpok.hephaistos.nbt.mutable.MutableNBTCompound;
@ -598,7 +599,7 @@ public abstract class Instance implements Block.Getter, Block.Setter, Tickable,
}
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
synchronized (nbtLock) {
return tag.read(nbt);
}

View File

@ -53,7 +53,7 @@ final class InstanceSnapshotImpl {
}
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
return tagReadable.getTag(tag);
}
}
@ -90,7 +90,7 @@ final class InstanceSnapshotImpl {
}
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
return tagReadable.getTag(tag);
}

View File

@ -12,6 +12,7 @@ import net.minestom.server.utils.collection.MergedMap;
import net.minestom.server.utils.collection.ObjectArray;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import org.jetbrains.annotations.Unmodifiable;
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
import org.jglrxavpok.hephaistos.nbt.mutable.MutableNBTCompound;
@ -175,7 +176,7 @@ record BlockImpl(@NotNull Registry.BlockEntry registry,
}
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
return tag.read(Objects.requireNonNullElse(nbt, NBTCompound.EMPTY));
}

View File

@ -12,6 +12,7 @@ import net.minestom.server.utils.MathUtils;
import net.minestom.server.utils.validate.Check;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import org.jglrxavpok.hephaistos.nbt.mutable.MutableNBTCompound;
import java.lang.invoke.MethodHandles;
@ -250,7 +251,7 @@ public sealed abstract class AbstractInventory implements InventoryClickHandler,
}
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
synchronized (nbtLock) {
return tag.read(nbt);
}

View File

@ -10,6 +10,7 @@ import net.minestom.server.utils.binary.Writeable;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
import java.nio.ByteBuffer;
@ -114,7 +115,7 @@ public class ItemMeta implements TagReadable, Writeable {
}
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
return tag.read(nbt);
}

View File

@ -8,10 +8,7 @@ import net.minestom.server.tag.Tag;
import net.minestom.server.tag.TagReadable;
import net.minestom.server.utils.NBTUtils;
import net.minestom.server.utils.validate.Check;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.*;
import org.jglrxavpok.hephaistos.nbt.NBT;
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
@ -236,7 +233,7 @@ public final class ItemStack implements TagReadable, HoverEventSource<HoverEvent
}
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
return meta.getTag(tag);
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.tag;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import org.jglrxavpok.hephaistos.nbt.mutable.MutableNBTCompound;
/**
@ -22,7 +23,7 @@ public interface TagHandler extends TagReadable, TagWritable {
static @NotNull TagHandler fromCompound(@NotNull MutableNBTCompound compound) {
return new TagHandler() {
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
return tag.read(compound);
}

View File

@ -1,7 +1,6 @@
package net.minestom.server.tag;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import org.jglrxavpok.hephaistos.nbt.NBTCompoundLike;
@ -40,7 +39,7 @@ public interface TagReadable {
static @NotNull TagReadable fromCompound(@NotNull NBTCompoundLike compound) {
return new TagReadable() {
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
return tag.read(compound);
}
};

View File

@ -6,6 +6,7 @@ import net.minestom.server.permission.Permission;
import net.minestom.server.tag.Tag;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import org.junit.jupiter.api.Test;
import java.util.Set;
@ -132,7 +133,7 @@ public class CommandConditionTest {
}
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
return null;
}

View File

@ -7,6 +7,7 @@ import net.minestom.server.permission.Permission;
import net.minestom.server.tag.Tag;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import org.junit.jupiter.api.Test;
import java.util.Set;
@ -72,7 +73,7 @@ public class CommandParsingTest {
}
@Override
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
public <T> @UnknownNullability T getTag(@NotNull Tag<T> tag) {
return null;
}