Package jss.commandapi
Class BaseCommand
- java.lang.Object
-
- jss.commandapi.BaseCommand
-
- All Implemented Interfaces:
org.bukkit.command.CommandExecutor,org.bukkit.command.TabCompleter,org.bukkit.command.TabExecutor
public abstract class BaseCommand extends Object implements org.bukkit.command.TabExecutor
BaseCommand is a flexible constructor for Bukkit commands that allows: 1. Registering subcommands. 2. Executing the main command logic if no subcommand is provided. 3. Tab completion for both subcommands and the main command.- Version:
- 0.0.9-alpha
- Author:
- jonagamerpro1234
-
-
Constructor Summary
Constructors Constructor Description BaseCommand()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BaseCommandaddSubCommand(SubCommand subCommand)Adds a subcommand to this command.BaseCommandaddSubCommand(SubCommand... subCommands)Adds multiple subcommands to this command at once.StringgetName()List<SubCommand>getSubCommands()BaseCommandname(String name)Sets the main command name.booleanonCommand(@NotNull org.bukkit.command.CommandSender sender, @NotNull org.bukkit.command.Command command, @NotNull String label, String @NotNull [] args)Handles command execution with debug, logging, and performance tracking.booleanonCommandMain(@NotNull org.bukkit.command.CommandSender sender, String[] args)Logic executed when no subcommand is provided.List<String>onTabComplete(@NotNull org.bukkit.command.CommandSender sender, @NotNull org.bukkit.command.Command command, @NotNull String alias, String @NotNull [] args)Handles tab completion for the main command and its subcommands.List<String>onTabMain(@NotNull org.bukkit.command.CommandSender sender, String[] args)Tab completion suggestions for the main command.voidregister(@NotNull org.bukkit.plugin.java.JavaPlugin plugin)Registers this command automatically using the provided JavaPlugin.
-
-
-
Method Detail
-
register
public void register(@NotNull @NotNull org.bukkit.plugin.java.JavaPlugin plugin)Registers this command automatically using the provided JavaPlugin.- Parameters:
plugin- the JavaPlugin instance used to register the command- Throws:
IllegalStateException- if the command name has not been set or is empty- Since:
- 0.0.8-alpha
-
name
public BaseCommand name(String name)
Sets the main command name.- Parameters:
name- the name of the main command- Returns:
- this BaseCommand instance for chaining
- Since:
- 0.0.7-alpha
-
addSubCommand
public BaseCommand addSubCommand(SubCommand subCommand)
Adds a subcommand to this command.- Parameters:
subCommand- the subcommand to add- Returns:
- this BaseCommand instance for chaining
- Since:
- 0.0.7-alpha
-
addSubCommand
public BaseCommand addSubCommand(SubCommand... subCommands)
Adds multiple subcommands to this command at once.- Parameters:
subCommands- the subcommands to add- Returns:
- this BaseCommand instance for chaining
- Since:
- 0.0.7-alpha
-
onCommandMain
public boolean onCommandMain(@NotNull @NotNull org.bukkit.command.CommandSender sender, String[] args)Logic executed when no subcommand is provided.- Parameters:
sender- the CommandSender executing the commandargs- the command arguments- Returns:
- true if execution was successful
- Since:
- 0.0.7-alpha
-
onTabMain
public List<String> onTabMain(@NotNull @NotNull org.bukkit.command.CommandSender sender, String[] args)
Tab completion suggestions for the main command.- Parameters:
sender- the CommandSender requesting tab completionargs- the command arguments- Returns:
- a list of suggestions
- Since:
- 0.0.7-alpha
-
onCommand
public boolean onCommand(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull org.bukkit.command.Command command, @NotNull @NotNull String label, String @NotNull [] args)Handles command execution with debug, logging, and performance tracking.- Specified by:
onCommandin interfaceorg.bukkit.command.CommandExecutor- Since:
- 0.0.8-alpha
-
onTabComplete
public List<String> onTabComplete(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull org.bukkit.command.Command command, @NotNull @NotNull String alias, String @NotNull [] args)
Handles tab completion for the main command and its subcommands.- Specified by:
onTabCompletein interfaceorg.bukkit.command.TabCompleter- Since:
- 0.0.7-alpha
-
getSubCommands
public List<SubCommand> getSubCommands()
-
getName
public String getName()
-
-