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 SubCommand
s 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
ModifierConstructorDescriptionprotected
CoreCommand
(@NotNull String name) Creates a new core command instance.protected
CoreCommand
(@NotNull String name, @NotNull String description, @NotNull String usageMessage, @NotNull List<String> aliases) Creates a new core command instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
execute
(@NotNull org.bukkit.command.CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) @NotNull String
@NotNull String
getName()
Class<? extends SubCommand>
Finds aSubCommand
by its name usingBaseCommand.getName()
.@NotNull List<Class<? extends SubCommand>>
getSubs()
Returns a list of theSubCommand
s that belong to thisCoreCommand
.@NotNull String
getUsage()
Gets an example usage of this commandboolean
Returns whether this command has a permission.boolean
Grabs the value ofCommand.playerOnly()
and returns it.abstract void
renderHelpList
(org.bukkit.command.CommandSender sender, List<SubCommand> subInstances) Provides a text that will help theCommandSender
trying to execute one of theSubCommand
s at this command.void
setSubList
(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:
getName
in classorg.bukkit.command.Command
- Returns:
- Command name as string.
-
getPermission
- Overrides:
getPermission
in 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:
getDescription
in classorg.bukkit.command.Command
- Returns:
- A brief description of this command
-
getUsage
Gets an example usage of this command- Overrides:
getUsage
in classorg.bukkit.command.Command
- Returns:
- One or more example usages
-
setSubList
-
getSubs
Returns a list of theSubCommand
s that belong to thisCoreCommand
.- Returns:
- List of the subs.
-
getSub
Finds aSubCommand
by its name usingBaseCommand.getName()
.- Parameters:
name
- Name of theSubCommand
you want to get.- Returns:
SubCommand
if 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 theCommandSender
trying to execute one of theSubCommand
s at this command.- Parameters:
sender
- The sender who is struggling with using any sub of this command.subInstances
- Instances of all theSubCommand
s under thisCoreCommand
.
-
execute
public boolean execute(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String commandLabel, @NotNull @NotNull String[] args) - Specified by:
execute
in 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:
tabComplete
in 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:
tabComplete
in classorg.bukkit.command.Command
- Throws:
IllegalArgumentException
-