☄️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

private 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

public 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

public CommandBuilder setCooldown(int cooldown)

Sets the cooldown (in seconds) for the command.

setPermission

public CommandBuilder setPermission(String permission)

Sets the permission required to execute the command.

setArguments

public CommandBuilder setArguments(String... argumentNames)

Sets the names of the arguments expected by the command.

setArgumentMapper

public CommandBuilder setArgumentMapper(Function<String[], String> argumentMapper)

Sets the function to map command arguments to a result message.

setCommandFunction

public CommandBuilder setCommandFunction(Function<CommandSender, Void> commandFunction)

Sets the function to execute when the command is executed.

setMessages

public CommandBuilder setMessages(String... messages)

Sets the messages to be sent in response to various command conditions.

addAliases

public CommandBuilder addAliases(String... aliases)

Adds aliases for the command.

build

public void build()

Builds and registers the command with the Bukkit server.

Notes

  • The CommandBuilder class 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