diff --git a/src/pocketmine/command/Command.php b/src/pocketmine/command/Command.php index c119de043..22eb347c5 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -74,7 +74,7 @@ abstract class Command{ * @param string $usageMessage * @param string[] $aliases */ - public function __construct($name, $description = "", $usageMessage = null, array $aliases = []){ + public function __construct(string $name, string $description = "", string $usageMessage = null, array $aliases = []){ $this->commandData = self::generateDefaultData(); $this->name = $name; $this->setLabel($name); @@ -118,7 +118,7 @@ abstract class Command{ /** * @return array */ - public function getOverloads(): array{ + public function getOverloads() : array{ return $this->commandData["overloads"]; } @@ -129,12 +129,12 @@ abstract class Command{ * * @return mixed */ - abstract public function execute(CommandSender $sender, $commandLabel, array $args); + abstract public function execute(CommandSender $sender, string $commandLabel, array $args); /** * @return string */ - public function getName(){ + public function getName() : string{ return $this->name; } @@ -149,7 +149,7 @@ abstract class Command{ /** * @param string|null $permission */ - public function setPermission($permission){ + public function setPermission(string $permission = null){ if($permission !== null){ $this->commandData["pocketminePermission"] = $permission; }else{ @@ -162,7 +162,7 @@ abstract class Command{ * * @return bool */ - public function testPermission(CommandSender $target){ + public function testPermission(CommandSender $target) : bool{ if($this->testPermissionSilent($target)){ return true; } @@ -181,7 +181,7 @@ abstract class Command{ * * @return bool */ - public function testPermissionSilent(CommandSender $target){ + public function testPermissionSilent(CommandSender $target) : bool{ if(($perm = $this->getPermission()) === null or $perm === ""){ return true; } @@ -198,11 +198,11 @@ abstract class Command{ /** * @return string */ - public function getLabel(){ + public function getLabel() : string{ return $this->label; } - public function setLabel($name){ + public function setLabel(string $name){ $this->nextLabel = $name; if(!$this->isRegistered()){ if($this->timings instanceof TimingsHandler){ @@ -224,7 +224,7 @@ abstract class Command{ * * @return bool */ - public function register(CommandMap $commandMap){ + public function register(CommandMap $commandMap) : bool{ if($this->allowChangesFrom($commandMap)){ $this->commandMap = $commandMap; @@ -239,7 +239,7 @@ abstract class Command{ * * @return bool */ - public function unregister(CommandMap $commandMap){ + public function unregister(CommandMap $commandMap) : bool{ if($this->allowChangesFrom($commandMap)){ $this->commandMap = null; $this->activeAliases = $this->commandData["aliases"]; @@ -256,42 +256,42 @@ abstract class Command{ * * @return bool */ - private function allowChangesFrom(CommandMap $commandMap){ + private function allowChangesFrom(CommandMap $commandMap) : bool{ return $this->commandMap === null or $this->commandMap === $commandMap; } /** * @return bool */ - public function isRegistered(){ + public function isRegistered() : bool{ return $this->commandMap !== null; } /** * @return string[] */ - public function getAliases(){ + public function getAliases() : array{ return $this->activeAliases; } /** * @return string */ - public function getPermissionMessage(){ + public function getPermissionMessage() : string{ return $this->permissionMessage; } /** * @return string */ - public function getDescription(){ + public function getDescription() : string{ return $this->commandData["description"]; } /** * @return string */ - public function getUsage(){ + public function getUsage() : string{ return $this->usageMessage; } @@ -308,21 +308,21 @@ abstract class Command{ /** * @param string $description */ - public function setDescription($description){ + public function setDescription(string $description){ $this->commandData["description"] = $description; } /** * @param string $permissionMessage */ - public function setPermissionMessage($permissionMessage){ + public function setPermissionMessage(string $permissionMessage){ $this->permissionMessage = $permissionMessage; } /** * @param string $usage */ - public function setUsage($usage){ + public function setUsage(string $usage){ $this->usageMessage = $usage; } @@ -337,11 +337,11 @@ abstract class Command{ } /** - * @param CommandSender $source - * @param string $message - * @param bool $sendToSource + * @param CommandSender $source + * @param TextContainer|string $message + * @param bool $sendToSource */ - public static function broadcastCommandMessage(CommandSender $source, $message, $sendToSource = true){ + public static function broadcastCommandMessage(CommandSender $source, $message, bool $sendToSource = true){ if($message instanceof TextContainer){ $m = clone $message; $result = "[" . $source->getName() . ": " . ($source->getServer()->getLanguage()->get($m->getText()) !== $m->getText() ? "%" : "") . $m->getText() . "]"; @@ -377,7 +377,7 @@ abstract class Command{ /** * @return string */ - public function __toString(){ + public function __toString() : string{ return $this->name; } } diff --git a/src/pocketmine/command/CommandMap.php b/src/pocketmine/command/CommandMap.php index 212384139..8e442fd2b 100644 --- a/src/pocketmine/command/CommandMap.php +++ b/src/pocketmine/command/CommandMap.php @@ -27,17 +27,19 @@ namespace pocketmine\command; interface CommandMap{ /** - * @param string $fallbackPrefix + * @param string $fallbackPrefix * @param Command[] $commands */ - public function registerAll($fallbackPrefix, array $commands); + public function registerAll(string $fallbackPrefix, array $commands); /** - * @param string $fallbackPrefix - * @param Command $command - * @param string $label + * @param string $fallbackPrefix + * @param Command $command + * @param string|null $label + * + * @return */ - public function register($fallbackPrefix, Command $command, $label = null); + public function register(string $fallbackPrefix, Command $command, string $label = null); /** * @param CommandSender $sender @@ -55,9 +57,9 @@ interface CommandMap{ /** * @param string $name * - * @return Command + * @return Command|null */ - public function getCommand($name); + public function getCommand(string $name); } \ No newline at end of file diff --git a/src/pocketmine/command/FormattedCommandAlias.php b/src/pocketmine/command/FormattedCommandAlias.php index 765a5307e..7d728af82 100644 --- a/src/pocketmine/command/FormattedCommandAlias.php +++ b/src/pocketmine/command/FormattedCommandAlias.php @@ -34,12 +34,12 @@ class FormattedCommandAlias extends Command{ * @param string $alias * @param string[] $formatStrings */ - public function __construct($alias, array $formatStrings){ + public function __construct(string $alias, array $formatStrings){ parent::__construct($alias); $this->formatStrings = $formatStrings; } - public function execute(CommandSender $sender, $commandLabel, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ $commands = []; $result = false; @@ -71,9 +71,8 @@ class FormattedCommandAlias extends Command{ * @param array $args * * @return string - * @throws \InvalidArgumentException */ - private function buildCommand($formatString, array $args){ + private function buildCommand(string $formatString, array $args) : string{ $index = strpos($formatString, '$'); while($index !== false){ $start = $index; @@ -153,7 +152,7 @@ class FormattedCommandAlias extends Command{ * * @return bool */ - private static function inRange($i, $j, $k){ + private static function inRange(int $i, int $j, int $k) : bool{ return $i >= $j and $i <= $k; } diff --git a/src/pocketmine/command/PluginCommand.php b/src/pocketmine/command/PluginCommand.php index b90bd2a14..59a1eb17e 100644 --- a/src/pocketmine/command/PluginCommand.php +++ b/src/pocketmine/command/PluginCommand.php @@ -45,7 +45,7 @@ class PluginCommand extends Command implements PluginIdentifiableCommand{ $this->usageMessage = ""; } - public function execute(CommandSender $sender, $commandLabel, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->owningPlugin->isEnabled()){ return false; @@ -64,7 +64,7 @@ class PluginCommand extends Command implements PluginIdentifiableCommand{ return $success; } - public function getExecutor(){ + public function getExecutor() : CommandExecutor{ return $this->executor; } @@ -78,7 +78,7 @@ class PluginCommand extends Command implements PluginIdentifiableCommand{ /** * @return Plugin */ - public function getPlugin(){ + public function getPlugin() : Plugin{ return $this->owningPlugin; } } diff --git a/src/pocketmine/command/PluginIdentifiableCommand.php b/src/pocketmine/command/PluginIdentifiableCommand.php index 081da9f8a..035bdc327 100644 --- a/src/pocketmine/command/PluginIdentifiableCommand.php +++ b/src/pocketmine/command/PluginIdentifiableCommand.php @@ -30,5 +30,5 @@ interface PluginIdentifiableCommand{ /** * @return Plugin */ - public function getPlugin(); + public function getPlugin() : Plugin; } diff --git a/src/pocketmine/command/SimpleCommandMap.php b/src/pocketmine/command/SimpleCommandMap.php index 99bd90393..1e7d13d05 100644 --- a/src/pocketmine/command/SimpleCommandMap.php +++ b/src/pocketmine/command/SimpleCommandMap.php @@ -131,13 +131,13 @@ class SimpleCommandMap implements CommandMap{ } - public function registerAll($fallbackPrefix, array $commands){ + public function registerAll(string $fallbackPrefix, array $commands){ foreach($commands as $command){ $this->register($fallbackPrefix, $command); } } - public function register($fallbackPrefix, Command $command, $label = null){ + public function register(string $fallbackPrefix, Command $command, string $label = null){ if($label === null){ $label = $command->getName(); } @@ -241,7 +241,7 @@ class SimpleCommandMap implements CommandMap{ $this->setDefaultCommands(); } - public function getCommand($name){ + public function getCommand(string $name){ return $this->knownCommands[$name] ?? null; } diff --git a/src/pocketmine/command/defaults/BanCommand.php b/src/pocketmine/command/defaults/BanCommand.php index 4188379cf..4ace5acb6 100644 --- a/src/pocketmine/command/defaults/BanCommand.php +++ b/src/pocketmine/command/defaults/BanCommand.php @@ -40,7 +40,7 @@ class BanCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.ban.player"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/BanIpCommand.php b/src/pocketmine/command/defaults/BanIpCommand.php index f86a9e26e..b6ccb496c 100644 --- a/src/pocketmine/command/defaults/BanIpCommand.php +++ b/src/pocketmine/command/defaults/BanIpCommand.php @@ -40,7 +40,7 @@ class BanIpCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.ban.ip"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/BanListCommand.php b/src/pocketmine/command/defaults/BanListCommand.php index 09000b798..b609abf3a 100644 --- a/src/pocketmine/command/defaults/BanListCommand.php +++ b/src/pocketmine/command/defaults/BanListCommand.php @@ -39,7 +39,7 @@ class BanListCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.ban.list"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/DefaultGamemodeCommand.php b/src/pocketmine/command/defaults/DefaultGamemodeCommand.php index 63dde0d92..be4539aa2 100644 --- a/src/pocketmine/command/defaults/DefaultGamemodeCommand.php +++ b/src/pocketmine/command/defaults/DefaultGamemodeCommand.php @@ -39,7 +39,7 @@ class DefaultGamemodeCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.defaultgamemode"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/DeopCommand.php b/src/pocketmine/command/defaults/DeopCommand.php index d0c1dc7ac..9f71fb91a 100644 --- a/src/pocketmine/command/defaults/DeopCommand.php +++ b/src/pocketmine/command/defaults/DeopCommand.php @@ -41,7 +41,7 @@ class DeopCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.op.take"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/DifficultyCommand.php b/src/pocketmine/command/defaults/DifficultyCommand.php index 4a6d3335a..b11832f34 100644 --- a/src/pocketmine/command/defaults/DifficultyCommand.php +++ b/src/pocketmine/command/defaults/DifficultyCommand.php @@ -41,7 +41,7 @@ class DifficultyCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.difficulty"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/DumpMemoryCommand.php b/src/pocketmine/command/defaults/DumpMemoryCommand.php index 4b083d5aa..593533ea1 100644 --- a/src/pocketmine/command/defaults/DumpMemoryCommand.php +++ b/src/pocketmine/command/defaults/DumpMemoryCommand.php @@ -38,7 +38,7 @@ class DumpMemoryCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.dumpmemory"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/EffectCommand.php b/src/pocketmine/command/defaults/EffectCommand.php index db0a15ced..51b185d69 100644 --- a/src/pocketmine/command/defaults/EffectCommand.php +++ b/src/pocketmine/command/defaults/EffectCommand.php @@ -40,7 +40,7 @@ class EffectCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.effect"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/EnchantCommand.php b/src/pocketmine/command/defaults/EnchantCommand.php index b4244754d..34bc2f631 100644 --- a/src/pocketmine/command/defaults/EnchantCommand.php +++ b/src/pocketmine/command/defaults/EnchantCommand.php @@ -40,7 +40,7 @@ class EnchantCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.enchant"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/GamemodeCommand.php b/src/pocketmine/command/defaults/GamemodeCommand.php index c297cece0..f66f73657 100644 --- a/src/pocketmine/command/defaults/GamemodeCommand.php +++ b/src/pocketmine/command/defaults/GamemodeCommand.php @@ -42,7 +42,7 @@ class GamemodeCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.gamemode"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/GarbageCollectorCommand.php b/src/pocketmine/command/defaults/GarbageCollectorCommand.php index b39c53fd7..526482d85 100644 --- a/src/pocketmine/command/defaults/GarbageCollectorCommand.php +++ b/src/pocketmine/command/defaults/GarbageCollectorCommand.php @@ -37,7 +37,7 @@ class GarbageCollectorCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.gc"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/GiveCommand.php b/src/pocketmine/command/defaults/GiveCommand.php index 3b5219b61..27093f893 100644 --- a/src/pocketmine/command/defaults/GiveCommand.php +++ b/src/pocketmine/command/defaults/GiveCommand.php @@ -44,7 +44,7 @@ class GiveCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.give"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/HelpCommand.php b/src/pocketmine/command/defaults/HelpCommand.php index 761e727de..8ef199937 100644 --- a/src/pocketmine/command/defaults/HelpCommand.php +++ b/src/pocketmine/command/defaults/HelpCommand.php @@ -41,7 +41,7 @@ class HelpCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.help"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/KickCommand.php b/src/pocketmine/command/defaults/KickCommand.php index 35b8d5060..7368b4276 100644 --- a/src/pocketmine/command/defaults/KickCommand.php +++ b/src/pocketmine/command/defaults/KickCommand.php @@ -41,7 +41,7 @@ class KickCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.kick"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/KillCommand.php b/src/pocketmine/command/defaults/KillCommand.php index 9934683cb..1e772ae2d 100644 --- a/src/pocketmine/command/defaults/KillCommand.php +++ b/src/pocketmine/command/defaults/KillCommand.php @@ -43,7 +43,7 @@ class KillCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.kill.self;pocketmine.command.kill.other"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/ListCommand.php b/src/pocketmine/command/defaults/ListCommand.php index 550347b7e..edc483982 100644 --- a/src/pocketmine/command/defaults/ListCommand.php +++ b/src/pocketmine/command/defaults/ListCommand.php @@ -38,7 +38,7 @@ class ListCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.list"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/MeCommand.php b/src/pocketmine/command/defaults/MeCommand.php index 0fdb4b79b..380b7f93b 100644 --- a/src/pocketmine/command/defaults/MeCommand.php +++ b/src/pocketmine/command/defaults/MeCommand.php @@ -40,7 +40,7 @@ class MeCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.me"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/OpCommand.php b/src/pocketmine/command/defaults/OpCommand.php index 2e6104268..0000f8410 100644 --- a/src/pocketmine/command/defaults/OpCommand.php +++ b/src/pocketmine/command/defaults/OpCommand.php @@ -41,7 +41,7 @@ class OpCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.op.give"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/PardonCommand.php b/src/pocketmine/command/defaults/PardonCommand.php index 878171815..c0b97ae7d 100644 --- a/src/pocketmine/command/defaults/PardonCommand.php +++ b/src/pocketmine/command/defaults/PardonCommand.php @@ -39,7 +39,7 @@ class PardonCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.unban.player"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/PardonIpCommand.php b/src/pocketmine/command/defaults/PardonIpCommand.php index e92be4f97..76cc5544f 100644 --- a/src/pocketmine/command/defaults/PardonIpCommand.php +++ b/src/pocketmine/command/defaults/PardonIpCommand.php @@ -39,7 +39,7 @@ class PardonIpCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.unban.ip"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/ParticleCommand.php b/src/pocketmine/command/defaults/ParticleCommand.php index 685cc4f42..61e405dc9 100644 --- a/src/pocketmine/command/defaults/ParticleCommand.php +++ b/src/pocketmine/command/defaults/ParticleCommand.php @@ -72,7 +72,7 @@ class ParticleCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.particle"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/PluginsCommand.php b/src/pocketmine/command/defaults/PluginsCommand.php index 804a15338..a43d06d29 100644 --- a/src/pocketmine/command/defaults/PluginsCommand.php +++ b/src/pocketmine/command/defaults/PluginsCommand.php @@ -39,7 +39,7 @@ class PluginsCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.plugins"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/ReloadCommand.php b/src/pocketmine/command/defaults/ReloadCommand.php index e8a4b1c3e..0097c30cb 100644 --- a/src/pocketmine/command/defaults/ReloadCommand.php +++ b/src/pocketmine/command/defaults/ReloadCommand.php @@ -39,7 +39,7 @@ class ReloadCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.reload"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/SaveCommand.php b/src/pocketmine/command/defaults/SaveCommand.php index b37ee0eee..5631e99d6 100644 --- a/src/pocketmine/command/defaults/SaveCommand.php +++ b/src/pocketmine/command/defaults/SaveCommand.php @@ -38,7 +38,7 @@ class SaveCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.save.perform"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/SaveOffCommand.php b/src/pocketmine/command/defaults/SaveOffCommand.php index 33fa17dd0..2aba6c39c 100644 --- a/src/pocketmine/command/defaults/SaveOffCommand.php +++ b/src/pocketmine/command/defaults/SaveOffCommand.php @@ -38,7 +38,7 @@ class SaveOffCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.save.disable"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/SaveOnCommand.php b/src/pocketmine/command/defaults/SaveOnCommand.php index 8220774a9..bfe8aff7e 100644 --- a/src/pocketmine/command/defaults/SaveOnCommand.php +++ b/src/pocketmine/command/defaults/SaveOnCommand.php @@ -38,7 +38,7 @@ class SaveOnCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.save.enable"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/SayCommand.php b/src/pocketmine/command/defaults/SayCommand.php index a7ed1d4b1..16960b246 100644 --- a/src/pocketmine/command/defaults/SayCommand.php +++ b/src/pocketmine/command/defaults/SayCommand.php @@ -41,7 +41,7 @@ class SayCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.say"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/SeedCommand.php b/src/pocketmine/command/defaults/SeedCommand.php index b6d8a915d..5d3edbcdf 100644 --- a/src/pocketmine/command/defaults/SeedCommand.php +++ b/src/pocketmine/command/defaults/SeedCommand.php @@ -38,7 +38,7 @@ class SeedCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.seed"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/SetWorldSpawnCommand.php b/src/pocketmine/command/defaults/SetWorldSpawnCommand.php index 0ea724408..228dcf8fa 100644 --- a/src/pocketmine/command/defaults/SetWorldSpawnCommand.php +++ b/src/pocketmine/command/defaults/SetWorldSpawnCommand.php @@ -42,7 +42,7 @@ class SetWorldSpawnCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.setworldspawn"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/SpawnpointCommand.php b/src/pocketmine/command/defaults/SpawnpointCommand.php index b0e3b194b..9b35625ee 100644 --- a/src/pocketmine/command/defaults/SpawnpointCommand.php +++ b/src/pocketmine/command/defaults/SpawnpointCommand.php @@ -43,7 +43,7 @@ class SpawnpointCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.spawnpoint"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/StatusCommand.php b/src/pocketmine/command/defaults/StatusCommand.php index 551a49e46..621b90771 100644 --- a/src/pocketmine/command/defaults/StatusCommand.php +++ b/src/pocketmine/command/defaults/StatusCommand.php @@ -38,7 +38,7 @@ class StatusCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.status"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/StopCommand.php b/src/pocketmine/command/defaults/StopCommand.php index c4e25a2e8..67c66be90 100644 --- a/src/pocketmine/command/defaults/StopCommand.php +++ b/src/pocketmine/command/defaults/StopCommand.php @@ -38,7 +38,7 @@ class StopCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.stop"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/TeleportCommand.php b/src/pocketmine/command/defaults/TeleportCommand.php index 874995287..9eed0a972 100644 --- a/src/pocketmine/command/defaults/TeleportCommand.php +++ b/src/pocketmine/command/defaults/TeleportCommand.php @@ -42,7 +42,7 @@ class TeleportCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.teleport"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/TellCommand.php b/src/pocketmine/command/defaults/TellCommand.php index 3b51993e6..ab89cc422 100644 --- a/src/pocketmine/command/defaults/TellCommand.php +++ b/src/pocketmine/command/defaults/TellCommand.php @@ -41,7 +41,7 @@ class TellCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.tell"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/TimeCommand.php b/src/pocketmine/command/defaults/TimeCommand.php index 5c559734a..8c7f1ccb1 100644 --- a/src/pocketmine/command/defaults/TimeCommand.php +++ b/src/pocketmine/command/defaults/TimeCommand.php @@ -42,7 +42,7 @@ class TimeCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.time.add;pocketmine.command.time.set;pocketmine.command.time.start;pocketmine.command.time.stop"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(count($args) < 1){ throw new InvalidCommandSyntaxException(); } diff --git a/src/pocketmine/command/defaults/TimingsCommand.php b/src/pocketmine/command/defaults/TimingsCommand.php index 142bc9788..ec4315d2b 100644 --- a/src/pocketmine/command/defaults/TimingsCommand.php +++ b/src/pocketmine/command/defaults/TimingsCommand.php @@ -44,7 +44,7 @@ class TimingsCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.timings"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/TitleCommand.php b/src/pocketmine/command/defaults/TitleCommand.php index a2038518d..9f9b42ba4 100644 --- a/src/pocketmine/command/defaults/TitleCommand.php +++ b/src/pocketmine/command/defaults/TitleCommand.php @@ -38,7 +38,7 @@ class TitleCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.title"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/TransferServerCommand.php b/src/pocketmine/command/defaults/TransferServerCommand.php index 5925a96dc..b4db230c4 100644 --- a/src/pocketmine/command/defaults/TransferServerCommand.php +++ b/src/pocketmine/command/defaults/TransferServerCommand.php @@ -40,7 +40,7 @@ class TransferServerCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.transferserver"); } - public function execute(CommandSender $sender, $commandLabel, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(count($args) < 1){ throw new InvalidCommandSyntaxException(); }elseif(!($sender instanceof Player)){ diff --git a/src/pocketmine/command/defaults/VersionCommand.php b/src/pocketmine/command/defaults/VersionCommand.php index e48356fd5..c3dba9064 100644 --- a/src/pocketmine/command/defaults/VersionCommand.php +++ b/src/pocketmine/command/defaults/VersionCommand.php @@ -41,7 +41,7 @@ class VersionCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.version"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/command/defaults/WhitelistCommand.php b/src/pocketmine/command/defaults/WhitelistCommand.php index 8bb8e95e5..a012508e2 100644 --- a/src/pocketmine/command/defaults/WhitelistCommand.php +++ b/src/pocketmine/command/defaults/WhitelistCommand.php @@ -40,7 +40,7 @@ class WhitelistCommand extends VanillaCommand{ $this->setPermission("pocketmine.command.whitelist.reload;pocketmine.command.whitelist.enable;pocketmine.command.whitelist.disable;pocketmine.command.whitelist.list;pocketmine.command.whitelist.add;pocketmine.command.whitelist.remove"); } - public function execute(CommandSender $sender, $currentAlias, array $args){ + public function execute(CommandSender $sender, string $commandLabel, array $args){ if(!$this->testPermission($sender)){ return true; } diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index d344ccccc..5d6b4a5c4 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -626,7 +626,13 @@ class PluginManager{ } if(isset($data["permission"])){ - $newCmd->setPermission($data["permission"]); + if(is_bool($data["permission"])){ + $newCmd->setPermission($data["permission"] ? "true" : "false"); + }elseif(is_string($data["permission"])){ + $newCmd->setPermission($data["permission"]); + }else{ + throw new \InvalidArgumentException("Permission must be a string or boolean, " . gettype($data["permission"] . " given")); + } } if(isset($data["permission-message"])){