diff --git a/common/src/main/java/net/william278/uniform/BaseCommand.java b/common/src/main/java/net/william278/uniform/BaseCommand.java index 1129b4d..e98dbd6 100644 --- a/common/src/main/java/net/william278/uniform/BaseCommand.java +++ b/common/src/main/java/net/william278/uniform/BaseCommand.java @@ -45,7 +45,7 @@ public abstract class BaseCommand { private final String[] aliases; public BaseCommand(@NotNull Command command) { - this.name = command.getNamespace(); + this.name = command.getName(); this.aliases = command.getAliases().toArray(new String[0]); command.provide(this); } diff --git a/common/src/main/java/net/william278/uniform/Command.java b/common/src/main/java/net/william278/uniform/Command.java index f6bfcea..0b016dc 100644 --- a/common/src/main/java/net/william278/uniform/Command.java +++ b/common/src/main/java/net/william278/uniform/Command.java @@ -28,10 +28,12 @@ import java.util.List; public interface Command { @NotNull - String getNamespace(); + String getName(); @NotNull - List getAliases(); + default List getAliases() { + return List.of(); + } void provide(@NotNull BaseCommand command); diff --git a/common/src/main/java/net/william278/uniform/CommandUser.java b/common/src/main/java/net/william278/uniform/CommandUser.java index 529c9f3..3c4f676 100644 --- a/common/src/main/java/net/william278/uniform/CommandUser.java +++ b/common/src/main/java/net/william278/uniform/CommandUser.java @@ -22,15 +22,20 @@ package net.william278.uniform; import net.kyori.adventure.audience.Audience; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.UUID; public interface CommandUser { + @NotNull Audience getAudience(); + @Nullable String getName(); + @Nullable UUID getUniqueId(); } diff --git a/example-plugin/src/main/java/net/william278/uniform/ExampleCrossPlatCommand.java b/example-plugin/src/main/java/net/william278/uniform/ExampleCrossPlatCommand.java index 828331d..477f819 100644 --- a/example-plugin/src/main/java/net/william278/uniform/ExampleCrossPlatCommand.java +++ b/example-plugin/src/main/java/net/william278/uniform/ExampleCrossPlatCommand.java @@ -25,20 +25,12 @@ import net.kyori.adventure.audience.Audience; import net.kyori.adventure.text.Component; import org.jetbrains.annotations.NotNull; -import java.util.List; - public class ExampleCrossPlatCommand implements Command { @Override @NotNull - public String getNamespace() { - return "example"; - } - - @Override - @NotNull - public List getAliases() { - return List.of("cross-plat"); + public String getName() { + return "example-crossplat"; } @Override diff --git a/fabric-1.20.1/src/main/java/net/william278/uniform/fabric/FabricCommandUser.java b/fabric-1.20.1/src/main/java/net/william278/uniform/fabric/FabricCommandUser.java index 52a820f..05cf065 100644 --- a/fabric-1.20.1/src/main/java/net/william278/uniform/fabric/FabricCommandUser.java +++ b/fabric-1.20.1/src/main/java/net/william278/uniform/fabric/FabricCommandUser.java @@ -32,7 +32,7 @@ import java.util.UUID; public record FabricCommandUser(@NotNull ServerCommandSource source) implements CommandUser { @Override - public Audience getAudience() { + public @NotNull Audience getAudience() { return (Audience) source.getPlayer(); } diff --git a/fabric-1.20.6/src/main/java/net/william278/uniform/fabric/FabricCommandUser.java b/fabric-1.20.6/src/main/java/net/william278/uniform/fabric/FabricCommandUser.java index 52a820f..05cf065 100644 --- a/fabric-1.20.6/src/main/java/net/william278/uniform/fabric/FabricCommandUser.java +++ b/fabric-1.20.6/src/main/java/net/william278/uniform/fabric/FabricCommandUser.java @@ -32,7 +32,7 @@ import java.util.UUID; public record FabricCommandUser(@NotNull ServerCommandSource source) implements CommandUser { @Override - public Audience getAudience() { + public @NotNull Audience getAudience() { return (Audience) source.getPlayer(); } diff --git a/paper/src/main/java/net/william278/uniform/paper/PaperCommandUser.java b/paper/src/main/java/net/william278/uniform/paper/PaperCommandUser.java index 3f4f3ab..9cea7ce 100644 --- a/paper/src/main/java/net/william278/uniform/paper/PaperCommandUser.java +++ b/paper/src/main/java/net/william278/uniform/paper/PaperCommandUser.java @@ -33,7 +33,7 @@ public record PaperCommandUser(@NotNull BukkitBrigadierCommandSource source) imp @Override - public Audience getAudience() { + public @NotNull Audience getAudience() { return source.getBukkitSender(); } diff --git a/paper/src/main/java/net/william278/uniform/paper/PaperUniform.java b/paper/src/main/java/net/william278/uniform/paper/PaperUniform.java index 8b7cfbe..d5fe45e 100644 --- a/paper/src/main/java/net/william278/uniform/paper/PaperUniform.java +++ b/paper/src/main/java/net/william278/uniform/paper/PaperUniform.java @@ -54,8 +54,8 @@ public final class PaperUniform implements Listener { private void onCommandRegistered(@NotNull CommandRegisteredEvent event) { for (PaperCommand command : commands) { event.getRoot().addChild(command.build()); - commands.remove(command); } + commands.clear(); } /** 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 52f9385..f6d385f 100644 --- a/velocity/src/main/java/net/william278/uniform/velocity/VelocityCommandUser.java +++ b/velocity/src/main/java/net/william278/uniform/velocity/VelocityCommandUser.java @@ -25,6 +25,7 @@ import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.proxy.Player; import net.kyori.adventure.audience.Audience; import net.william278.uniform.CommandUser; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.UUID; @@ -32,7 +33,7 @@ import java.util.UUID; public record VelocityCommandUser(CommandSource source) implements CommandUser { @Override - public Audience getAudience() { + public @NotNull Audience getAudience() { return source; }