BaseCommand
extends Command
in package
implements
IArgumentable, IRunnable, PluginOwned
Uses
ArgumentableTrait
Interfaces, Classes, Traits and Enums
- IArgumentable
- IRunnable
- Interface IRunnable
- PluginOwned
- This interface may be implemented by objects which are owned by plugins, to allow them to be identified as such.
Table of Contents
- ERR_INSUFFICIENT_ARGUMENTS = 0x3
- ERR_INVALID_ARG_VALUE = 0x1
- ERR_NO_ARGUMENTS = 0x4
- ERR_TOO_MANY_ARGUMENTS = 0x2
- $timings : TimingsHandler|null
- $currentSender : CommandSender
- $description : Translatable|string
- $errorMessages : array<string|int, mixed>
- $usageMessage : Translatable|string
- $activeAliases : array<string|int, string>
- $aliases : array<string|int, string>
- $argumentList : array<string|int, mixed>
- $commandMap : CommandMap|null
- $constraints : array<string|int, mixed>
- $label : string
- $name : string
- $nextLabel : string
- $permission : string|null
- $permissionMessage : string|null
- $plugin : Plugin
- $requiredArgumentCount : array<string|int, mixed>
- $subCommands : array<string|int, mixed>
- __construct() : mixed
- __toString() : string
- addConstraint() : void
- broadcastCommandMessage() : void
- execute() : mixed
- generateUsageMessage() : string
- getAliases() : array<string|int, string>
- getArgumentList() : array<string|int, array<string|int, BaseArgument>>
- getConstraints() : array<string|int, BaseConstraint>
- getDescription() : Translatable|string
- getLabel() : string
- getName() : string
- getOwningPlugin() : Plugin
- getPermission() : string|null
- getPermissionMessage() : string|null
- getSubCommands() : array<string|int, BaseSubCommand>
- getUsage() : Translatable|string
- getUsageMessage() : string
- hasArguments() : bool
- hasRequiredArguments() : bool
- isRegistered() : bool
- onRun() : void
- parseArguments() : array<string|int, mixed>
- register() : bool
- Registers the command into a Command map
- registerArgument() : void
- registerSubCommand() : void
- sendError() : void
- setAliases() : void
- setDescription() : void
- setErrorFormat() : void
- setErrorFormats() : void
- setLabel() : bool
- setPermission() : void
- setPermissionMessage() : void
- setUsage() : void
- testPermission() : bool
- testPermissionSilent() : bool
- unregister() : bool
- prepare() : void
- This is where all the arguments, permissions, sub-commands, etc would be registered
- sendUsage() : void
- allowChangesFrom() : bool
- attemptArgumentParsing() : array<string|int, mixed>|null
Constants
ERR_INSUFFICIENT_ARGUMENTS
public
mixed
ERR_INSUFFICIENT_ARGUMENTS
= 0x3
ERR_INVALID_ARG_VALUE
public
mixed
ERR_INVALID_ARG_VALUE
= 0x1
ERR_NO_ARGUMENTS
public
mixed
ERR_NO_ARGUMENTS
= 0x4
ERR_TOO_MANY_ARGUMENTS
public
mixed
ERR_TOO_MANY_ARGUMENTS
= 0x2
Properties
$timings
public
TimingsHandler|null
$timings
= null
$currentSender
protected
CommandSender
$currentSender
$description
protected
Translatable|string
$description
= ""
$errorMessages
protected
array<string|int, mixed>
$errorMessages
= [self::ERR_INVALID_ARG_VALUE => \pocketmine\utils\TextFormat::RED . "Invalid value '{value}' for argument #{position}", self::ERR_TOO_MANY_ARGUMENTS => \pocketmine\utils\TextFormat::RED . "Too many arguments given", self::ERR_INSUFFICIENT_ARGUMENTS => \pocketmine\utils\TextFormat::RED . "Insufficient number of arguments given", self::ERR_NO_ARGUMENTS => \pocketmine\utils\TextFormat::RED . "No arguments are required for this command"]
$usageMessage
protected
Translatable|string
$usageMessage
$activeAliases
private
array<string|int, string>
$activeAliases
= []
$aliases
private
array<string|int, string>
$aliases
= []
$argumentList
private
array<string|int, mixed>
$argumentList
= []
$commandMap
private
CommandMap|null
$commandMap
= null
$constraints
private
array<string|int, mixed>
$constraints
= []
$label
private
string
$label
$name
private
string
$name
$nextLabel
private
string
$nextLabel
$permission
private
string|null
$permission
= null
$permissionMessage
private
string|null
$permissionMessage
= null
$plugin
private
Plugin
$plugin
$requiredArgumentCount
private
array<string|int, mixed>
$requiredArgumentCount
= []
$subCommands
private
array<string|int, mixed>
$subCommands
= []
Methods
__construct()
public
__construct(Plugin $plugin, string $name[, string $description = "" ][, array<string|int, mixed> $aliases = [] ]) : mixed
Parameters
- $plugin : Plugin
- $name : string
- $description : string = ""
- $aliases : array<string|int, mixed> = []
Return values
mixed —__toString()
public
__toString() : string
Return values
string —addConstraint()
public
addConstraint(BaseConstraint $constraint) : void
Parameters
- $constraint : BaseConstraint
Return values
void —broadcastCommandMessage()
public
static broadcastCommandMessage(CommandSender $source, Translatable|string $message[, bool $sendToSource = true ]) : void
Parameters
- $source : CommandSender
- $message : Translatable|string
- $sendToSource : bool = true
Return values
void —execute()
public
final execute(CommandSender $sender, string $commandLabel, array<string|int, mixed> $args) : mixed
Parameters
- $sender : CommandSender
- $commandLabel : string
- $args : array<string|int, mixed>
Return values
mixed —generateUsageMessage()
public
generateUsageMessage() : string
Return values
string —getAliases()
public
getAliases() : array<string|int, string>
Return values
array<string|int, string> —getArgumentList()
public
getArgumentList() : array<string|int, array<string|int, BaseArgument>>
Return values
array<string|int, array<string|int, BaseArgument>> —getConstraints()
public
getConstraints() : array<string|int, BaseConstraint>
Return values
array<string|int, BaseConstraint> —getDescription()
public
getDescription() : Translatable|string
Return values
Translatable|string —getLabel()
public
getLabel() : string
Return values
string —getName()
public
getName() : string
Return values
string —getOwningPlugin()
public
getOwningPlugin() : Plugin
Return values
Plugin —getPermission()
public
getPermission() : string|null
Return values
string|null —getPermissionMessage()
public
getPermissionMessage() : string|null
Return values
string|null —getSubCommands()
public
getSubCommands() : array<string|int, BaseSubCommand>
Return values
array<string|int, BaseSubCommand> —getUsage()
public
getUsage() : Translatable|string
Return values
Translatable|string —getUsageMessage()
public
getUsageMessage() : string
Return values
string —hasArguments()
public
hasArguments() : bool
Return values
bool —hasRequiredArguments()
public
hasRequiredArguments() : bool
Return values
bool —isRegistered()
public
isRegistered() : bool
Return values
bool —onRun()
public
abstract onRun(CommandSender $sender, string $aliasUsed, array<string|int, mixed>|array<string, mixed|array> $args) : void
Parameters
- $sender : CommandSender
- $aliasUsed : string
- $args : array<string|int, mixed>|array<string, mixed|array>
Return values
void —parseArguments()
public
parseArguments(array<string|int, mixed> $rawArgs, CommandSender $sender) : array<string|int, mixed>
Parameters
- $rawArgs : array<string|int, mixed>
- $sender : CommandSender
Return values
array<string|int, mixed> —register()
Registers the command into a Command map
public
register(CommandMap $commandMap) : bool
Parameters
- $commandMap : CommandMap
Return values
bool —registerArgument()
public
registerArgument(int $position, BaseArgument $argument) : void
Parameters
- $position : int
- $argument : BaseArgument
Tags
Return values
void —registerSubCommand()
public
registerSubCommand(BaseSubCommand $subCommand) : void
Parameters
- $subCommand : BaseSubCommand
Return values
void —sendError()
public
sendError(int $errorCode[, array<string|int, mixed> $args = [] ]) : void
Parameters
- $errorCode : int
- $args : array<string|int, mixed> = []
Return values
void —setAliases()
public
setAliases(array<string|int, string> $aliases) : void
Parameters
- $aliases : array<string|int, string>
Return values
void —setDescription()
public
setDescription(Translatable|string $description) : void
Parameters
- $description : Translatable|string
Return values
void —setErrorFormat()
public
setErrorFormat(int $errorCode, string $format) : void
Parameters
- $errorCode : int
- $format : string
Return values
void —setErrorFormats()
public
setErrorFormats(array<string|int, mixed> $errorFormats) : void
Parameters
- $errorFormats : array<string|int, mixed>
Return values
void —setLabel()
public
setLabel(string $name) : bool
Parameters
- $name : string
Return values
bool —setPermission()
public
setPermission(string|null $permission) : void
Parameters
- $permission : string|null
Return values
void —setPermissionMessage()
public
setPermissionMessage(string $permissionMessage) : void
Parameters
- $permissionMessage : string
Return values
void —setUsage()
public
setUsage(Translatable|string $usage) : void
Parameters
- $usage : Translatable|string
Return values
void —testPermission()
public
testPermission(CommandSender $target[, string|null $permission = null ]) : bool
Parameters
- $target : CommandSender
- $permission : string|null = null
Return values
bool —testPermissionSilent()
public
testPermissionSilent(CommandSender $target[, string|null $permission = null ]) : bool
Parameters
- $target : CommandSender
- $permission : string|null = null
Return values
bool —unregister()
public
unregister(CommandMap $commandMap) : bool
Parameters
- $commandMap : CommandMap
Return values
bool —prepare()
This is where all the arguments, permissions, sub-commands, etc would be registered
protected
abstract prepare() : void
Return values
void —sendUsage()
protected
sendUsage() : void
Return values
void —allowChangesFrom()
private
allowChangesFrom(CommandMap $commandMap) : bool
Parameters
- $commandMap : CommandMap
Return values
bool —attemptArgumentParsing()
private
attemptArgumentParsing(ArgumentableTrait $ctx, array<string|int, mixed> $args) : array<string|int, mixed>|null
Parameters
- $ctx : ArgumentableTrait
- $args : array<string|int, mixed>