java.lang.Object
io.github.projectunified.minelib.util.subcommand.SubCommand

public abstract class SubCommand extends Object
A sub-command
  • Field Details

    • name

      protected final String name
    • consoleAllowed

      protected boolean consoleAllowed
    • permission

      protected String permission
    • usage

      protected String usage
    • description

      protected String description
    • usageSender

      protected BiConsumer<String,org.bukkit.command.CommandSender> usageSender
    • playerOnlyMessageSender

      protected Consumer<org.bukkit.command.CommandSender> playerOnlyMessageSender
    • noPermissionMessageSender

      protected Consumer<org.bukkit.command.CommandSender> noPermissionMessageSender
  • Constructor Details

    • SubCommand

      protected SubCommand(@NotNull @NotNull String name)
      Create new sub-command
      Parameters:
      name - the name
    • SubCommand

      protected SubCommand(@NotNull @NotNull String name, @NotNull @NotNull String description, @NotNull @NotNull String usage, @Nullable @Nullable String permission, boolean consoleAllowed)
      Create new sub-command
      Parameters:
      name - the name
      description - the description
      usage - the usage
      permission - the permission
      consoleAllowed - is console allowed to use?
  • Method Details

    • isExecutable

      public final boolean isExecutable(@NotNull @NotNull org.bukkit.command.CommandSender sender, boolean sendMessageIfFalse)
      Check the command is executable for the sender
      Parameters:
      sender - the sender
      sendMessageIfFalse - true if the message should be sent if the command is not executable
      Returns:
      true if the command is executable
    • onCommand

      public final boolean onCommand(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String... args)
      Execute the sub-command
      Parameters:
      sender - the sender
      label - the label of the parent command
      args - the arguments
      Returns:
      whether the command runs successfully
    • getDescription

      @NotNull public final @NotNull String getDescription()
      Get the description
      Returns:
      the description
    • setDescription

      public final void setDescription(@NotNull @NotNull String description)
      Set the description
      Parameters:
      description - the description
    • getUsage

      @NotNull public final @NotNull String getUsage()
      Get the usage
      Returns:
      the usage
    • setUsage

      public final void setUsage(@NotNull @NotNull String usage)
      Set the usage
      Parameters:
      usage - the usage
    • getPermission

      @Nullable public final @Nullable String getPermission()
      Get the permission
      Returns:
      the permission
    • setPermission

      public final void setPermission(@Nullable @Nullable String permission)
      Set the permission
      Parameters:
      permission - the permission
    • setPermission

      public final void setPermission(@NotNull @NotNull org.bukkit.permissions.Permission permission)
      Set the permission
      Parameters:
      permission - the permission
    • isConsoleAllowed

      public final boolean isConsoleAllowed()
      Check if the console is allowed to use
      Returns:
      true if it is
    • setConsoleAllowed

      public final void setConsoleAllowed(boolean consoleAllowed)
      Set if the console is allowed to use
      Parameters:
      consoleAllowed - true if it is
    • getName

      @NotNull public final @NotNull String getName()
      Get the name of the sub-command
      Returns:
      the name
    • onSubCommand

      public abstract void onSubCommand(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String... args)
      Called when executing the sub-command
      Parameters:
      sender - the sender
      label - the label of the parent command
      args - the arguments
    • isProperUsage

      public boolean isProperUsage(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String... args)
      Check if the sender properly calls the sub-command
      Parameters:
      sender - the sender
      label - the label of the parent command
      args - the arguments
      Returns:
      true if the sender is
    • onTabComplete

      @NotNull public @NotNull List<String> onTabComplete(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String... args)
      Get the suggested strings when the sender use TAB key to complete the sub-command
      Parameters:
      sender - the sender
      label - the label of the parent command
      args - the arguments
      Returns:
      the suggested strings