diff --git a/cloud-bukkit/src/main/java/com/intellectualsites/commands/BukkitCommandManager.java b/cloud-bukkit/src/main/java/com/intellectualsites/commands/BukkitCommandManager.java index f88dad9a..7bde8cb3 100644 --- a/cloud-bukkit/src/main/java/com/intellectualsites/commands/BukkitCommandManager.java +++ b/cloud-bukkit/src/main/java/com/intellectualsites/commands/BukkitCommandManager.java @@ -63,4 +63,10 @@ public class BukkitCommandManager extends CommandManager commandSyntaxFormatter = new StandardCommandSyntaxFormatter<>(); - public CommandManager(@Nonnull final Function, CommandExecutionCoordinator> commandExecutionCoordinator, - @Nonnull final CommandRegistrationHandler commandRegistrationHandler) { + public CommandManager( + @Nonnull final Function, CommandExecutionCoordinator> commandExecutionCoordinator, + @Nonnull final CommandRegistrationHandler commandRegistrationHandler) { this.commandTree = CommandTree.newTree(this, commandRegistrationHandler); this.commandExecutionCoordinator = commandExecutionCoordinator.apply(commandTree); this.commandRegistrationHandler = commandRegistrationHandler; @@ -73,7 +74,8 @@ public abstract class CommandManager executeCommand(@Nonnull final C commandSender, @Nonnull final String input) { - return this.commandExecutionCoordinator.coordinateExecution(this.commandContextFactory.create(commandSender), tokenize(input)); + return this.commandExecutionCoordinator.coordinateExecution(this.commandContextFactory.create(commandSender), + tokenize(input)); } /** @@ -135,7 +137,7 @@ public abstract class CommandManager getCommandRegistrationHandler() { return this.commandRegistrationHandler; } @@ -151,14 +153,38 @@ public abstract class CommandManager commandBuilder(@Nonnull final String name) { + return Command.newBuilder(name, this.createDefaultCommandMeta()); + } + + /** * Get the internal command tree. This should not be accessed unless you know what you * are doing * * @return Command tree */ - @Nonnull CommandTree getCommandTree() { + @Nonnull + CommandTree getCommandTree() { return this.commandTree; } + /** + * Construct a default command meta instance + * + * @return Default command meta + * @throws UnsupportedOperationException If the command manager does not support this operation + */ + @Nonnull + public abstract M createDefaultCommandMeta(); + } diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/meta/CommandMeta.java b/cloud-core/src/main/java/com/intellectualsites/commands/meta/CommandMeta.java index b7ef4b77..6ee9175f 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/meta/CommandMeta.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/meta/CommandMeta.java @@ -25,9 +25,16 @@ package com.intellectualsites.commands.meta; import javax.annotation.Nonnull; +/** + * Object that is associated with a {@link com.intellectualsites.commands.Command}. + * Command meta should not be mutable, as one fixed instance will be used per command. + *

+ * Appropriate use for command meta would be fixed state, such as command descriptions. + */ public class CommandMeta { - @Nonnull public static SimpleCommandMeta.Builder simple() { + @Nonnull + public static SimpleCommandMeta.Builder simple() { return SimpleCommandMeta.builder(); } diff --git a/cloud-core/src/main/java/com/intellectualsites/commands/meta/SimpleCommandMeta.java b/cloud-core/src/main/java/com/intellectualsites/commands/meta/SimpleCommandMeta.java index 0eac867e..9e44d9d2 100644 --- a/cloud-core/src/main/java/com/intellectualsites/commands/meta/SimpleCommandMeta.java +++ b/cloud-core/src/main/java/com/intellectualsites/commands/meta/SimpleCommandMeta.java @@ -60,7 +60,6 @@ public class SimpleCommandMeta extends CommandMeta { return SimpleCommandMeta.builder().build(); } - /** * Get the value associated with a key * diff --git a/cloud-jline/src/main/java/com/intellectualsites/commands/jline/JLineCommandManager.java b/cloud-jline/src/main/java/com/intellectualsites/commands/jline/JLineCommandManager.java index 0ea6579b..85711f6f 100644 --- a/cloud-jline/src/main/java/com/intellectualsites/commands/jline/JLineCommandManager.java +++ b/cloud-jline/src/main/java/com/intellectualsites/commands/jline/JLineCommandManager.java @@ -138,4 +138,10 @@ public class JLineCommandManager extends CommandManager