diff --git a/fabric-1.20.1/src/main/java/net/william278/uniform/fabric/FabricCommand.java b/fabric-1.20.1/src/main/java/net/william278/uniform/fabric/FabricCommand.java index 1111c01..a043651 100644 --- a/fabric-1.20.1/src/main/java/net/william278/uniform/fabric/FabricCommand.java +++ b/fabric-1.20.1/src/main/java/net/william278/uniform/fabric/FabricCommand.java @@ -21,6 +21,7 @@ package net.william278.uniform.fabric; +import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -31,8 +32,10 @@ import net.minecraft.util.Identifier; import net.minecraft.util.InvalidIdentifierException; import net.william278.uniform.BaseCommand; import net.william278.uniform.Command; +import net.william278.uniform.CommandSyntax; import net.william278.uniform.Uniform; import net.william278.uniform.element.ArgumentElement; +import net.william278.uniform.element.CommandElement; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -48,7 +51,8 @@ public class FabricCommand extends BaseCommand { super(name, aliases); } - public FabricCommand(@NotNull String name, @NotNull String description, @NotNull List aliases) { + public FabricCommand(@NotNull String name, @NotNull String description, + @NotNull List aliases) { super(name, description, aliases); } @@ -79,6 +83,28 @@ public class FabricCommand extends BaseCommand { }); } + @Override + @NotNull + @SuppressWarnings("unchecked") + public List> getSyntaxes() { + return super.getSyntaxes().stream().map( + syntax -> new CommandSyntax<>( + syntax.condition(), + syntax.executor(), + syntax.elements().stream() + .filter(e -> e instanceof ArgumentElement) + .map(e -> (ArgumentElement) e) + .map(e -> e.custom() ? new ArgumentElement<>( + e.name(), + StringArgumentType.string(), + e.suggestionProvider() + ) : e) + .map(e -> (CommandElement) e) + .toList() + ) + ).toList(); + } + @Override public void addSubCommand(@NotNull Command command) { addSubCommand(new FabricCommand(command)); @@ -88,5 +114,4 @@ public class FabricCommand extends BaseCommand { public Uniform getUniform() { return FabricUniform.INSTANCE; } - } diff --git a/fabric-1.20.6/src/main/java/net/william278/uniform/fabric/FabricCommand.java b/fabric-1.20.6/src/main/java/net/william278/uniform/fabric/FabricCommand.java index 86982b9..a043651 100644 --- a/fabric-1.20.6/src/main/java/net/william278/uniform/fabric/FabricCommand.java +++ b/fabric-1.20.6/src/main/java/net/william278/uniform/fabric/FabricCommand.java @@ -21,6 +21,7 @@ package net.william278.uniform.fabric; +import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -31,8 +32,10 @@ import net.minecraft.util.Identifier; import net.minecraft.util.InvalidIdentifierException; import net.william278.uniform.BaseCommand; import net.william278.uniform.Command; +import net.william278.uniform.CommandSyntax; import net.william278.uniform.Uniform; import net.william278.uniform.element.ArgumentElement; +import net.william278.uniform.element.CommandElement; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -80,6 +83,28 @@ public class FabricCommand extends BaseCommand { }); } + @Override + @NotNull + @SuppressWarnings("unchecked") + public List> getSyntaxes() { + return super.getSyntaxes().stream().map( + syntax -> new CommandSyntax<>( + syntax.condition(), + syntax.executor(), + syntax.elements().stream() + .filter(e -> e instanceof ArgumentElement) + .map(e -> (ArgumentElement) e) + .map(e -> e.custom() ? new ArgumentElement<>( + e.name(), + StringArgumentType.string(), + e.suggestionProvider() + ) : e) + .map(e -> (CommandElement) e) + .toList() + ) + ).toList(); + } + @Override public void addSubCommand(@NotNull Command command) { addSubCommand(new FabricCommand(command)); diff --git a/velocity/src/main/java/net/william278/uniform/velocity/VelocityCommandUser.java b/velocity/src/main/java/net/william278/uniform/velocity/VelocityCommandUser.java index d997534..defaf59 100644 --- a/velocity/src/main/java/net/william278/uniform/velocity/VelocityCommandUser.java +++ b/velocity/src/main/java/net/william278/uniform/velocity/VelocityCommandUser.java @@ -33,7 +33,8 @@ import java.util.UUID; public record VelocityCommandUser(CommandSource source) implements CommandUser { @Override - public @NotNull Audience getAudience() { + @NotNull + public Audience getAudience() { return source; }