Package one.tranic.t.base.command.simple
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 fromCommandSource
- 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 -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the description of the command.getName()Retrieves the name of the command.Retrieves the permission required to execute this command.getUsage()Retrieves the usage string for the command.booleanhasPermission(C source) Checks if the given source has the required permissions to execute a command or perform an action.voidsendResult(C source, String msg) Sends a message result to a specified source.voidsendResult(C source, String msg, boolean withConsole) Sends a result message to the specified source and optionally to the console.voidsendResult(C source, net.kyori.adventure.text.Component msg) Sends a result message to a specified source.voidsendResult(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.voidsetDescription(String description) Sets the description for this command.voidSets the name of the command, prefixing it with platform-specific identifiers.voidsetPermission(String permission) Sets the permission for the command with platform-specific modifications.voidSets the usage description for this command.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface one.tranic.t.base.command.simple.SimpleCommandImpl
execute, suggest
-
Constructor Details
-
SimpleCommand
public SimpleCommand()
-
-
Method Details
-
hasPermission
Description copied from interface:SimpleCommandImplChecks if the given source has the required permissions to execute a command or perform an action.- Specified by:
hasPermissionin interfaceSimpleCommandImpl<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
Sends a result message to a specified source.- Parameters:
source- the command source who will receive the messagemsg- the message to be sent to the source
-
sendResult
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 entitymsg- the message to be sent, represented as aComponentwithConsole- if true, the message will also be sent to the console
-
sendResult
Sends a message result to a specified source.- Parameters:
source- the source (e.g., player or console) to which the result will be sentmsg- the message to be sent to the source
-
sendResult
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 entitymsg- the message to be sentwithConsole- whether the message should also be sent to the console
-
getName
Retrieves the name of the command.- Returns:
- the name of the command
-
setName
Sets the name of the command, prefixing it with platform-specific identifiers.- Parameters:
name- the base name to set for this command
-
getDescription
Retrieves the description of the command.- Returns:
- the description text for this command
-
setDescription
Sets the description for this command.- Parameters:
description- the description to set for this command
-
getUsage
Retrieves the usage string for the command.- Returns:
- the usage string for the command
-
setUsage
Sets the usage description for this command.- Parameters:
usage- the usage description to set for this command
-
getPermission
Retrieves the permission required to execute this command.- Returns:
- the permission string associated with this command
-
setPermission
Sets the permission for the command with platform-specific modifications.- Parameters:
permission- the base permission string to set for this command
-