Class SubCommandBuilder
java.lang.Object
me.tayebyassine.homestead.commands.SubCommandBuilder
- Direct Known Subclasses:
AcceptInviteSubCmd, AutoSubCmd, BalanceSubCmd, BanlistSubCmd, BanPlayerSubCmd, BordersSubCmd, ChatSubCmd, CheckUpdatesSubCmd, ClaimlistSubCmd, ClaimSubCmd, CreateRegionSubCmd, DeleteRegionSubCmd, DenyInviteSubCmd, DepositBankSubCmd, ExportSubCmd, FlagsSubCmd, FlySubCmd, HelpSubCmd, HomeSubCmd, ImportSubCmd, KickPlayerSubCmd, LeaveRegionSubCmd, LevelsSubCmd, LogsSubCmd, MailSubCmd, MembersSubCmd, MenuSubCmd, MergeAcceptRegionSubCmd, MergeRegionSubCmd, OverrideFlagSubCmd, PlayerInfoSubCmd, PluginSubCmd, ProtectionModeSubCmd, RateRegionSubCmd, RegionInfoSubCmd, ReloadSubCmd, RenameRegionSubCmd, RentSubCmd, RewardsSubCmd, SetDescriptionSubCmd, SetDisplayNameSubCmd, SetMapColorSubCmd, SetMapIconSubCmd, SetMemberTaxSubCmd, SetRegionSubCmd, SetSpawnSubCmd, SetTimeSubCmd, SetWeatherSubCmd, StorageSubCmd, SubAreasSubCmd, TopRegionsSubCmd, TransferOwnershipSubCmd, TrustPlayerSubCmd, UnbanPlayerSubCmd, UnclaimSubCmd, UntrustPlayerSubCmd, VisitRegionSubCmd, WarSubCmd, WithdrawBankSubCmd
Base class for every sub-command registered on a
CommandBuilder.
Sub-commands are looked up by name or alias (case-insensitive). A sub-command may declare its own permissions, execution context (player only / console only) and usage string.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSubCommandBuilder(String name) Creates a sub-command without aliases.SubCommandBuilder(String name, String... aliases) Creates a sub-command with the given aliases. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.bukkit.entity.PlayerasPlayer(org.bukkit.command.CommandSender sender) Casts the sender to aPlayerwhen possible.String[]Gets a human-readable description of allowed executors.getName()getUsage()booleanhasPermission(org.bukkit.command.CommandSender sender) Checks whether the sender holds every required permission.booleanisAllowedCommandSender(org.bukkit.command.CommandSender sender) Checks if the given sender is allowed to execute this sub-command.booleanbooleanbooleanChecks whether this sub-command matches the given input (name or alias).abstract booleanonExecution(org.bukkit.command.CommandSender sender, String[] args) Executes this sub-command.onTabComplete(org.bukkit.command.CommandSender sender, String[] args) Provides tab-completion suggestions for this sub-command.protected SubCommandBuildersetAdminPermission(String... extraPermissions) Convenience helper that builds the standard admin permission set:homestead.commands.homesteadadminandhomestead.commands.homesteadadmin.<name>, followed by any extra permissions.setAllowedCommandSenders(CommandSenderType... types) Sets the allowed executor types for this sub-command.Restricts this sub-command to the console only.setPermission(String permission) Replaces the permission list with a single permission.setPermission(List<String> permissions) Replaces the permission list.Restricts this sub-command to players only.setPlayerOnly(boolean playerOnly) Sets whether this sub-command is restricted to players.protected SubCommandBuildersetRegionPermission(String... extraPermissions) Convenience helper that builds the standardregionpermission set:homestead.commands.regionandhomestead.commands.region.<name>, followed by any extra permissions.Sets the usage string shown to the player.
-
Field Details
-
plugin
-
-
Constructor Details
-
SubCommandBuilder
Creates a sub-command without aliases.- Parameters:
name- the sub-command name
-
SubCommandBuilder
-
-
Method Details
-
onExecution
Executes this sub-command.- Parameters:
sender- the command senderargs- the arguments following the sub-command name- Returns:
trueto signal that the command was handled
-
onTabComplete
-
setPermission
Replaces the permission list with a single permission.- Parameters:
permission- the required permission- Returns:
- this sub-command, for chaining
-
setPermission
Replaces the permission list. All permissions must be held by the sender.- Parameters:
permissions- the required permissions- Returns:
- this sub-command, for chaining
-
setRegionPermission
Convenience helper that builds the standardregionpermission set:homestead.commands.regionandhomestead.commands.region.<name>, followed by any extra permissions.- Parameters:
extraPermissions- additional permissions, may be empty- Returns:
- this sub-command, for chaining
-
setAdminPermission
Convenience helper that builds the standard admin permission set:homestead.commands.homesteadadminandhomestead.commands.homesteadadmin.<name>, followed by any extra permissions.- Parameters:
extraPermissions- additional permissions, may be empty- Returns:
- this sub-command, for chaining
-
setAllowedCommandSenders
Sets the allowed executor types for this sub-command.- Parameters:
types- the allowed executor types- Returns:
- this sub-command, for chaining
-
setPlayerOnly
Restricts this sub-command to players only.- Returns:
- this sub-command, for chaining
-
setConsoleOnly
Restricts this sub-command to the console only.- Returns:
- this sub-command, for chaining
-
hasPermission
public boolean hasPermission(org.bukkit.command.CommandSender sender) Checks whether the sender holds every required permission.- Parameters:
sender- the command sender- Returns:
trueif no permissions are required or the sender holds all of them
-
matches
Checks whether this sub-command matches the given input (name or alias).- Parameters:
input- the raw input- Returns:
trueif the input matches the name or any alias
-
getName
- Returns:
- the sub-command name
-
getAliases
- Returns:
- the sub-command aliases
-
getUsage
- Returns:
- the sub-command usage string
-
setUsage
Sets the usage string shown to the player.- Parameters:
usage- the usage string- Returns:
- this sub-command, for chaining
-
getPermissions
-
isPlayerOnly
public boolean isPlayerOnly()- Returns:
trueif this sub-command is restricted to players only
-
setPlayerOnly
Sets whether this sub-command is restricted to players.- Parameters:
playerOnly-trueto restrict to players- Returns:
- this sub-command, for chaining
-
isConsoleOnly
public boolean isConsoleOnly()- Returns:
trueif this sub-command is restricted to the console only
-
isAllowedCommandSender
public boolean isAllowedCommandSender(org.bukkit.command.CommandSender sender) Checks if the given sender is allowed to execute this sub-command.- Parameters:
sender- the command sender- Returns:
trueif the sender type is allowed
-
getAllowedCommandSenderDescription
Gets a human-readable description of allowed executors.- Returns:
- description string
-
getallowedCommandSenders
- Returns:
- an unmodifiable view of the allowed executor types
-
asPlayer
protected org.bukkit.entity.Player asPlayer(org.bukkit.command.CommandSender sender) Casts the sender to aPlayerwhen possible.- Parameters:
sender- the command sender- Returns:
- the player, or
nullif the sender is not a player
-