From 10d9b82a17ea81f337571b6692003b7d98ac8c65 Mon Sep 17 00:00:00 2001 From: Quie_ Date: Wed, 10 Jan 2024 12:30:15 -0500 Subject: [PATCH] Worked on switching some Serializer classes to ArgumentType classes and adding the serializers as subclasses. --- .../redstonetools/RedstoneToolsClient.java | 9 --- .../features/arguments/Argument.java | 10 +-- .../serializers/BigIntegerArgumentType.java | 69 +++++++++++++++++++ .../serializers/BigIntegerSerializer.java | 33 --------- ...lizer.java => BlockStateArgumentType.java} | 36 ++++++++-- ...alizer.java => BrigadierArgumentType.java} | 10 ++- .../serializers/CollectionSerializer.java | 14 ++-- .../arguments/serializers/EnumSerializer.java | 4 +- ...rializer.java => GenericArgumentType.java} | 15 ++-- ...rializer.java => IntLikeArgumentType.java} | 36 ++++++++-- .../serializers/IntegerSerializer.java | 2 +- .../arguments/serializers/LongSerializer.java | 2 +- ...lizer.java => NumberBaseArgumentType.java} | 35 ++++++++-- .../serializers/NumberSerializer.java | 2 +- .../StringBrigadierSerializer.java | 2 +- .../features/commands/BaseConvertFeature.java | 2 +- .../commands/BinaryBlockReadFeature.java | 9 +-- .../redstonetools/utils/ReflectionUtils.java | 6 +- 18 files changed, 198 insertions(+), 98 deletions(-) create mode 100644 src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BigIntegerArgumentType.java delete mode 100644 src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BigIntegerSerializer.java rename src/main/java/tools/redstone/redstonetools/features/arguments/serializers/{BlockStateArgumentSerializer.java => BlockStateArgumentType.java} (50%) rename src/main/java/tools/redstone/redstonetools/features/arguments/serializers/{BrigadierSerializer.java => BrigadierArgumentType.java} (66%) rename src/main/java/tools/redstone/redstonetools/features/arguments/serializers/{TypeSerializer.java => GenericArgumentType.java} (94%) rename src/main/java/tools/redstone/redstonetools/features/arguments/serializers/{IntLikeSerializer.java => IntLikeArgumentType.java} (75%) rename src/main/java/tools/redstone/redstonetools/features/arguments/serializers/{NumberBaseSerializer.java => NumberBaseArgumentType.java} (64%) diff --git a/src/main/java/tools/redstone/redstonetools/RedstoneToolsClient.java b/src/main/java/tools/redstone/redstonetools/RedstoneToolsClient.java index 2a4403b1..551ad222 100644 --- a/src/main/java/tools/redstone/redstonetools/RedstoneToolsClient.java +++ b/src/main/java/tools/redstone/redstonetools/RedstoneToolsClient.java @@ -1,23 +1,14 @@ package tools.redstone.redstonetools; import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.fabric.api.command.v2.ArgumentTypeRegistry; import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.client.MinecraftClient; -import net.minecraft.command.argument.serialize.ArgumentSerializer; -import net.minecraft.command.argument.serialize.ConstantArgumentSerializer; -import net.minecraft.util.Identifier; import org.reflections.Reflections; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.mojang.brigadier.arguments.ArgumentType; - import rip.hippo.inject.Doctor; import rip.hippo.inject.Injector; -import tools.redstone.redstonetools.features.arguments.serializers.IntegerSerializer; -import tools.redstone.redstonetools.features.arguments.serializers.TypeSerializer; import tools.redstone.redstonetools.utils.DependencyLookup; import tools.redstone.redstonetools.utils.ReflectionUtils; diff --git a/src/main/java/tools/redstone/redstonetools/features/arguments/Argument.java b/src/main/java/tools/redstone/redstonetools/features/arguments/Argument.java index 683536c0..89cb76ae 100644 --- a/src/main/java/tools/redstone/redstonetools/features/arguments/Argument.java +++ b/src/main/java/tools/redstone/redstonetools/features/arguments/Argument.java @@ -1,20 +1,20 @@ package tools.redstone.redstonetools.features.arguments; -import tools.redstone.redstonetools.features.arguments.serializers.TypeSerializer; +import tools.redstone.redstonetools.features.arguments.serializers.GenericArgumentType; import com.mojang.brigadier.context.CommandContext; public class Argument { private String name; - private final TypeSerializer type; + private final GenericArgumentType type; private boolean optional = false; private volatile T value; private T defaultValue; - private Argument(TypeSerializer type) { + private Argument(GenericArgumentType type) { this.type = type; } - public static Argument ofType(TypeSerializer type) { + public static Argument ofType(GenericArgumentType type) { return new Argument<>(type); } @@ -48,7 +48,7 @@ public String getName() { return name; } - public TypeSerializer getType() { + public GenericArgumentType getType() { return type; } diff --git a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BigIntegerArgumentType.java b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BigIntegerArgumentType.java new file mode 100644 index 00000000..b3651c4a --- /dev/null +++ b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BigIntegerArgumentType.java @@ -0,0 +1,69 @@ +package tools.redstone.redstonetools.features.arguments.serializers; + +import net.minecraft.command.CommandRegistryAccess; +import net.minecraft.command.argument.serialize.ArgumentSerializer; + +import java.math.BigInteger; +import java.util.Optional; + +public class BigIntegerArgumentType extends IntLikeArgumentType { + private static final BigIntegerArgumentType INSTANCE = new BigIntegerArgumentType(null, null); + + public static BigIntegerArgumentType bigInteger() { + return INSTANCE; + } + + public static BigIntegerArgumentType bigInteger(BigInteger min) { + return new BigIntegerArgumentType(min, null); + } + + public static BigIntegerArgumentType bigInteger(BigInteger min, BigInteger max) { + return new BigIntegerArgumentType(min, max); + } + + private BigIntegerArgumentType(BigInteger min, BigInteger max) { + super(BigInteger.class, min, max); + + } + + @Override + protected Optional tryParseOptional(String string, int radix) { + try { + return Optional.of(new BigInteger(string, radix)); + } catch (NumberFormatException ignored) { + return Optional.empty(); + } + } + + public static class BigIntegerSerializer extends Serializer>{ + + @Override + public ArgumentTypeProperties getArgumentTypeProperties(BigIntegerArgumentType argumentType) { + return new Properties(argumentType.max,argumentType.min); + } + + public final class Properties + implements ArgumentSerializer.ArgumentTypeProperties{ + final BigInteger max, min; + + public Properties(BigInteger max, BigInteger min) { + this.max = max; + this.min = min; + } + + @Override + public BigIntegerArgumentType createType(CommandRegistryAccess commandRegistryAccess) { + return new BigIntegerArgumentType(this.max,this.min); + } + + @Override + public ArgumentSerializer getSerializer() { + return BigIntegerSerializer.this; + } + } + } + + + + +} diff --git a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BigIntegerSerializer.java b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BigIntegerSerializer.java deleted file mode 100644 index 36b94bbb..00000000 --- a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BigIntegerSerializer.java +++ /dev/null @@ -1,33 +0,0 @@ -package tools.redstone.redstonetools.features.arguments.serializers; - -import java.math.BigInteger; -import java.util.Optional; - -public class BigIntegerSerializer extends IntLikeSerializer { - private static final BigIntegerSerializer INSTANCE = new BigIntegerSerializer(null, null); - - public static BigIntegerSerializer bigInteger() { - return INSTANCE; - } - - public static BigIntegerSerializer bigInteger(BigInteger min) { - return new BigIntegerSerializer(min, null); - } - - public static BigIntegerSerializer bigInteger(BigInteger min, BigInteger max) { - return new BigIntegerSerializer(min, max); - } - - private BigIntegerSerializer(BigInteger min, BigInteger max) { - super(BigInteger.class, min, max); - } - - @Override - protected Optional tryParseOptional(String string, int radix) { - try { - return Optional.of(new BigInteger(string, radix)); - } catch (NumberFormatException ignored) { - return Optional.empty(); - } - } -} diff --git a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BlockStateArgumentSerializer.java b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BlockStateArgumentType.java similarity index 50% rename from src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BlockStateArgumentSerializer.java rename to src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BlockStateArgumentType.java index b16446ce..9ce1dbcb 100644 --- a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BlockStateArgumentSerializer.java +++ b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BlockStateArgumentType.java @@ -4,20 +4,20 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.command.CommandRegistryAccess; import net.minecraft.command.argument.BlockStateArgument; -import net.minecraft.command.argument.BlockStateArgumentType; +import net.minecraft.command.argument.serialize.ArgumentSerializer; import net.minecraft.registry.Registries; -public class BlockStateArgumentSerializer extends BrigadierSerializer { +public class BlockStateArgumentType extends BrigadierArgumentType { - private static BlockStateArgumentSerializer INSTANCE; + private static BlockStateArgumentType INSTANCE; - private BlockStateArgumentSerializer(CommandRegistryAccess registryAccess) { - super(BlockStateArgument.class, BlockStateArgumentType.blockState(registryAccess)); + private BlockStateArgumentType(CommandRegistryAccess registryAccess) { + super(BlockStateArgument.class, net.minecraft.command.argument.BlockStateArgumentType.blockState(registryAccess)); } - public static BlockStateArgumentSerializer blockState(CommandRegistryAccess registryAccess) { + public static BlockStateArgumentType blockState(CommandRegistryAccess registryAccess) { if (INSTANCE == null) { - INSTANCE = new BlockStateArgumentSerializer(registryAccess); + INSTANCE = new BlockStateArgumentType(registryAccess); } return INSTANCE; @@ -62,4 +62,26 @@ public String serialize(BlockStateArgument value) { return builder.toString(); } + public static class BlockStateArgumentSerializer extends Serializer>{ + + @Override + public ArgumentTypeProperties getArgumentTypeProperties(BlockStateArgumentType argumentType) { + return new Properties(); + } + + public final class Properties + implements ArgumentSerializer.ArgumentTypeProperties{ + + @Override + public BlockStateArgumentType createType(CommandRegistryAccess commandRegistryAccess) { + return new BlockStateArgumentType(commandRegistryAccess); + } + + @Override + public ArgumentSerializer getSerializer() { + return BlockStateArgumentSerializer.this; + } + } + } + } diff --git a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BrigadierSerializer.java b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BrigadierArgumentType.java similarity index 66% rename from src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BrigadierSerializer.java rename to src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BrigadierArgumentType.java index 5a2e5ba9..846a3bcf 100644 --- a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BrigadierSerializer.java +++ b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/BrigadierArgumentType.java @@ -6,16 +6,17 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import net.minecraft.command.argument.serialize.ArgumentSerializer; import java.util.Collection; import java.util.concurrent.CompletableFuture; -public abstract class BrigadierSerializer extends TypeSerializer { +public abstract class BrigadierArgumentType extends GenericArgumentType { // the wrapped brigadier argument type private final ArgumentType argumentType; - public BrigadierSerializer(Class clazz, ArgumentType argumentType) { + public BrigadierArgumentType(Class clazz, ArgumentType argumentType) { super(clazz); this.argumentType = argumentType; } @@ -35,4 +36,9 @@ public Collection getExamples() { return argumentType.getExamples(); } + public abstract class BrigadierSerializer extends Serializer,ArgumentSerializer.ArgumentTypeProperties>>{ + + public abstract ArgumentTypeProperties> getArgumentTypeProperties(BrigadierArgumentType argumentType); + + } } diff --git a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/CollectionSerializer.java b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/CollectionSerializer.java index c68c7c29..16bb16b7 100644 --- a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/CollectionSerializer.java +++ b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/CollectionSerializer.java @@ -18,18 +18,18 @@ * @param The collection type. */ public class CollectionSerializer> - extends TypeSerializer> + extends GenericArgumentType> { - public static CollectionSerializer> listOf(TypeSerializer element) { + public static CollectionSerializer> listOf(GenericArgumentType element) { return new CollectionSerializer<>(List.class, element, ArrayList::new); } - public static CollectionSerializer> setOf(TypeSerializer element) { + public static CollectionSerializer> setOf(GenericArgumentType element) { return new CollectionSerializer<>(Set.class, element, HashSet::new); } - final TypeSerializer elementType; + final GenericArgumentType elementType; final Function, C> collectionFactory; // cache example because @@ -39,10 +39,10 @@ public static CollectionSerializer> setOf(TypeSerializer ele @SuppressWarnings("unchecked") protected CollectionSerializer(Class clazz, - TypeSerializer elementType, + GenericArgumentType elementType, Function, C> collectionFactory) { super((Class) clazz); - this.elementType = (TypeSerializer) elementType; + this.elementType = (GenericArgumentType) elementType; this.collectionFactory = collectionFactory; // build example @@ -55,7 +55,7 @@ protected CollectionSerializer(Class clazz, this.example = b.delete(b.length() - 3, b.length()).append("]").toString(); } - public TypeSerializer getElementType() { + public GenericArgumentType getElementType() { return elementType; } diff --git a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/EnumSerializer.java b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/EnumSerializer.java index af7d354a..35315687 100644 --- a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/EnumSerializer.java +++ b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/EnumSerializer.java @@ -9,12 +9,10 @@ import java.util.Collection; import java.util.EnumSet; -import java.util.List; -import java.util.Optional; import java.util.concurrent.CompletableFuture; public abstract class EnumSerializer> - extends TypeSerializer { + extends GenericArgumentType { protected EnumSerializer(Class clazz) { super(clazz); diff --git a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/TypeSerializer.java b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/GenericArgumentType.java similarity index 94% rename from src/main/java/tools/redstone/redstonetools/features/arguments/serializers/TypeSerializer.java rename to src/main/java/tools/redstone/redstonetools/features/arguments/serializers/GenericArgumentType.java index ab4b148a..f444a1d2 100644 --- a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/TypeSerializer.java +++ b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/GenericArgumentType.java @@ -1,12 +1,15 @@ package tools.redstone.redstonetools.features.arguments.serializers; +import com.google.common.reflect.TypeToken; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import com.google.gson.stream.JsonReader; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; - import net.minecraft.command.argument.serialize.ArgumentSerializer; import net.minecraft.command.argument.serialize.ArgumentSerializer.ArgumentTypeProperties; import net.minecraft.network.PacketByteBuf; @@ -14,24 +17,19 @@ import java.util.Collection; import java.util.concurrent.CompletableFuture; -import com.google.common.reflect.TypeToken; -import com.google.gson.JsonObject; -import com.google.gson.stream.JsonReader; -import com.google.gson.Gson; - /** * Base class for the 'wrapped' argument type. * * @param The value type. * @param The serialized type. */ -public abstract class TypeSerializer implements ArgumentType { +public abstract class GenericArgumentType implements ArgumentType { protected final Class clazz; // TODO: Consider moving this constructor to enum serializer as it's the only // class that uses the clazz field - protected TypeSerializer(Class clazz) { + protected GenericArgumentType(Class clazz) { this.clazz = clazz; } @@ -58,7 +56,6 @@ public final T parse(StringReader reader) throws CommandSyntaxException { public abstract CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder); - public abstract Serializer getSerializer(); public static abstract class Serializer, T extends ArgumentTypeProperties> implements ArgumentSerializer { diff --git a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/IntLikeSerializer.java b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/IntLikeArgumentType.java similarity index 75% rename from src/main/java/tools/redstone/redstonetools/features/arguments/serializers/IntLikeSerializer.java rename to src/main/java/tools/redstone/redstonetools/features/arguments/serializers/IntLikeArgumentType.java index 987d7df1..58b77389 100644 --- a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/IntLikeSerializer.java +++ b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/IntLikeArgumentType.java @@ -5,6 +5,8 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import net.minecraft.command.CommandRegistryAccess; +import net.minecraft.command.argument.serialize.ArgumentSerializer; import net.minecraft.text.Text; import tools.redstone.redstonetools.utils.NumberBase; @@ -13,13 +15,13 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; -public abstract class IntLikeSerializer> extends TypeSerializer { - private final T min; +public abstract class IntLikeArgumentType> extends GenericArgumentType { + final T min; private final boolean hasMin; - private final T max; + final T max; private final boolean hasMax; - protected IntLikeSerializer(Class clazz, T min, T max) { + protected IntLikeArgumentType(Class clazz, T min, T max) { super(clazz); this.min = min; @@ -127,4 +129,30 @@ public Collection getExamples() { public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { return builder.buildFuture(); } + +// public static abstract class IntLikeSerializer extends Serializer, ArgumentSerializer.ArgumentTypeProperties>>{ +// +// @Override +// public ArgumentTypeProperties> getArgumentTypeProperties(IntLikeArgumentType argumentType) { +// return new Properties(argumentType.max,argumentType.min); +// } +// +// public abstract class Properties implements ArgumentTypeProperties>{ +// +// final T max, min; +// +// public Properties(T max, T min) { +// this.max = max; +// this.min = min; +// } +// +// @Override +// public abstract IntLikeArgumentType createType(CommandRegistryAccess commandRegistryAccess); +// +// @Override +// public ArgumentSerializer, ?> getSerializer() { +// return IntLikeSerializer.this; +// } +// } +// } } diff --git a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/IntegerSerializer.java b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/IntegerSerializer.java index 8a53cf08..22f53850 100644 --- a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/IntegerSerializer.java +++ b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/IntegerSerializer.java @@ -2,7 +2,7 @@ import java.util.Optional; -public class IntegerSerializer extends IntLikeSerializer { +public class IntegerSerializer extends IntLikeArgumentType { private static final IntegerSerializer INSTANCE = new IntegerSerializer(Integer.MIN_VALUE, Integer.MAX_VALUE); public static IntegerSerializer integer() { diff --git a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/LongSerializer.java b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/LongSerializer.java index 43516d84..3038e6a0 100644 --- a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/LongSerializer.java +++ b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/LongSerializer.java @@ -2,7 +2,7 @@ import java.util.Optional; -public class LongSerializer extends IntLikeSerializer { +public class LongSerializer extends IntLikeArgumentType { private static final LongSerializer INSTANCE = new LongSerializer(Long.MIN_VALUE, Long.MAX_VALUE); public static LongSerializer longArg() { diff --git a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/NumberBaseSerializer.java b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/NumberBaseArgumentType.java similarity index 64% rename from src/main/java/tools/redstone/redstonetools/features/arguments/serializers/NumberBaseSerializer.java rename to src/main/java/tools/redstone/redstonetools/features/arguments/serializers/NumberBaseArgumentType.java index 87126ee2..acace7d2 100644 --- a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/NumberBaseSerializer.java +++ b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/NumberBaseArgumentType.java @@ -5,6 +5,8 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import net.minecraft.command.CommandRegistryAccess; +import net.minecraft.command.argument.serialize.ArgumentSerializer; import net.minecraft.text.Text; import tools.redstone.redstonetools.utils.NumberBase; @@ -12,15 +14,15 @@ import java.util.Collection; import java.util.concurrent.CompletableFuture; -public class NumberBaseSerializer extends TypeSerializer { +public class NumberBaseArgumentType extends GenericArgumentType { private static final IntegerSerializer INT_SERIALIZER = IntegerSerializer.integer(2, 36); - private static final NumberBaseSerializer INSTANCE = new NumberBaseSerializer(); + private static final NumberBaseArgumentType INSTANCE = new NumberBaseArgumentType(); - public static NumberBaseSerializer numberBase() { + public static NumberBaseArgumentType numberBase() { return INSTANCE; } - protected NumberBaseSerializer() { + protected NumberBaseArgumentType() { super(Integer.class); } @@ -72,4 +74,29 @@ public CompletableFuture listSuggestions(CommandContext cont return builder.buildFuture(); } + + public static class NumberBaseSerializer extends Serializer>{ + + @Override + public ArgumentTypeProperties getArgumentTypeProperties(NumberBaseArgumentType argumentType) { + return new Properties(); + } + + public final class Properties + implements ArgumentSerializer.ArgumentTypeProperties{ + + @Override + public NumberBaseArgumentType createType(CommandRegistryAccess commandRegistryAccess) { + return new NumberBaseArgumentType(); + } + + @Override + public ArgumentSerializer getSerializer() { + return NumberBaseSerializer.this; + } + } + + } + + } diff --git a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/NumberSerializer.java b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/NumberSerializer.java index 320eb217..a12d9744 100644 --- a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/NumberSerializer.java +++ b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/NumberSerializer.java @@ -4,7 +4,7 @@ import java.util.Optional; -public class NumberSerializer extends IntLikeSerializer { +public class NumberSerializer extends IntLikeArgumentType { private static final NumberSerializer INSTANCE = new NumberSerializer(null,null); public static NumberSerializer numberArg(){ diff --git a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/StringBrigadierSerializer.java b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/StringBrigadierSerializer.java index f5dba14b..67cb02ec 100644 --- a/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/StringBrigadierSerializer.java +++ b/src/main/java/tools/redstone/redstonetools/features/arguments/serializers/StringBrigadierSerializer.java @@ -4,7 +4,7 @@ import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.exceptions.CommandSyntaxException; -public abstract class StringBrigadierSerializer extends BrigadierSerializer { +public abstract class StringBrigadierSerializer extends BrigadierArgumentType { public StringBrigadierSerializer(Class clazz, ArgumentType argumentType) { super(clazz, argumentType); diff --git a/src/main/java/tools/redstone/redstonetools/features/commands/BaseConvertFeature.java b/src/main/java/tools/redstone/redstonetools/features/commands/BaseConvertFeature.java index 818d4203..bf9a2c5c 100644 --- a/src/main/java/tools/redstone/redstonetools/features/commands/BaseConvertFeature.java +++ b/src/main/java/tools/redstone/redstonetools/features/commands/BaseConvertFeature.java @@ -9,7 +9,7 @@ import tools.redstone.redstonetools.utils.NumberArg; -import static tools.redstone.redstonetools.features.arguments.serializers.NumberBaseSerializer.numberBase; +import static tools.redstone.redstonetools.features.arguments.serializers.NumberBaseArgumentType.numberBase; import static tools.redstone.redstonetools.features.arguments.serializers.NumberSerializer.numberArg; @AutoService(AbstractFeature.class) diff --git a/src/main/java/tools/redstone/redstonetools/features/commands/BinaryBlockReadFeature.java b/src/main/java/tools/redstone/redstonetools/features/commands/BinaryBlockReadFeature.java index fdcd7b60..1ea3ff15 100644 --- a/src/main/java/tools/redstone/redstonetools/features/commands/BinaryBlockReadFeature.java +++ b/src/main/java/tools/redstone/redstonetools/features/commands/BinaryBlockReadFeature.java @@ -7,24 +7,19 @@ import tools.redstone.redstonetools.features.feedback.Feedback; import tools.redstone.redstonetools.utils.WorldEditUtils; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import com.mojang.datafixers.util.Either; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.regions.CuboidRegion; -import com.sk89q.worldedit.regions.Region; -import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.RedstoneLampBlock; import net.minecraft.command.argument.BlockStateArgument; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.state.property.Property; import net.minecraft.util.math.BlockPos; import java.util.Collections; -import static tools.redstone.redstonetools.features.arguments.serializers.BlockStateArgumentSerializer.blockState; +import static tools.redstone.redstonetools.features.arguments.serializers.BlockStateArgumentType.blockState; import static tools.redstone.redstonetools.features.arguments.serializers.BoolSerializer.bool; import static tools.redstone.redstonetools.features.arguments.serializers.IntegerSerializer.integer; -import static tools.redstone.redstonetools.features.arguments.serializers.NumberBaseSerializer.numberBase; +import static tools.redstone.redstonetools.features.arguments.serializers.NumberBaseArgumentType.numberBase; @AutoService(AbstractFeature.class) diff --git a/src/main/java/tools/redstone/redstonetools/utils/ReflectionUtils.java b/src/main/java/tools/redstone/redstonetools/utils/ReflectionUtils.java index 8c0d2f35..076916c7 100644 --- a/src/main/java/tools/redstone/redstonetools/utils/ReflectionUtils.java +++ b/src/main/java/tools/redstone/redstonetools/utils/ReflectionUtils.java @@ -25,7 +25,7 @@ import tools.redstone.redstonetools.features.AbstractFeature; import tools.redstone.redstonetools.features.Feature; import tools.redstone.redstonetools.features.arguments.Argument; -import tools.redstone.redstonetools.features.arguments.serializers.TypeSerializer; +import tools.redstone.redstonetools.features.arguments.serializers.GenericArgumentType; public class ReflectionUtils { private static final Logger LOGGER = LogManager.getLogger(); @@ -78,8 +78,8 @@ public static DoctorModule[] getModules() { return modules; } - public static Set> getAllArguments() { - return REFLECTIONS.getSubTypesOf(TypeSerializer.class); + public static Set> getAllArguments() { + return REFLECTIONS.getSubTypesOf(GenericArgumentType.class); } public static Set getFeatures() {