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
  • Constructor Details

    • AnnoyingCommand

      public AnnoyingCommand()
      Constructs a new command instance for registration
  • Method Details

    • getName

      @NotNull public @NotNull String getName()
      OPTIONAL This is the name of the command

      If not specified, the lowercase class name will be used (Command will be removed)

      Example: the command class MyEpicCommand would be registered as myepic

      Returns:
      the name of the command
    • getPermission

      @Nullable public @Nullable String getPermission()
      OPTIONAL This is the permission required to use the command

      If not specified (or null), no permission will be required

      Returns:
      the permission required to use the command
    • isPlayerOnly

      public boolean isPlayerOnly()
      OPTIONAL Whether the command is player-only (no console), default: false
      Returns:
      whether the command is player-only
    • getArgsPredicate

      @NotNull public @NotNull Predicate<String[]> getArgsPredicate()
      OPTIONAL The command's arguments will be tested against this predicate

      This 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 the Annoyable.getAnnoyingPlugin()
      Overrides:
      register in class Registrable
    • unregister

      public void unregister()
      Unregisters the command from the Annoyable.getAnnoyingPlugin()
      Overrides:
      unregister in class Registrable
    • onCommand

      public abstract void onCommand(@NotNull @NotNull AnnoyingSender sender)
      REQUIRED This 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)
      OPTIONAL This is the tab completion for the command

      BukkitUtility will come in handy

      Parameters:
      sender - the sender of the command
      Returns:
      a Collection of 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:
      onCommand in interface org.bukkit.command.CommandExecutor
      Parameters:
      cmdSender - Source of the command
      cmd - Command which was executed
      label - Alias of the command which was used
      args - 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:
      onTabComplete in interface org.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 executed
      label - Alias of the command which was used
      args - 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