Class 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 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()
      OPTIONAL The command's arguments will be tested against this predicate
      @NotNull java.lang.String getName()
      OPTIONAL This is the name of the command
      @Nullable java.lang.String getPermission()
      OPTIONAL This is the permission required to use the command
      boolean isPlayerOnly()
      OPTIONAL Whether the command is player-only (no console), default: false
      boolean onCommand​(@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 void onCommand​(@NotNull AnnoyingSender sender)
      REQUIRED This is everything that's executed when the command is run
      java.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)
      OPTIONAL This is the tab completion for the command
      void register()
      Registers the command to the Annoyable.getAnnoyingPlugin()
      void unregister()
      Unregisters the command from the Annoyable.getAnnoyingPlugin()
      • Methods inherited from class xyz.srnyx.javautilities.parents.Stringable

        toString, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AnnoyingCommand

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

      • getName

        @NotNull
        public @NotNull java.lang.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 java.lang.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 java.util.function.Predicate<java.lang.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
      • 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 java.util.Collection<java.lang.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 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:
        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 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:
        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