From d20cf85982178e11ea7ae20e5dd327d9d4705c6e Mon Sep 17 00:00:00 2001 From: themode Date: Wed, 23 Mar 2022 07:04:05 +0100 Subject: [PATCH] Unnecessary class parameter --- .../java/net/minestom/server/tag/Tag.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/main/java/net/minestom/server/tag/Tag.java b/src/main/java/net/minestom/server/tag/Tag.java index 806cc4867..48ec57e2f 100644 --- a/src/main/java/net/minestom/server/tag/Tag.java +++ b/src/main/java/net/minestom/server/tag/Tag.java @@ -61,10 +61,9 @@ public class Tag { } static Tag tag(@NotNull String key, - @NotNull Class nbtClass, @NotNull Function readFunction, @NotNull Function writeFunction) { - return new Tag(key, (Function) readFunction, (Function) writeFunction, null); + return new Tag<>(key, (Function) readFunction, (Function) writeFunction, null); } /** @@ -137,36 +136,35 @@ public class Tag { } public static @NotNull Tag Byte(@NotNull String key) { - return tag(key, NBTByte.class, NBTByte::getValue, NBT::Byte); + return tag(key, NBTByte::getValue, NBT::Byte); } public static @NotNull Tag Short(@NotNull String key) { - return tag(key, NBTShort.class, NBTShort::getValue, NBT::Short); + return tag(key, NBTShort::getValue, NBT::Short); } public static @NotNull Tag Integer(@NotNull String key) { - return tag(key, NBTInt.class, NBTInt::getValue, NBT::Int); + return tag(key, NBTInt::getValue, NBT::Int); } public static @NotNull Tag Long(@NotNull String key) { - return tag(key, NBTLong.class, NBTLong::getValue, NBT::Long); + return tag(key, NBTLong::getValue, NBT::Long); } public static @NotNull Tag Float(@NotNull String key) { - return tag(key, NBTFloat.class, NBTFloat::getValue, NBT::Float); + return tag(key, NBTFloat::getValue, NBT::Float); } public static @NotNull Tag Double(@NotNull String key) { - return tag(key, NBTDouble.class, NBTDouble::getValue, NBT::Double); + return tag(key, NBTDouble::getValue, NBT::Double); } public static @NotNull Tag String(@NotNull String key) { - return tag(key, NBTString.class, NBTString::getValue, NBT::String); + return tag(key, NBTString::getValue, NBT::String); } public static @NotNull Tag NBT(@NotNull String key) { - //noinspection unchecked - return tag(key, NBT.class, nbt -> (T) nbt, t -> t); + return Tag.tag(key, nbt -> nbt, t -> t); } /** @@ -178,8 +176,8 @@ public class Tag { * @return the created tag */ public static @NotNull Tag Structure(@NotNull String key, @NotNull TagSerializer serializer) { - return tag(key, NBTCompound.class, - nbt -> serializer.read(TagHandler.fromCompound(nbt)), + return tag(key, + (NBTCompound compound) -> serializer.read(TagHandler.fromCompound(compound)), (value) -> { TagHandler handler = TagHandler.newHandler(); serializer.write(handler, value); @@ -188,8 +186,8 @@ public class Tag { } public static @NotNull Tag View(@NotNull TagSerializer serializer) { - return tag("", NBTCompound.class, - nbt -> serializer.read(TagHandler.fromCompound(nbt)), + return tag("", + (NBTCompound compound) -> serializer.read(TagHandler.fromCompound(compound)), (value) -> { TagHandler handler = TagHandler.newHandler(); serializer.write(handler, value); @@ -198,6 +196,6 @@ public class Tag { } public static @NotNull Tag ItemStack(@NotNull String key) { - return tag(key, NBTCompound.class, ItemStack::fromItemNBT, ItemStack::toItemNBT); + return tag(key, ItemStack::fromItemNBT, ItemStack::toItemNBT); } }