Class SubCommand
java.lang.Object
io.github.projectunified.minelib.util.subcommand.SubCommand
A sub-command
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
SubCommand
(@NotNull String name) Create new sub-commandprotected
SubCommand
(@NotNull String name, @NotNull String description, @NotNull String usage, @Nullable String permission, boolean consoleAllowed) Create new sub-command -
Method Summary
Modifier and TypeMethodDescriptionfinal @NotNull String
Get the descriptionfinal @NotNull String
getName()
Get the name of the sub-commandfinal @Nullable String
Get the permissionfinal @NotNull String
getUsage()
Get the usagefinal boolean
Check if the console is allowed to usefinal boolean
isExecutable
(@NotNull org.bukkit.command.CommandSender sender, boolean sendMessageIfFalse) Check the command is executable for the senderboolean
isProperUsage
(@NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String... args) Check if the sender properly calls the sub-commandfinal boolean
onCommand
(@NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String... args) Execute the sub-commandabstract void
onSubCommand
(@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 void
setConsoleAllowed
(boolean consoleAllowed) Set if the console is allowed to usefinal void
setDescription
(@NotNull String description) Set the descriptionfinal void
setPermission
(@NotNull org.bukkit.permissions.Permission permission) Set the permissionfinal void
setPermission
(@Nullable String permission) Set the permissionfinal void
Set 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
-