Declare built-in command names inside the constructor (#5487)

This increases code consistency by placing the name in the same place where everything else about the command is defined.
This commit is contained in:
BrandPVP 2023-01-09 23:43:08 +03:00 committed by GitHub
parent 545d18eea7
commit 9c391a6809
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 121 additions and 121 deletions

View File

@ -89,46 +89,46 @@ class SimpleCommandMap implements CommandMap{
private function setDefaultCommands() : void{ private function setDefaultCommands() : void{
$this->registerAll("pocketmine", [ $this->registerAll("pocketmine", [
new BanCommand("ban"), new BanCommand(),
new BanIpCommand("ban-ip"), new BanIpCommand(),
new BanListCommand("banlist"), new BanListCommand(),
new ClearCommand("clear"), new ClearCommand(),
new DefaultGamemodeCommand("defaultgamemode"), new DefaultGamemodeCommand(),
new DeopCommand("deop"), new DeopCommand(),
new DifficultyCommand("difficulty"), new DifficultyCommand(),
new DumpMemoryCommand("dumpmemory"), new DumpMemoryCommand(),
new EffectCommand("effect"), new EffectCommand(),
new EnchantCommand("enchant"), new EnchantCommand(),
new GamemodeCommand("gamemode"), new GamemodeCommand(),
new GarbageCollectorCommand("gc"), new GarbageCollectorCommand(),
new GiveCommand("give"), new GiveCommand(),
new HelpCommand("help"), new HelpCommand(),
new KickCommand("kick"), new KickCommand(),
new KillCommand("kill"), new KillCommand(),
new ListCommand("list"), new ListCommand(),
new MeCommand("me"), new MeCommand(),
new OpCommand("op"), new OpCommand(),
new PardonCommand("pardon"), new PardonCommand(),
new PardonIpCommand("pardon-ip"), new PardonIpCommand(),
new ParticleCommand("particle"), new ParticleCommand(),
new PluginsCommand("plugins"), new PluginsCommand(),
new SaveCommand("save-all"), new SaveCommand(),
new SaveOffCommand("save-off"), new SaveOffCommand(),
new SaveOnCommand("save-on"), new SaveOnCommand(),
new SayCommand("say"), new SayCommand(),
new SeedCommand("seed"), new SeedCommand(),
new SetWorldSpawnCommand("setworldspawn"), new SetWorldSpawnCommand(),
new SpawnpointCommand("spawnpoint"), new SpawnpointCommand(),
new StatusCommand("status"), new StatusCommand(),
new StopCommand("stop"), new StopCommand(),
new TeleportCommand("tp"), new TeleportCommand(),
new TellCommand("tell"), new TellCommand(),
new TimeCommand("time"), new TimeCommand(),
new TimingsCommand("timings"), new TimingsCommand(),
new TitleCommand("title"), new TitleCommand(),
new TransferServerCommand("transferserver"), new TransferServerCommand(),
new VersionCommand("version"), new VersionCommand(),
new WhitelistCommand("whitelist") new WhitelistCommand()
]); ]);
} }

View File

@ -35,9 +35,9 @@ use function implode;
class BanCommand extends VanillaCommand{ class BanCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "ban",
KnownTranslationFactory::pocketmine_command_ban_player_description(), KnownTranslationFactory::pocketmine_command_ban_player_description(),
KnownTranslationFactory::commands_ban_usage() KnownTranslationFactory::commands_ban_usage()
); );

View File

@ -36,9 +36,9 @@ use function inet_pton;
class BanIpCommand extends VanillaCommand{ class BanIpCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "ban-ip",
KnownTranslationFactory::pocketmine_command_ban_ip_description(), KnownTranslationFactory::pocketmine_command_ban_ip_description(),
KnownTranslationFactory::commands_banip_usage() KnownTranslationFactory::commands_banip_usage()
); );

View File

@ -37,9 +37,9 @@ use const SORT_STRING;
class BanListCommand extends VanillaCommand{ class BanListCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "banlist",
KnownTranslationFactory::pocketmine_command_banlist_description(), KnownTranslationFactory::pocketmine_command_banlist_description(),
KnownTranslationFactory::commands_banlist_usage() KnownTranslationFactory::commands_banlist_usage()
); );

View File

@ -40,9 +40,9 @@ use function min;
class ClearCommand extends VanillaCommand{ class ClearCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "clear",
KnownTranslationFactory::pocketmine_command_clear_description(), KnownTranslationFactory::pocketmine_command_clear_description(),
KnownTranslationFactory::pocketmine_command_clear_usage() KnownTranslationFactory::pocketmine_command_clear_usage()
); );

View File

@ -32,9 +32,9 @@ use function count;
class DefaultGamemodeCommand extends VanillaCommand{ class DefaultGamemodeCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "defaultgamemode",
KnownTranslationFactory::pocketmine_command_defaultgamemode_description(), KnownTranslationFactory::pocketmine_command_defaultgamemode_description(),
KnownTranslationFactory::commands_defaultgamemode_usage() KnownTranslationFactory::commands_defaultgamemode_usage()
); );

View File

@ -35,9 +35,9 @@ use function count;
class DeopCommand extends VanillaCommand{ class DeopCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "deop",
KnownTranslationFactory::pocketmine_command_deop_description(), KnownTranslationFactory::pocketmine_command_deop_description(),
KnownTranslationFactory::commands_deop_usage() KnownTranslationFactory::commands_deop_usage()
); );

View File

@ -33,9 +33,9 @@ use function count;
class DifficultyCommand extends VanillaCommand{ class DifficultyCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "difficulty",
KnownTranslationFactory::pocketmine_command_difficulty_description(), KnownTranslationFactory::pocketmine_command_difficulty_description(),
KnownTranslationFactory::commands_difficulty_usage() KnownTranslationFactory::commands_difficulty_usage()
); );

View File

@ -30,11 +30,11 @@ use function date;
class DumpMemoryCommand extends VanillaCommand{ class DumpMemoryCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "dumpmemory",
"Dumps the memory", "Dumps the memory",
"/$name [path]" "/dumpmemory [path]"
); );
$this->setPermission(DefaultPermissionNames::COMMAND_DUMPMEMORY); $this->setPermission(DefaultPermissionNames::COMMAND_DUMPMEMORY);
} }

View File

@ -37,9 +37,9 @@ use function strtolower;
class EffectCommand extends VanillaCommand{ class EffectCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "effect",
KnownTranslationFactory::pocketmine_command_effect_description(), KnownTranslationFactory::pocketmine_command_effect_description(),
KnownTranslationFactory::commands_effect_usage() KnownTranslationFactory::commands_effect_usage()
); );

View File

@ -34,9 +34,9 @@ use function implode;
class EnchantCommand extends VanillaCommand{ class EnchantCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "enchant",
KnownTranslationFactory::pocketmine_command_enchant_description(), KnownTranslationFactory::pocketmine_command_enchant_description(),
KnownTranslationFactory::commands_enchant_usage() KnownTranslationFactory::commands_enchant_usage()
); );

View File

@ -34,9 +34,9 @@ use function implode;
class GamemodeCommand extends VanillaCommand{ class GamemodeCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "gamemode",
KnownTranslationFactory::pocketmine_command_gamemode_description(), KnownTranslationFactory::pocketmine_command_gamemode_description(),
KnownTranslationFactory::commands_gamemode_usage() KnownTranslationFactory::commands_gamemode_usage()
); );

View File

@ -34,9 +34,9 @@ use function round;
class GarbageCollectorCommand extends VanillaCommand{ class GarbageCollectorCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "gc",
KnownTranslationFactory::pocketmine_command_gc_description() KnownTranslationFactory::pocketmine_command_gc_description()
); );
$this->setPermission(DefaultPermissionNames::COMMAND_GC); $this->setPermission(DefaultPermissionNames::COMMAND_GC);

View File

@ -41,9 +41,9 @@ use function implode;
class GiveCommand extends VanillaCommand{ class GiveCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "give",
KnownTranslationFactory::pocketmine_command_give_description(), KnownTranslationFactory::pocketmine_command_give_description(),
KnownTranslationFactory::pocketmine_command_give_usage() KnownTranslationFactory::pocketmine_command_give_usage()
); );

View File

@ -44,9 +44,9 @@ use const SORT_NATURAL;
class HelpCommand extends VanillaCommand{ class HelpCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "help",
KnownTranslationFactory::pocketmine_command_help_description(), KnownTranslationFactory::pocketmine_command_help_description(),
KnownTranslationFactory::commands_help_usage(), KnownTranslationFactory::commands_help_usage(),
["?"] ["?"]

View File

@ -37,9 +37,9 @@ use function trim;
class KickCommand extends VanillaCommand{ class KickCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "kick",
KnownTranslationFactory::pocketmine_command_kick_description(), KnownTranslationFactory::pocketmine_command_kick_description(),
KnownTranslationFactory::commands_kick_usage() KnownTranslationFactory::commands_kick_usage()
); );

View File

@ -34,9 +34,9 @@ use function implode;
class KillCommand extends VanillaCommand{ class KillCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "kill",
KnownTranslationFactory::pocketmine_command_kill_description(), KnownTranslationFactory::pocketmine_command_kill_description(),
KnownTranslationFactory::pocketmine_command_kill_usage(), KnownTranslationFactory::pocketmine_command_kill_usage(),
["suicide"] ["suicide"]

View File

@ -36,9 +36,9 @@ use const SORT_STRING;
class ListCommand extends VanillaCommand{ class ListCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "list",
KnownTranslationFactory::pocketmine_command_list_description() KnownTranslationFactory::pocketmine_command_list_description()
); );
$this->setPermission(DefaultPermissionNames::COMMAND_LIST); $this->setPermission(DefaultPermissionNames::COMMAND_LIST);

View File

@ -34,9 +34,9 @@ use function implode;
class MeCommand extends VanillaCommand{ class MeCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "me",
KnownTranslationFactory::pocketmine_command_me_description(), KnownTranslationFactory::pocketmine_command_me_description(),
KnownTranslationFactory::commands_me_usage() KnownTranslationFactory::commands_me_usage()
); );

View File

@ -35,9 +35,9 @@ use function count;
class OpCommand extends VanillaCommand{ class OpCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "op",
KnownTranslationFactory::pocketmine_command_op_description(), KnownTranslationFactory::pocketmine_command_op_description(),
KnownTranslationFactory::commands_op_usage() KnownTranslationFactory::commands_op_usage()
); );

View File

@ -32,9 +32,9 @@ use function count;
class PardonCommand extends VanillaCommand{ class PardonCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "pardon",
KnownTranslationFactory::pocketmine_command_unban_player_description(), KnownTranslationFactory::pocketmine_command_unban_player_description(),
KnownTranslationFactory::commands_unban_usage(), KnownTranslationFactory::commands_unban_usage(),
["unban"] ["unban"]

View File

@ -33,9 +33,9 @@ use function inet_pton;
class PardonIpCommand extends VanillaCommand{ class PardonIpCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "pardon-ip",
KnownTranslationFactory::pocketmine_command_unban_ip_description(), KnownTranslationFactory::pocketmine_command_unban_ip_description(),
KnownTranslationFactory::commands_unbanip_usage(), KnownTranslationFactory::commands_unbanip_usage(),
["unban-ip"] ["unban-ip"]

View File

@ -74,9 +74,9 @@ use function strtolower;
class ParticleCommand extends VanillaCommand{ class ParticleCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "particle",
KnownTranslationFactory::pocketmine_command_particle_description(), KnownTranslationFactory::pocketmine_command_particle_description(),
KnownTranslationFactory::pocketmine_command_particle_usage() KnownTranslationFactory::pocketmine_command_particle_usage()
); );

View File

@ -36,9 +36,9 @@ use const SORT_STRING;
class PluginsCommand extends VanillaCommand{ class PluginsCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "plugins",
KnownTranslationFactory::pocketmine_command_plugins_description(), KnownTranslationFactory::pocketmine_command_plugins_description(),
null, null,
["pl"] ["pl"]

View File

@ -32,9 +32,9 @@ use function round;
class SaveCommand extends VanillaCommand{ class SaveCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "save-all",
KnownTranslationFactory::pocketmine_command_save_description() KnownTranslationFactory::pocketmine_command_save_description()
); );
$this->setPermission(DefaultPermissionNames::COMMAND_SAVE_PERFORM); $this->setPermission(DefaultPermissionNames::COMMAND_SAVE_PERFORM);

View File

@ -30,9 +30,9 @@ use pocketmine\permission\DefaultPermissionNames;
class SaveOffCommand extends VanillaCommand{ class SaveOffCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "save-off",
KnownTranslationFactory::pocketmine_command_saveoff_description() KnownTranslationFactory::pocketmine_command_saveoff_description()
); );
$this->setPermission(DefaultPermissionNames::COMMAND_SAVE_DISABLE); $this->setPermission(DefaultPermissionNames::COMMAND_SAVE_DISABLE);

View File

@ -30,9 +30,9 @@ use pocketmine\permission\DefaultPermissionNames;
class SaveOnCommand extends VanillaCommand{ class SaveOnCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "save-on",
KnownTranslationFactory::pocketmine_command_saveon_description() KnownTranslationFactory::pocketmine_command_saveon_description()
); );
$this->setPermission(DefaultPermissionNames::COMMAND_SAVE_ENABLE); $this->setPermission(DefaultPermissionNames::COMMAND_SAVE_ENABLE);

View File

@ -35,9 +35,9 @@ use function implode;
class SayCommand extends VanillaCommand{ class SayCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "say",
KnownTranslationFactory::pocketmine_command_say_description(), KnownTranslationFactory::pocketmine_command_say_description(),
KnownTranslationFactory::commands_say_usage() KnownTranslationFactory::commands_say_usage()
); );

View File

@ -30,9 +30,9 @@ use pocketmine\player\Player;
class SeedCommand extends VanillaCommand{ class SeedCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "seed",
KnownTranslationFactory::pocketmine_command_seed_description() KnownTranslationFactory::pocketmine_command_seed_description()
); );
$this->setPermission(DefaultPermissionNames::COMMAND_SEED); $this->setPermission(DefaultPermissionNames::COMMAND_SEED);

View File

@ -36,9 +36,9 @@ use function count;
class SetWorldSpawnCommand extends VanillaCommand{ class SetWorldSpawnCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "setworldspawn",
KnownTranslationFactory::pocketmine_command_setworldspawn_description(), KnownTranslationFactory::pocketmine_command_setworldspawn_description(),
KnownTranslationFactory::commands_setworldspawn_usage() KnownTranslationFactory::commands_setworldspawn_usage()
); );

View File

@ -37,9 +37,9 @@ use function round;
class SpawnpointCommand extends VanillaCommand{ class SpawnpointCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "spawnpoint",
KnownTranslationFactory::pocketmine_command_spawnpoint_description(), KnownTranslationFactory::pocketmine_command_spawnpoint_description(),
KnownTranslationFactory::commands_spawnpoint_usage() KnownTranslationFactory::commands_spawnpoint_usage()
); );

View File

@ -36,9 +36,9 @@ use function round;
class StatusCommand extends VanillaCommand{ class StatusCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "status",
KnownTranslationFactory::pocketmine_command_status_description() KnownTranslationFactory::pocketmine_command_status_description()
); );
$this->setPermission(DefaultPermissionNames::COMMAND_STATUS); $this->setPermission(DefaultPermissionNames::COMMAND_STATUS);

View File

@ -30,9 +30,9 @@ use pocketmine\permission\DefaultPermissionNames;
class StopCommand extends VanillaCommand{ class StopCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "stop",
KnownTranslationFactory::pocketmine_command_stop_description() KnownTranslationFactory::pocketmine_command_stop_description()
); );
$this->setPermission(DefaultPermissionNames::COMMAND_STOP); $this->setPermission(DefaultPermissionNames::COMMAND_STOP);

View File

@ -40,9 +40,9 @@ use function round;
class TeleportCommand extends VanillaCommand{ class TeleportCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "tp",
KnownTranslationFactory::pocketmine_command_tp_description(), KnownTranslationFactory::pocketmine_command_tp_description(),
KnownTranslationFactory::commands_tp_usage(), KnownTranslationFactory::commands_tp_usage(),
["teleport"] ["teleport"]

View File

@ -36,9 +36,9 @@ use function implode;
class TellCommand extends VanillaCommand{ class TellCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "tell",
KnownTranslationFactory::pocketmine_command_tell_description(), KnownTranslationFactory::pocketmine_command_tell_description(),
KnownTranslationFactory::commands_message_usage(), KnownTranslationFactory::commands_message_usage(),
["w", "msg"] ["w", "msg"]

View File

@ -35,9 +35,9 @@ use function implode;
class TimeCommand extends VanillaCommand{ class TimeCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "time",
KnownTranslationFactory::pocketmine_command_time_description(), KnownTranslationFactory::pocketmine_command_time_description(),
KnownTranslationFactory::pocketmine_command_time_usage() KnownTranslationFactory::pocketmine_command_time_usage()
); );

View File

@ -57,9 +57,9 @@ use const PHP_EOL;
class TimingsCommand extends VanillaCommand{ class TimingsCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "timings",
KnownTranslationFactory::pocketmine_command_timings_description(), KnownTranslationFactory::pocketmine_command_timings_description(),
KnownTranslationFactory::pocketmine_command_timings_usage() KnownTranslationFactory::pocketmine_command_timings_usage()
); );

View File

@ -33,9 +33,9 @@ use function implode;
class TitleCommand extends VanillaCommand{ class TitleCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "title",
KnownTranslationFactory::pocketmine_command_title_description(), KnownTranslationFactory::pocketmine_command_title_description(),
KnownTranslationFactory::commands_title_usage() KnownTranslationFactory::commands_title_usage()
); );

View File

@ -32,9 +32,9 @@ use function count;
class TransferServerCommand extends VanillaCommand{ class TransferServerCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "transferserver",
KnownTranslationFactory::pocketmine_command_transferserver_description(), KnownTranslationFactory::pocketmine_command_transferserver_description(),
KnownTranslationFactory::pocketmine_command_transferserver_usage() KnownTranslationFactory::pocketmine_command_transferserver_usage()
); );

View File

@ -40,9 +40,9 @@ use const PHP_VERSION;
class VersionCommand extends VanillaCommand{ class VersionCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "version",
KnownTranslationFactory::pocketmine_command_version_description(), KnownTranslationFactory::pocketmine_command_version_description(),
KnownTranslationFactory::pocketmine_command_version_usage(), KnownTranslationFactory::pocketmine_command_version_usage(),
["ver", "about"] ["ver", "about"]

View File

@ -38,9 +38,9 @@ use const SORT_STRING;
class WhitelistCommand extends VanillaCommand{ class WhitelistCommand extends VanillaCommand{
public function __construct(string $name){ public function __construct(){
parent::__construct( parent::__construct(
$name, "whitelist",
KnownTranslationFactory::pocketmine_command_whitelist_description(), KnownTranslationFactory::pocketmine_command_whitelist_description(),
KnownTranslationFactory::commands_whitelist_usage() KnownTranslationFactory::commands_whitelist_usage()
); );