Class CommandInvoker

java.lang.Object
net.winmister332.libs.commands.CommandInvoker
All Implemented Interfaces:
Iterable<Command>

public final class CommandInvoker extends Object implements Iterable<Command>
This is the class which handles the searching and invocation of all WMCommands.
  • Method Details

    • getInstance

      public static CommandInvoker getInstance(boolean parseQuotes, boolean ignoreInnerQuotes)
      Gets an instance of the @see CommandInvoker class.
      Parameters:
      parseQuotes - If true, all arguments surrounded in quotes will be treated as their own argument.
      ignoreInnerQuotes - If true, all inner escaped quotes are hidden and not shown as unescaped quotes.
      Returns:
      The instance of the @see CommandInvoker with the specified settings.
    • getInstance

      public static CommandInvoker getInstance()
      Gets an instance of the @see CommandInvoker class.
      Returns:
      The instance of the @see CommandInvoker with the default settings.
    • register

      public void register(Command command)
      Registeres a command with the invoker. If the command is not registered it will NOT be invoked.
      Parameters:
      command - The command to register.
    • registerAll

      public void registerAll(Command... commands)
      Registeres a collection of Commands one at a time.
      Parameters:
      commands - The collection of commands to register.
    • unregister

      public void unregister(Command c)
      Unregisters a specified command, so it cannot be invoked by the invoker.
      Parameters:
      c - The command to unregister.
    • unregisterAll

      public void unregisterAll(Command... commands)
      Unregisters a collection of commands, so they cannot be invoked by the invoker.
      Parameters:
      commands - The collection of commands to unregister.
    • commandExists

      public boolean commandExists(Command command)
      Checks if a command is registered and is recognised by the invoker.
      Parameters:
      command - The command to check.
      Returns:
      True if the command is found.
    • indexOf

      public int indexOf(Command c)
      Gets the index of a command which was registered to the invoker.
      Parameters:
      c - The command to check.
      Returns:
      The index of the command if found, -1 if not found.
    • getAllCommands

      public Command[] getAllCommands()
      Gets all commands registered with the @see CommandInvoker.
      Returns:
    • getCommands

      public Command[] getCommands()
      Gets only the commands which are visible to the user and are not hidden.
      Returns:
      The visible commands.
    • getCommandByName

      public Command getCommandByName(String name)
      Gets the command with the specified name.
      Parameters:
      name - The name to check;
      Returns:
      The command with the specified name if one is found.
    • getCommandByAlias

      public Command getCommandByAlias(String alias)
      Gets the command with the specified alias.
      Parameters:
      alias - The alias to check.
      Returns:
      The command with the specified name if one is found.
    • getCommand

      public Command getCommand(String value)
      Gets the command with the specified name or alias.
      Parameters:
      value - The name or alias to check.
      Returns:
      The command with the specified name or alias.
    • invoke

      public boolean invoke(String input, org.bukkit.command.CommandSender sender)
      Process and invoke a string as a command.
      Parameters:
      input - The raw input of the command to be processed and invoked.
      sender - The sender of the command. (Forwarded by a Bukkit command.)
      Returns:
      True if the command invoked and completed successfully.
    • invoke

      public boolean invoke(Command command, CommandArgs arguments, String cmdInput, org.bukkit.command.CommandSender sender)
      Process and invoke a string as a command
      Parameters:
      command - The command to invoke.
      arguments - The arguments associated with the command.
      cmdInput - The input label string typed associated with the command (the name or alias).
      sender - The sender forwarded by the Bukkit command.
      Returns:
      True if the command executed successfully.
    • iterator

      @NotNull public @NotNull Iterator<Command> iterator()
      Specified by:
      iterator in interface Iterable<Command>