Class SubCommand
java.lang.Object
io.github.projectunified.minelib.util.subcommand.SubCommand
A sub-command
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSubCommand(@NotNull String name) Create new sub-commandprotectedSubCommand(@NotNull String name, @NotNull String description, @NotNull String usage, @Nullable String permission, boolean consoleAllowed) Create new sub-command -
Method Summary
Modifier and TypeMethodDescriptionfinal @NotNull StringGet the descriptionfinal @NotNull StringgetName()Get the name of the sub-commandfinal @Nullable StringGet the permissionfinal @NotNull StringgetUsage()Get the usagefinal booleanCheck if the console is allowed to usefinal booleanisExecutable(@NotNull org.bukkit.command.CommandSender sender, boolean sendMessageIfFalse) Check the command is executable for the senderbooleanisProperUsage(@NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String... args) Check if the sender properly calls the sub-commandfinal booleanonCommand(@NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String... args) Execute the sub-commandabstract voidonSubCommand(@NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String... args) Called when executing the sub-commandonTabComplete(@NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String... args) Get the suggested strings when the sender use TAB key to complete the sub-commandfinal voidsetConsoleAllowed(boolean consoleAllowed) Set if the console is allowed to usefinal voidsetDescription(@NotNull String description) Set the descriptionfinal voidsetPermission(@NotNull org.bukkit.permissions.Permission permission) Set the permissionfinal voidsetPermission(@Nullable String permission) Set the permissionfinal voidSet the usage
-
Field Details
-
name
-
consoleAllowed
protected boolean consoleAllowed -
permission
-
usage
-
description
-
usageSender
-
playerOnlyMessageSender
-
noPermissionMessageSender
-
-
Constructor Details
-
SubCommand
Create new sub-command- Parameters:
name- the name
-
SubCommand
protected SubCommand(@NotNull @NotNull String name, @NotNull @NotNull String description, @NotNull @NotNull String usage, @Nullable @Nullable String permission, boolean consoleAllowed) Create new sub-command- Parameters:
name- the namedescription- the descriptionusage- the usagepermission- the permissionconsoleAllowed- is console allowed to use?
-
-
Method Details
-
isExecutable
public final boolean isExecutable(@NotNull @NotNull org.bukkit.command.CommandSender sender, boolean sendMessageIfFalse) Check the command is executable for the sender- Parameters:
sender- the sendersendMessageIfFalse- true if the message should be sent if the command is not executable- Returns:
- true if the command is executable
-
onCommand
public final boolean onCommand(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String... args) Execute the sub-command- Parameters:
sender- the senderlabel- the label of the parent commandargs- the arguments- Returns:
- whether the command runs successfully
-
getDescription
Get the description- Returns:
- the description
-
setDescription
Set the description- Parameters:
description- the description
-
getUsage
Get the usage- Returns:
- the usage
-
setUsage
Set the usage- Parameters:
usage- the usage
-
getPermission
Get the permission- Returns:
- the permission
-
setPermission
Set the permission- Parameters:
permission- the permission
-
setPermission
public final void setPermission(@NotNull @NotNull org.bukkit.permissions.Permission permission) Set the permission- Parameters:
permission- the permission
-
isConsoleAllowed
public final boolean isConsoleAllowed()Check if the console is allowed to use- Returns:
- true if it is
-
setConsoleAllowed
public final void setConsoleAllowed(boolean consoleAllowed) Set if the console is allowed to use- Parameters:
consoleAllowed- true if it is
-
getName
Get the name of the sub-command- Returns:
- the name
-
onSubCommand
public abstract void onSubCommand(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String... args) Called when executing the sub-command- Parameters:
sender- the senderlabel- the label of the parent commandargs- the arguments
-
isProperUsage
public boolean isProperUsage(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String... args) Check if the sender properly calls the sub-command- Parameters:
sender- the senderlabel- the label of the parent commandargs- the arguments- Returns:
- true if the sender is
-
onTabComplete
@NotNull public @NotNull List<String> onTabComplete(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String... args) Get the suggested strings when the sender use TAB key to complete the sub-command- Parameters:
sender- the senderlabel- the label of the parent commandargs- the arguments- Returns:
- the suggested strings
-