Package xyz.srnyx.annoyingapi.command
Class AnnoyingCommand
java.lang.Object
xyz.srnyx.javautilities.parents.Stringable
xyz.srnyx.annoyingapi.parents.Registrable
xyz.srnyx.annoyingapi.command.AnnoyingCommand
- All Implemented Interfaces:
org.bukkit.command.CommandExecutor,org.bukkit.command.TabCompleter,org.bukkit.command.TabExecutor,Annoyable
- Direct Known Subclasses:
DisabledCommand
Represents a command that can be executed by a player or the console
-
Nested Class Summary
Nested classes/interfaces inherited from class xyz.srnyx.annoyingapi.parents.Registrable
Registrable.Ignore -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionOPTIONALThe command's arguments will be tested against this predicate@NotNull StringgetName()OPTIONALThis is the name of the command@Nullable StringOPTIONALThis is the permission required to use the commandbooleanOPTIONALWhether the command is player-only (no console), default:falsebooleanonCommand(@NotNull org.bukkit.command.CommandSender cmdSender, @NotNull org.bukkit.command.Command cmd, @NotNull String label, @NotNull String[] args) Executes the given command, returning its success.abstract voidonCommand(@NotNull AnnoyingSender sender) REQUIREDThis is everything that's executed when the command is runonTabComplete(@NotNull org.bukkit.command.CommandSender cmdSender, @NotNull org.bukkit.command.Command cmd, @NotNull String label, @NotNull String[] args) Requests a list of possible completions for a command argument.@Nullable Collection<String> onTabComplete(@NotNull AnnoyingSender sender) OPTIONALThis is the tab completion for the commandvoidregister()Registers the command to theAnnoyable.getAnnoyingPlugin()voidUnregisters the command from theAnnoyable.getAnnoyingPlugin()Methods inherited from class xyz.srnyx.annoyingapi.parents.Registrable
isRegistered, setRegisteredMethods inherited from class xyz.srnyx.javautilities.parents.Stringable
toString, toString, toString, toString, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface xyz.srnyx.annoyingapi.parents.Annoyable
getAnnoyingPlugin
-
Constructor Details
-
AnnoyingCommand
public AnnoyingCommand()Constructs a new command instance for registration
-
-
Method Details
-
getName
OPTIONALThis is the name of the commandIf not specified, the lowercase class name will be used (
Commandwill be removed)Example: the command class
MyEpicCommandwould be registered asmyepic- Returns:
- the name of the command
-
getPermission
OPTIONALThis is the permission required to use the commandIf not specified (or
null), no permission will be required- Returns:
- the permission required to use the command
-
isPlayerOnly
public boolean isPlayerOnly()OPTIONALWhether the command is player-only (no console), default:false- Returns:
- whether the command is player-only
-
getArgsPredicate
OPTIONALThe command's arguments will be tested against this predicateThis is usually used to check if the command has the correct amount of arguments
If not specified, any arguments will be accepted
- Returns:
- the predicate to test the command's arguments against
-
register
public void register()Registers the command to theAnnoyable.getAnnoyingPlugin()- Overrides:
registerin classRegistrable
-
unregister
public void unregister()Unregisters the command from theAnnoyable.getAnnoyingPlugin()- Overrides:
unregisterin classRegistrable
-
onCommand
REQUIREDThis is everything that's executed when the command is run- Parameters:
sender- the sender of the command
-
onTabComplete
@Nullable public @Nullable Collection<String> onTabComplete(@NotNull @NotNull AnnoyingSender sender) OPTIONALThis is the tab completion for the commandBukkitUtilitywill come in handy- Parameters:
sender- the sender of the command- Returns:
- a
Collectionof suggestions
-
onCommand
public boolean onCommand(@NotNull @NotNull org.bukkit.command.CommandSender cmdSender, @NotNull @NotNull org.bukkit.command.Command cmd, @NotNull @NotNull String label, @NotNull @NotNull String[] args) Executes the given command, returning its success.
If false is returned, then the "usage" plugin.yml entry for this command (if defined) will be sent to the player.- Specified by:
onCommandin interfaceorg.bukkit.command.CommandExecutor- Parameters:
cmdSender- Source of the commandcmd- Command which was executedlabel- Alias of the command which was usedargs- Passed command arguments- Returns:
- true if a valid command, otherwise false
-
onTabComplete
public List<String> onTabComplete(@NotNull @NotNull org.bukkit.command.CommandSender cmdSender, @NotNull @NotNull org.bukkit.command.Command cmd, @NotNull @NotNull String label, @NotNull @NotNull String[] args) Requests a list of possible completions for a command argument.- Specified by:
onTabCompletein interfaceorg.bukkit.command.TabCompleter- Parameters:
cmdSender- Source of the command. For players tab-completing a command inside a command block, this will be the player, not the command block.cmd- Command which was executedlabel- Alias of the command which was usedargs- The arguments passed to the command, including final partial argument to be completed- Returns:
- A List of possible completions for the final argument, or null to default to the command executor
-