Package me.efekos.simpler.commands
Class BaseCommand
java.lang.Object
org.bukkit.command.Command
me.efekos.simpler.commands.BaseCommand
- Direct Known Subclasses:
SubCommand
public abstract class BaseCommand
extends org.bukkit.command.Command
Used for base commands like /feed, /god etc.
Requires
Command to be used in CommandManager-
Field Summary
Fields inherited from class org.bukkit.command.Command
description, timings, usageMessage -
Constructor Summary
ConstructorsConstructorDescriptionBaseCommand(@NotNull String name) Creates an instance of this command.BaseCommand(@NotNull String name, @NotNull String description, @NotNull String usageMessage, @NotNull List<String> aliases) Creates an instance of this command. -
Method Summary
Modifier and TypeMethodDescriptionbooleanexecute(@NotNull org.bukkit.command.CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) Executes the command, returning its success@NotNull StringGrabs the value ofCommand.description()and returns it.@NotNull StringgetName()Grabs the value ofCommand.name()and returns it.Grabs the value ofCommand.permission()and returns it.abstract @NotNull SyntaxUsed for handling tab completion, making examples and providing valid usages for this command.@NotNull StringgetUsage()Gets an example usage of this commandbooleanReturns whether this command has a permission.booleanGrabs the value ofCommand.playerOnly()and returns it.abstract voidonConsoleUse(org.bukkit.command.ConsoleCommandSender sender, String[] args) Fires when the console executes this commandabstract voidonPlayerUse(org.bukkit.entity.Player player, String[] args) Fires when a player executes this command.tabComplete(@NotNull org.bukkit.command.CommandSender sender, @NotNull String alias, @NotNull String[] args) Executed on tab completion for this command, returning a list of options the player can tab through.tabComplete(@NotNull org.bukkit.command.CommandSender sender, @NotNull String alias, @NotNull String[] args, org.bukkit.Location location) Executed on tab completion for this command, returning a list of options the player can tab through.Methods inherited from class org.bukkit.command.Command
broadcastCommandMessage, broadcastCommandMessage, getAliases, getLabel, getPermissionMessage, isRegistered, register, setAliases, setDescription, setLabel, setName, setPermission, setPermissionMessage, setUsage, testPermission, testPermissionSilent, toString, unregister
-
Constructor Details
-
BaseCommand
Creates an instance of this command.- Parameters:
name- Name of the command.
-
BaseCommand
public BaseCommand(@NotNull @NotNull String name, @NotNull @NotNull String description, @NotNull @NotNull String usageMessage, @NotNull @NotNull List<String> aliases) Creates an instance of this command.- Parameters:
name- Name of the command.description- Description of the command.usageMessage- Usage message of the command.aliases- Aliases for the command.
-
-
Method Details
-
getName
Grabs the value ofCommand.name()and returns it.- Overrides:
getNamein classorg.bukkit.command.Command- Returns:
- Command name as a
String.
-
getPermission
Grabs the value ofCommand.permission()and returns it.- Overrides:
getPermissionin classorg.bukkit.command.Command- Returns:
- Permission this command needs to be executed as String, null if this command does not need any permission.
-
hasPermission
public boolean hasPermission()Returns whether this command has a permission.- Returns:
- Whether this command has a permission.
-
getDescription
Grabs the value ofCommand.description()and returns it.- Overrides:
getDescriptionin classorg.bukkit.command.Command- Returns:
- A brief description of this command
-
getSyntax
Used for handling tab completion, making examples and providing valid usages for this command. You can create your own arguments with a class extendsArgument. This is really helpful at making sure your arguments are good.- Returns:
- A Syntax class for this command.
-
getUsage
Gets an example usage of this command- Overrides:
getUsagein classorg.bukkit.command.Command- Returns:
- One or more example usages
-
isPlayerOnly
public boolean isPlayerOnly()Grabs the value ofCommand.playerOnly()and returns it.- Returns:
- Is this command can be used by something that is not player?
-
onPlayerUse
Fires when a player executes this command.- Parameters:
player- Player that sent the command.args- The args given by sender.
-
onConsoleUse
Fires when the console executes this command- Parameters:
sender- The consoleargs- Args given by sender
-
execute
public boolean execute(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String commandLabel, @NotNull @NotNull String[] args) Executes the command, returning its success- Specified by:
executein classorg.bukkit.command.Command- Parameters:
sender- Source object which is executing this commandcommandLabel- The alias of the command usedargs- All arguments passed to the command, split via ' '- Returns:
- true if the command was successful, otherwise false
-
tabComplete
@NotNull public @NotNull List<String> tabComplete(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String alias, @NotNull @NotNull String[] args) throws IllegalArgumentException Executed on tab completion for this command, returning a list of options the player can tab through.- Overrides:
tabCompletein classorg.bukkit.command.Command- Parameters:
sender- Source object which is executing this commandalias- the alias being usedargs- All arguments passed to the command, split via ' '- Returns:
- a list of tab-completions for the specified arguments. This will never be null. List may be immutable.
- Throws:
IllegalArgumentException- if sender, alias, or args is null
-
tabComplete
@NotNull public @NotNull List<String> tabComplete(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String alias, @NotNull @NotNull String[] args, @Nullable org.bukkit.Location location) throws IllegalArgumentException Executed on tab completion for this command, returning a list of options the player can tab through.- Overrides:
tabCompletein classorg.bukkit.command.Command- Parameters:
sender- Source object which is executing this commandalias- the alias being usedargs- All arguments passed to the command, split via ' 'location- The position looked at by the sender, or null if none- Returns:
- a list of tab-completions for the specified arguments. This will never be null. List may be immutable.
- Throws:
IllegalArgumentException- if sender, alias, or args is null
-