Package me.efekos.simpler.commands
Class CoreCommand
java.lang.Object
org.bukkit.command.Command
me.efekos.simpler.commands.CoreCommand
public abstract class CoreCommand
extends org.bukkit.command.Command
Used for core commands like /friends invite,/friends list,/friends remove etc.
getSubs() will return a list of the SubCommands that belong to this command. Must be annotated with Command to be registered properly.-
Field Summary
Fields inherited from class org.bukkit.command.Command
description, timings, usageMessage -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCoreCommand(@NotNull String name) Creates a new core command instance.protectedCoreCommand(@NotNull String name, @NotNull String description, @NotNull String usageMessage, @NotNull List<String> aliases) Creates a new core command instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanexecute(@NotNull org.bukkit.command.CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) @NotNull String@NotNull StringgetName()Class<? extends SubCommand>Finds aSubCommandby its name usingBaseCommand.getName().@NotNull List<Class<? extends SubCommand>>getSubs()Returns a list of theSubCommands that belong to thisCoreCommand.@NotNull StringgetUsage()Gets an example usage of this commandbooleanReturns whether this command has a permission.booleanGrabs the value ofCommand.playerOnly()and returns it.abstract voidrenderHelpList(org.bukkit.command.CommandSender sender, List<SubCommand> subInstances) Provides a text that will help theCommandSendertrying to execute one of theSubCommands at this command.voidsetSubList(List<Class<? extends SubCommand>> subList) tabComplete(@NotNull org.bukkit.command.CommandSender sender, @NotNull String alias, @NotNull String[] args) tabComplete(@NotNull org.bukkit.command.CommandSender sender, @NotNull String alias, @NotNull String[] args, org.bukkit.Location location) 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
-
CoreCommand
Creates a new core command instance. Not really needed for usage, but you have to override this constructor in your class.- Parameters:
name- Name of the command, not important in this case though.
-
CoreCommand
protected CoreCommand(@NotNull @NotNull String name, @NotNull @NotNull String description, @NotNull @NotNull String usageMessage, @NotNull @NotNull List<String> aliases) Creates a new core command instance. Not really needed for usage, but you have to override this constructor in your class.- Parameters:
name- Name of the command, not important in this case though.description- Description.usageMessage- Usage message.aliases- Alias list.
-
-
Method Details
-
getName
- Overrides:
getNamein classorg.bukkit.command.Command- Returns:
- Command name as string.
-
getPermission
- 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.
-
getDescription
- Overrides:
getDescriptionin classorg.bukkit.command.Command- Returns:
- A brief description of this command
-
getUsage
Gets an example usage of this command- Overrides:
getUsagein classorg.bukkit.command.Command- Returns:
- One or more example usages
-
setSubList
-
getSubs
Returns a list of theSubCommands that belong to thisCoreCommand.- Returns:
- List of the subs.
-
getSub
Finds aSubCommandby its name usingBaseCommand.getName().- Parameters:
name- Name of theSubCommandyou want to get.- Returns:
SubCommandif found, null otherwise.
-
isPlayerOnly
public boolean isPlayerOnly()Grabs the value ofCommand.playerOnly()and returns it.- Returns:
- Is this command or subs of this command can be used by something that is not player?
-
renderHelpList
public abstract void renderHelpList(org.bukkit.command.CommandSender sender, List<SubCommand> subInstances) Provides a text that will help theCommandSendertrying to execute one of theSubCommands at this command.- Parameters:
sender- The sender who is struggling with using any sub of this command.subInstances- Instances of all theSubCommands under thisCoreCommand.
-
execute
public boolean execute(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String commandLabel, @NotNull @NotNull String[] args) - Specified by:
executein classorg.bukkit.command.Command
-
hasPermission
public boolean hasPermission()Returns whether this command has a permission.- Returns:
- Whether this command has a permission.
-
tabComplete
@NotNull public @NotNull List<String> tabComplete(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String alias, @NotNull @NotNull String[] args) throws IllegalArgumentException - Overrides:
tabCompletein classorg.bukkit.command.Command- Throws:
IllegalArgumentException
-
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 - Overrides:
tabCompletein classorg.bukkit.command.Command- Throws:
IllegalArgumentException
-