diff --git a/src/main/java/net/minestom/server/command/builder/Command.java b/src/main/java/net/minestom/server/command/builder/Command.java index 5d65bd63a..1f4218389 100644 --- a/src/main/java/net/minestom/server/command/builder/Command.java +++ b/src/main/java/net/minestom/server/command/builder/Command.java @@ -8,13 +8,16 @@ import net.minestom.server.command.builder.arguments.ArgumentDynamicWord; import net.minestom.server.command.builder.arguments.ArgumentType; import net.minestom.server.command.builder.arguments.minecraft.SuggestionType; import net.minestom.server.command.builder.condition.CommandCondition; +import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.*; +import java.util.function.Consumer; import java.util.function.Supplier; +import java.util.stream.Stream; /** * Represents a command which has suggestion/auto-completion. @@ -42,6 +45,7 @@ public class Command { private final String name; private final String[] aliases; + private final String[] names; private CommandExecutor defaultExecutor; private CommandCondition condition; @@ -59,6 +63,7 @@ public class Command { public Command(@NotNull String name, @Nullable String... aliases) { this.name = name; this.aliases = aliases; + this.names = Stream.concat(Arrays.stream(aliases), Stream.of(name)).toArray(String[]::new); this.subcommands = new ArrayList<>(); this.syntaxes = new ArrayList<>(); @@ -223,8 +228,7 @@ public class Command { * * @return the main command's name */ - @NotNull - public String getName() { + public @NotNull String getName() { return name; } @@ -233,11 +237,21 @@ public class Command { * * @return the command aliases, can be null or empty */ - @Nullable - public String[] getAliases() { + public @Nullable String[] getAliases() { return aliases; } + /** + * Gets all the possible names for this command. + *
+ * Include {@link #getName()} and {@link #getAliases()}.
+ *
+ * @return this command names
+ */
+ public @NotNull String[] getNames() {
+ return names;
+ }
+
/**
* Gets the default {@link CommandExecutor} which is called when there is no argument
* or if no corresponding syntax has been found.
@@ -266,8 +280,7 @@ public class Command {
* @return a collection containing all this command syntaxes
* @see #addSyntax(CommandExecutor, Argument[])
*/
- @NotNull
- public Collection