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
public abstract class AnnoyingCommand extends Registrable implements org.bukkit.command.TabExecutor
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 Constructor Description AnnoyingCommand()Constructs a new command instance for registration
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description @NotNull java.util.function.Predicate<java.lang.String[]>getArgsPredicate()OPTIONALThe command's arguments will be tested against this predicate@NotNull java.lang.StringgetName()OPTIONALThis is the name of the command@Nullable java.lang.StringgetPermission()OPTIONALThis is the permission required to use the commandbooleanisPlayerOnly()OPTIONALWhether the command is player-only (no console), default:falsebooleanonCommand(@NotNull org.bukkit.command.CommandSender cmdSender, @NotNull org.bukkit.command.Command cmd, @NotNull java.lang.String label, @NotNull java.lang.String[] args)Executes the given command, returning its success.abstract voidonCommand(@NotNull AnnoyingSender sender)REQUIREDThis is everything that's executed when the command is runjava.util.List<java.lang.String>onTabComplete(@NotNull org.bukkit.command.CommandSender cmdSender, @NotNull org.bukkit.command.Command cmd, @NotNull java.lang.String label, @NotNull java.lang.String[] args)Requests a list of possible completions for a command argument.@Nullable java.util.Collection<java.lang.String>onTabComplete(@NotNull AnnoyingSender sender)OPTIONALThis is the tab completion for the commandvoidregister()Registers the command to theAnnoyable.getAnnoyingPlugin()voidunregister()Unregisters the command from theAnnoyable.getAnnoyingPlugin()-
Methods inherited from class xyz.srnyx.annoyingapi.parents.Registrable
isRegistered, setRegistered
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface xyz.srnyx.annoyingapi.parents.Annoyable
getAnnoyingPlugin
-
-
-
-
Method Detail
-
getName
@NotNull public @NotNull java.lang.String 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
@Nullable public @Nullable java.lang.String 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
@NotNull public @NotNull java.util.function.Predicate<java.lang.String[]> 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
public abstract void onCommand(@NotNull @NotNull AnnoyingSender sender)REQUIREDThis is everything that's executed when the command is run- Parameters:
sender- the sender of the command
-
onTabComplete
@Nullable public @Nullable java.util.Collection<java.lang.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 java.lang.String label, @NotNull @NotNull java.lang.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 java.util.List<java.lang.String> onTabComplete(@NotNull @NotNull org.bukkit.command.CommandSender cmdSender, @NotNull @NotNull org.bukkit.command.Command cmd, @NotNull @NotNull java.lang.String label, @NotNull @NotNull java.lang.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
-
-