☄️Command Builder
Create commands faster and easier
Overview
The CommandBuilder class simplifies the creation and management of custom commands in a Minecraft Bukkit server environment. It provides methods for setting command properties such as cooldown, permission, aliases, arguments, command function, and messages, allowing for flexible and customizable command behavior.
Constructor
CommandBuilder
CommandBuilderprivate CommandBuilder(JavaPlugin plugin)Initializes a new instance of the CommandBuilder class with the specified JavaPlugin instance.
Parameters
plugin: The JavaPlugin instance associated with the command builder.
Static Factory Method
create
createpublic static CommandBuilder create(JavaPlugin plugin, String commandName)Creates a new CommandBuilder instance with the specified JavaPlugin instance and command name.
Parameters
plugin: The JavaPlugin instance associated with the command builder.commandName: The name of the command to be created.
Methods
setCooldown
setCooldownpublic CommandBuilder setCooldown(int cooldown)Sets the cooldown (in seconds) for the command.
setPermission
setPermissionpublic CommandBuilder setPermission(String permission)Sets the permission required to execute the command.
setArguments
setArgumentspublic CommandBuilder setArguments(String... argumentNames)Sets the names of the arguments expected by the command.
setArgumentMapper
setArgumentMapperpublic CommandBuilder setArgumentMapper(Function<String[], String> argumentMapper)Sets the function to map command arguments to a result message.
setCommandFunction
setCommandFunctionpublic CommandBuilder setCommandFunction(Function<CommandSender, Void> commandFunction)Sets the function to execute when the command is executed.
setMessages
setMessagespublic CommandBuilder setMessages(String... messages)Sets the messages to be sent in response to various command conditions.
addAliases
addAliasespublic CommandBuilder addAliases(String... aliases)Adds aliases for the command.
build
buildpublic void build()Builds and registers the command with the Bukkit server.
Notes
The
CommandBuilderclass allows for the creation of custom commands with configurable properties and behavior.Developers can specify cooldown, permission, arguments, command function, and messages to tailor the command to their specific requirements.
Custom commands created using this builder pattern can enhance server functionality and provide players with additional gameplay features and interactions.
Last updated