diff --git a/src/command/PluginCommand.php b/src/command/PluginCommand.php index 07b0999f0..55b8df3ed 100644 --- a/src/command/PluginCommand.php +++ b/src/command/PluginCommand.php @@ -43,10 +43,6 @@ final class PluginCommand extends Command implements PluginOwned{ return false; } - if(!$this->testPermission($sender)){ - return false; - } - $success = $this->executor->onCommand($sender, $this, $commandLabel, $args); if(!$success && $this->usageMessage !== ""){ diff --git a/src/command/SimpleCommandMap.php b/src/command/SimpleCommandMap.php index 429cd3a3b..89a9d6465 100644 --- a/src/command/SimpleCommandMap.php +++ b/src/command/SimpleCommandMap.php @@ -202,7 +202,9 @@ class SimpleCommandMap implements CommandMap{ $target->timings->startTiming(); try{ - $target->execute($sender, $sentCommandLabel, $args); + if($target->testPermission($sender)){ + $target->execute($sender, $sentCommandLabel, $args); + } }catch(InvalidCommandSyntaxException $e){ $sender->sendMessage($sender->getLanguage()->translate(KnownTranslationFactory::commands_generic_usage($target->getUsage()))); }finally{ diff --git a/src/command/defaults/BanCommand.php b/src/command/defaults/BanCommand.php index 734159a20..fc3117ae1 100644 --- a/src/command/defaults/BanCommand.php +++ b/src/command/defaults/BanCommand.php @@ -45,10 +45,6 @@ class BanCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) === 0){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/BanIpCommand.php b/src/command/defaults/BanIpCommand.php index 13c74888c..2d8bc0632 100644 --- a/src/command/defaults/BanIpCommand.php +++ b/src/command/defaults/BanIpCommand.php @@ -46,10 +46,6 @@ class BanIpCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) === 0){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/BanListCommand.php b/src/command/defaults/BanListCommand.php index 5ec515a2b..606aef9a2 100644 --- a/src/command/defaults/BanListCommand.php +++ b/src/command/defaults/BanListCommand.php @@ -47,10 +47,6 @@ class BanListCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(isset($args[0])){ $args[0] = strtolower($args[0]); if($args[0] === "ips"){ diff --git a/src/command/defaults/ClearCommand.php b/src/command/defaults/ClearCommand.php index 7e4f81065..7acd03ea7 100644 --- a/src/command/defaults/ClearCommand.php +++ b/src/command/defaults/ClearCommand.php @@ -51,10 +51,6 @@ class ClearCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) > 3){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/DefaultGamemodeCommand.php b/src/command/defaults/DefaultGamemodeCommand.php index 860a7506d..03eff2481 100644 --- a/src/command/defaults/DefaultGamemodeCommand.php +++ b/src/command/defaults/DefaultGamemodeCommand.php @@ -42,10 +42,6 @@ class DefaultGamemodeCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) === 0){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/DeopCommand.php b/src/command/defaults/DeopCommand.php index a32d94108..eb6cec268 100644 --- a/src/command/defaults/DeopCommand.php +++ b/src/command/defaults/DeopCommand.php @@ -45,10 +45,6 @@ class DeopCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) === 0){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/DifficultyCommand.php b/src/command/defaults/DifficultyCommand.php index b73204f56..0bfc384e3 100644 --- a/src/command/defaults/DifficultyCommand.php +++ b/src/command/defaults/DifficultyCommand.php @@ -43,10 +43,6 @@ class DifficultyCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) !== 1){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/DumpMemoryCommand.php b/src/command/defaults/DumpMemoryCommand.php index 83f177e01..3844199a1 100644 --- a/src/command/defaults/DumpMemoryCommand.php +++ b/src/command/defaults/DumpMemoryCommand.php @@ -40,10 +40,6 @@ class DumpMemoryCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - $sender->getServer()->getMemoryManager()->dumpServerMemory($args[0] ?? (Path::join($sender->getServer()->getDataPath(), "memory_dumps", date("D_M_j-H.i.s-T_Y"))), 48, 80); return true; } diff --git a/src/command/defaults/EffectCommand.php b/src/command/defaults/EffectCommand.php index 159832bac..5339f4a5b 100644 --- a/src/command/defaults/EffectCommand.php +++ b/src/command/defaults/EffectCommand.php @@ -46,10 +46,6 @@ class EffectCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) < 2){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/EnchantCommand.php b/src/command/defaults/EnchantCommand.php index 092ceb006..64bb146bb 100644 --- a/src/command/defaults/EnchantCommand.php +++ b/src/command/defaults/EnchantCommand.php @@ -44,10 +44,6 @@ class EnchantCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) < 2){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/GamemodeCommand.php b/src/command/defaults/GamemodeCommand.php index 1363d34dc..77fade0b0 100644 --- a/src/command/defaults/GamemodeCommand.php +++ b/src/command/defaults/GamemodeCommand.php @@ -45,10 +45,6 @@ class GamemodeCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) === 0){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/GarbageCollectorCommand.php b/src/command/defaults/GarbageCollectorCommand.php index 69875c7d5..c77fd794f 100644 --- a/src/command/defaults/GarbageCollectorCommand.php +++ b/src/command/defaults/GarbageCollectorCommand.php @@ -43,10 +43,6 @@ class GarbageCollectorCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - $chunksCollected = 0; $entitiesCollected = 0; diff --git a/src/command/defaults/GiveCommand.php b/src/command/defaults/GiveCommand.php index 650a262d0..2d465c74c 100644 --- a/src/command/defaults/GiveCommand.php +++ b/src/command/defaults/GiveCommand.php @@ -51,10 +51,6 @@ class GiveCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) < 2){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/HelpCommand.php b/src/command/defaults/HelpCommand.php index 7fe12e039..d5a530f56 100644 --- a/src/command/defaults/HelpCommand.php +++ b/src/command/defaults/HelpCommand.php @@ -55,10 +55,6 @@ class HelpCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) === 0){ $commandName = ""; $pageNumber = 1; diff --git a/src/command/defaults/KickCommand.php b/src/command/defaults/KickCommand.php index 3ccb2e527..78767b9da 100644 --- a/src/command/defaults/KickCommand.php +++ b/src/command/defaults/KickCommand.php @@ -47,10 +47,6 @@ class KickCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) === 0){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/KillCommand.php b/src/command/defaults/KillCommand.php index c041e0cbb..eebabd3d9 100644 --- a/src/command/defaults/KillCommand.php +++ b/src/command/defaults/KillCommand.php @@ -47,10 +47,6 @@ class KillCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) >= 2){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/ListCommand.php b/src/command/defaults/ListCommand.php index 5df3e1a91..d86416f3d 100644 --- a/src/command/defaults/ListCommand.php +++ b/src/command/defaults/ListCommand.php @@ -45,10 +45,6 @@ class ListCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - $playerNames = array_map(function(Player $player) : string{ return $player->getName(); }, array_filter($sender->getServer()->getOnlinePlayers(), function(Player $player) use ($sender) : bool{ diff --git a/src/command/defaults/MeCommand.php b/src/command/defaults/MeCommand.php index 586d6cb39..33564e9cc 100644 --- a/src/command/defaults/MeCommand.php +++ b/src/command/defaults/MeCommand.php @@ -44,10 +44,6 @@ class MeCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) === 0){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/OpCommand.php b/src/command/defaults/OpCommand.php index 53cbc7461..97b483c80 100644 --- a/src/command/defaults/OpCommand.php +++ b/src/command/defaults/OpCommand.php @@ -45,10 +45,6 @@ class OpCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) === 0){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/PardonCommand.php b/src/command/defaults/PardonCommand.php index a1ea1e6ee..a545fb350 100644 --- a/src/command/defaults/PardonCommand.php +++ b/src/command/defaults/PardonCommand.php @@ -43,10 +43,6 @@ class PardonCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) !== 1){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/PardonIpCommand.php b/src/command/defaults/PardonIpCommand.php index d9a229354..a7adc237d 100644 --- a/src/command/defaults/PardonIpCommand.php +++ b/src/command/defaults/PardonIpCommand.php @@ -44,10 +44,6 @@ class PardonIpCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) !== 1){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/ParticleCommand.php b/src/command/defaults/ParticleCommand.php index 1c9972efb..2c5d1c5d6 100644 --- a/src/command/defaults/ParticleCommand.php +++ b/src/command/defaults/ParticleCommand.php @@ -84,10 +84,6 @@ class ParticleCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) < 7){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/PluginsCommand.php b/src/command/defaults/PluginsCommand.php index e4c83354d..39f86e637 100644 --- a/src/command/defaults/PluginsCommand.php +++ b/src/command/defaults/PluginsCommand.php @@ -47,10 +47,6 @@ class PluginsCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - $list = array_map(function(Plugin $plugin) : string{ return ($plugin->isEnabled() ? TextFormat::GREEN : TextFormat::RED) . $plugin->getDescription()->getFullName(); }, $sender->getServer()->getPluginManager()->getPlugins()); diff --git a/src/command/defaults/SaveCommand.php b/src/command/defaults/SaveCommand.php index 10d036d55..0fefc573c 100644 --- a/src/command/defaults/SaveCommand.php +++ b/src/command/defaults/SaveCommand.php @@ -41,10 +41,6 @@ class SaveCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - Command::broadcastCommandMessage($sender, KnownTranslationFactory::pocketmine_save_start()); $start = microtime(true); diff --git a/src/command/defaults/SaveOffCommand.php b/src/command/defaults/SaveOffCommand.php index b4d86d486..bb13623d7 100644 --- a/src/command/defaults/SaveOffCommand.php +++ b/src/command/defaults/SaveOffCommand.php @@ -39,10 +39,6 @@ class SaveOffCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - $sender->getServer()->getWorldManager()->setAutoSave(false); Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_save_disabled()); diff --git a/src/command/defaults/SaveOnCommand.php b/src/command/defaults/SaveOnCommand.php index 20504122b..cb842db9e 100644 --- a/src/command/defaults/SaveOnCommand.php +++ b/src/command/defaults/SaveOnCommand.php @@ -39,10 +39,6 @@ class SaveOnCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - $sender->getServer()->getWorldManager()->setAutoSave(true); Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_save_enabled()); diff --git a/src/command/defaults/SayCommand.php b/src/command/defaults/SayCommand.php index 16e681553..8419d0de2 100644 --- a/src/command/defaults/SayCommand.php +++ b/src/command/defaults/SayCommand.php @@ -45,10 +45,6 @@ class SayCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) === 0){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/SeedCommand.php b/src/command/defaults/SeedCommand.php index e7345f8ba..af353f87a 100644 --- a/src/command/defaults/SeedCommand.php +++ b/src/command/defaults/SeedCommand.php @@ -39,10 +39,6 @@ class SeedCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if($sender instanceof Player){ $seed = $sender->getPosition()->getWorld()->getSeed(); }else{ diff --git a/src/command/defaults/SetWorldSpawnCommand.php b/src/command/defaults/SetWorldSpawnCommand.php index 0c0d46c11..928afd86a 100644 --- a/src/command/defaults/SetWorldSpawnCommand.php +++ b/src/command/defaults/SetWorldSpawnCommand.php @@ -46,10 +46,6 @@ class SetWorldSpawnCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) === 0){ if($sender instanceof Player){ $location = $sender->getPosition(); diff --git a/src/command/defaults/SpawnpointCommand.php b/src/command/defaults/SpawnpointCommand.php index b5932770a..de8789e9a 100644 --- a/src/command/defaults/SpawnpointCommand.php +++ b/src/command/defaults/SpawnpointCommand.php @@ -47,10 +47,6 @@ class SpawnpointCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - $target = null; if(count($args) === 0){ diff --git a/src/command/defaults/StatusCommand.php b/src/command/defaults/StatusCommand.php index 7e5f9b544..67088be9c 100644 --- a/src/command/defaults/StatusCommand.php +++ b/src/command/defaults/StatusCommand.php @@ -45,10 +45,6 @@ class StatusCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - $mUsage = Process::getAdvancedMemoryUsage(); $server = $sender->getServer(); diff --git a/src/command/defaults/StopCommand.php b/src/command/defaults/StopCommand.php index 664fa3657..382f99ca0 100644 --- a/src/command/defaults/StopCommand.php +++ b/src/command/defaults/StopCommand.php @@ -39,10 +39,6 @@ class StopCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_stop_start()); $sender->getServer()->shutdown(); diff --git a/src/command/defaults/TeleportCommand.php b/src/command/defaults/TeleportCommand.php index 618ae10a2..5713ef231 100644 --- a/src/command/defaults/TeleportCommand.php +++ b/src/command/defaults/TeleportCommand.php @@ -59,10 +59,6 @@ class TeleportCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - switch(count($args)){ case 1: // /tp targetPlayer case 3: // /tp x y z diff --git a/src/command/defaults/TellCommand.php b/src/command/defaults/TellCommand.php index bf36d255f..672e5b74b 100644 --- a/src/command/defaults/TellCommand.php +++ b/src/command/defaults/TellCommand.php @@ -47,10 +47,6 @@ class TellCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) < 2){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/TimeCommand.php b/src/command/defaults/TimeCommand.php index 49edee2b8..33357e4df 100644 --- a/src/command/defaults/TimeCommand.php +++ b/src/command/defaults/TimeCommand.php @@ -51,9 +51,6 @@ class TimeCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } if(count($args) < 1){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/TimingsCommand.php b/src/command/defaults/TimingsCommand.php index 14fae62f5..9a5076072 100644 --- a/src/command/defaults/TimingsCommand.php +++ b/src/command/defaults/TimingsCommand.php @@ -67,10 +67,6 @@ class TimingsCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) !== 1){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/TitleCommand.php b/src/command/defaults/TitleCommand.php index 19218799c..cf0670608 100644 --- a/src/command/defaults/TitleCommand.php +++ b/src/command/defaults/TitleCommand.php @@ -44,10 +44,6 @@ class TitleCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) < 2){ throw new InvalidCommandSyntaxException(); } diff --git a/src/command/defaults/TransferServerCommand.php b/src/command/defaults/TransferServerCommand.php index 5d15c8258..532f0e18c 100644 --- a/src/command/defaults/TransferServerCommand.php +++ b/src/command/defaults/TransferServerCommand.php @@ -42,10 +42,6 @@ class TransferServerCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) < 1){ throw new InvalidCommandSyntaxException(); }elseif(!($sender instanceof Player)){ diff --git a/src/command/defaults/VersionCommand.php b/src/command/defaults/VersionCommand.php index 9fa670957..6c579cdda 100644 --- a/src/command/defaults/VersionCommand.php +++ b/src/command/defaults/VersionCommand.php @@ -53,10 +53,6 @@ class VersionCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) === 0){ $sender->sendMessage(KnownTranslationFactory::pocketmine_command_version_serverSoftwareName( VersionInfo::NAME diff --git a/src/command/defaults/WhitelistCommand.php b/src/command/defaults/WhitelistCommand.php index 02fd65f23..2b1a90c53 100644 --- a/src/command/defaults/WhitelistCommand.php +++ b/src/command/defaults/WhitelistCommand.php @@ -55,10 +55,6 @@ class WhitelistCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - if(!$this->testPermission($sender)){ - return true; - } - if(count($args) === 1){ switch(strtolower($args[0])){ case "reload":