Class SimpleCommand<C extends CommandSource<?,?>>

java.lang.Object
one.tranic.t.base.command.simple.SimpleCommand<C>
Type Parameters:
C - the type of the command source, extending from CommandSource
All Implemented Interfaces:
SimpleCommandImpl<C>

public abstract class SimpleCommand<C extends CommandSource<?,?>> extends Object implements SimpleCommandImpl<C>
Abstract base class representing a command in a multi-platform environment.

This class provides methods to manage command properties such as name, description, usage, and permissions, as well as utilities to handle platform-specific command registration and unwrapping.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieves the description of the command.
    Retrieves the name of the command.
    Retrieves the permission required to execute this command.
    Retrieves the usage string for the command.
    boolean
    hasPermission(C source)
    Checks if the given source has the required permissions to execute a command or perform an action.
    void
    sendResult(C source, String msg)
    Sends a message result to a specified source.
    void
    sendResult(C source, String msg, boolean withConsole)
    Sends a result message to the specified source and optionally to the console.
    void
    sendResult(C source, net.kyori.adventure.text.Component msg)
    Sends a result message to a specified source.
    void
    sendResult(C source, net.kyori.adventure.text.Component msg, boolean withConsole)
    Sends a message result to a given source, taking into account whether the source is a Bedrock player, a standard player, or whether the message should also be sent to the console.
    void
    setDescription(String description)
    Sets the description for this command.
    void
    Sets the name of the command, prefixing it with platform-specific identifiers.
    void
    setPermission(String permission)
    Sets the permission for the command with platform-specific modifications.
    void
    Sets the usage description for this command.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface one.tranic.t.base.command.simple.SimpleCommandImpl

    execute, suggest
  • Constructor Details

    • SimpleCommand

      public SimpleCommand()
  • Method Details

    • hasPermission

      public boolean hasPermission(C source)
      Description copied from interface: SimpleCommandImpl
      Checks if the given source has the required permissions to execute a command or perform an action.
      Specified by:
      hasPermission in interface SimpleCommandImpl<C extends CommandSource<?,?>>
      Parameters:
      source - the contextual source for which the permission check is being performed
      Returns:
      true if the source has the appropriate permissions, otherwise false
    • sendResult

      public void sendResult(C source, net.kyori.adventure.text.Component msg)
      Sends a result message to a specified source.
      Parameters:
      source - the command source who will receive the message
      msg - the message to be sent to the source
    • sendResult

      public void sendResult(C source, net.kyori.adventure.text.Component msg, boolean withConsole)
      Sends a message result to a given source, taking into account whether the source is a Bedrock player, a standard player, or whether the message should also be sent to the console.
      Parameters:
      source - the source to which the result should be sent; can be a player or other entity
      msg - the message to be sent, represented as a Component
      withConsole - if true, the message will also be sent to the console
    • sendResult

      public void sendResult(C source, String msg)
      Sends a message result to a specified source.
      Parameters:
      source - the source (e.g., player or console) to which the result will be sent
      msg - the message to be sent to the source
    • sendResult

      public void sendResult(C source, String msg, boolean withConsole)
      Sends a result message to the specified source and optionally to the console.
      Parameters:
      source - the source to which the result is sent; it can represent a player or another entity
      msg - the message to be sent
      withConsole - whether the message should also be sent to the console
    • getName

      public String getName()
      Retrieves the name of the command.
      Returns:
      the name of the command
    • setName

      public void setName(String name)
      Sets the name of the command, prefixing it with platform-specific identifiers.
      Parameters:
      name - the base name to set for this command
    • getDescription

      public String getDescription()
      Retrieves the description of the command.
      Returns:
      the description text for this command
    • setDescription

      public void setDescription(String description)
      Sets the description for this command.
      Parameters:
      description - the description to set for this command
    • getUsage

      public String getUsage()
      Retrieves the usage string for the command.
      Returns:
      the usage string for the command
    • setUsage

      public void setUsage(String usage)
      Sets the usage description for this command.
      Parameters:
      usage - the usage description to set for this command
    • getPermission

      public String getPermission()
      Retrieves the permission required to execute this command.
      Returns:
      the permission string associated with this command
    • setPermission

      public void setPermission(String permission)
      Sets the permission for the command with platform-specific modifications.
      Parameters:
      permission - the base permission string to set for this command