Class CoreCommand

java.lang.Object
org.bukkit.command.Command
me.efekos.simpler.commands.CoreCommand

public abstract class CoreCommand extends org.bukkit.command.Command
Used for core commands like /friends invite,/friends list,/friends remove etc. getSubs() will return a list of the SubCommands that belong to this command. Must be annotated with Command to be registered properly.
  • Constructor Details

    • CoreCommand

      protected CoreCommand(@NotNull @NotNull String name)
      Creates a new core command instance. Not really needed for usage, but you have to override this constructor in your class.
      Parameters:
      name - Name of the command, not important in this case though.
    • CoreCommand

      protected CoreCommand(@NotNull @NotNull String name, @NotNull @NotNull String description, @NotNull @NotNull String usageMessage, @NotNull @NotNull List<String> aliases)
      Creates a new core command instance. Not really needed for usage, but you have to override this constructor in your class.
      Parameters:
      name - Name of the command, not important in this case though.
      description - Description.
      usageMessage - Usage message.
      aliases - Alias list.
  • Method Details

    • getName

      @NotNull public @NotNull String getName()
      Overrides:
      getName in class org.bukkit.command.Command
      Returns:
      Command name as string.
    • getPermission

      @Nullable public String getPermission()
      Overrides:
      getPermission in class org.bukkit.command.Command
      Returns:
      Permission this command needs to be executed as String, null if this command does not need any permission.
    • getDescription

      @NotNull public @NotNull String getDescription()
      Overrides:
      getDescription in class org.bukkit.command.Command
      Returns:
      A brief description of this command
    • getUsage

      @NotNull public @NotNull String getUsage()
      Gets an example usage of this command
      Overrides:
      getUsage in class org.bukkit.command.Command
      Returns:
      One or more example usages
    • setSubList

      public void setSubList(List<Class<? extends SubCommand>> subList)
    • getSubs

      @NotNull public @NotNull List<Class<? extends SubCommand>> getSubs()
      Returns a list of the SubCommands that belong to this CoreCommand.
      Returns:
      List of the subs.
    • getSub

      @Nullable public Class<? extends SubCommand> getSub(String name)
      Finds a SubCommand by its name using BaseCommand.getName().
      Parameters:
      name - Name of the SubCommand you want to get.
      Returns:
      SubCommand if found, null otherwise.
    • isPlayerOnly

      public boolean isPlayerOnly()
      Grabs the value of Command.playerOnly() and returns it.
      Returns:
      Is this command or subs of this command can be used by something that is not player?
    • renderHelpList

      public abstract void renderHelpList(org.bukkit.command.CommandSender sender, List<SubCommand> subInstances)
      Provides a text that will help the CommandSender trying to execute one of the SubCommands at this command.
      Parameters:
      sender - The sender who is struggling with using any sub of this command.
      subInstances - Instances of all the SubCommands under this CoreCommand.
    • execute

      public boolean execute(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String commandLabel, @NotNull @NotNull String[] args)
      Specified by:
      execute in class org.bukkit.command.Command
    • hasPermission

      public boolean hasPermission()
      Returns whether this command has a permission.
      Returns:
      Whether this command has a permission.
    • tabComplete

      @NotNull public @NotNull List<String> tabComplete(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String alias, @NotNull @NotNull String[] args) throws IllegalArgumentException
      Overrides:
      tabComplete in class org.bukkit.command.Command
      Throws:
      IllegalArgumentException
    • tabComplete

      @NotNull public @NotNull List<String> tabComplete(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String alias, @NotNull @NotNull String[] args, @Nullable org.bukkit.Location location) throws IllegalArgumentException
      Overrides:
      tabComplete in class org.bukkit.command.Command
      Throws:
      IllegalArgumentException