diff --git a/src/pocketmine/command/Command.php b/src/pocketmine/command/Command.php index 55a8d0ad5..f498f7891 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -34,8 +34,6 @@ use pocketmine\Server; use pocketmine\utils\TextFormat; abstract class Command{ - /** @var array */ - private static $defaultDataTemplate = null; /** @var string */ private $name; @@ -48,6 +46,9 @@ abstract class Command{ /** @var string */ private $label; + /** @var string[] */ + private $aliases = []; + /** * @var string[] */ @@ -62,6 +63,9 @@ abstract class Command{ /** @var string */ protected $usageMessage; + /** @var string|null */ + private $permission = null; + /** @var string */ private $permissionMessage = null; @@ -75,7 +79,6 @@ abstract class Command{ * @param string[] $aliases */ public function __construct(string $name, string $description = "", string $usageMessage = null, array $aliases = []){ - $this->commandData = self::generateDefaultData(); $this->name = $name; $this->setLabel($name); $this->setDescription($description); @@ -83,45 +86,6 @@ abstract class Command{ $this->setAliases($aliases); } - /** - * Returns an array containing command data - * - * @return array - */ - public function getDefaultCommandData() : array{ - return $this->commandData; - } - - /** - * Generates modified command data for the specified player - * for AvailableCommandsPacket. - * - * @param Player $player - * - * @return array - */ - public function generateCustomCommandData(Player $player) : array{ - //TODO: fix command permission filtering on join - /*if(!$this->testPermissionSilent($player)){ - return null; - }*/ - $customData = $this->commandData; - $customData["aliases"] = $this->getAliases(); - /*foreach($customData["overloads"] as $overloadName => $overload){ - if(isset($overload["pocketminePermission"]) and !$player->hasPermission($overload["pocketminePermission"])){ - unset($customData["overloads"][$overloadName]); - } - }*/ - return $customData; - } - - /** - * @return array - */ - public function getOverloads() : array{ - return $this->commandData["overloads"]; - } - /** * @param CommandSender $sender * @param string $commandLabel @@ -142,7 +106,7 @@ abstract class Command{ * @return string|null */ public function getPermission(){ - return $this->commandData["pocketminePermission"] ?? null; + return $this->permission; } @@ -150,11 +114,7 @@ abstract class Command{ * @param string|null $permission */ public function setPermission(string $permission = null){ - if($permission !== null){ - $this->commandData["pocketminePermission"] = $permission; - }else{ - unset($this->commandData["pocketminePermission"]); - } + $this->permission = $permission; } /** @@ -242,7 +202,7 @@ abstract class Command{ public function unregister(CommandMap $commandMap) : bool{ if($this->allowChangesFrom($commandMap)){ $this->commandMap = null; - $this->activeAliases = $this->commandData["aliases"]; + $this->activeAliases = $this->aliases; $this->label = $this->nextLabel; return true; @@ -285,7 +245,7 @@ abstract class Command{ * @return string */ public function getDescription() : string{ - return $this->commandData["description"]; + return $this->description; } /** @@ -299,9 +259,9 @@ abstract class Command{ * @param string[] $aliases */ public function setAliases(array $aliases){ - $this->commandData["aliases"] = $aliases; + $this->aliases = $aliases; if(!$this->isRegistered()){ - $this->activeAliases = (array) $aliases; + $this->activeAliases = $aliases; } } @@ -309,7 +269,7 @@ abstract class Command{ * @param string $description */ public function setDescription(string $description){ - $this->commandData["description"] = $description; + $this->description = $description; } /** @@ -326,16 +286,6 @@ abstract class Command{ $this->usageMessage = $usage; } - /** - * @return array - */ - final public static function generateDefaultData() : array{ - if(self::$defaultDataTemplate === null){ - self::$defaultDataTemplate = json_decode(file_get_contents(Server::getInstance()->getFilePath() . "src/pocketmine/resources/command_default.json"), true); - } - return self::$defaultDataTemplate; - } - /** * @param CommandSender $source * @param TextContainer|string $message diff --git a/src/pocketmine/resources/command_default.json b/src/pocketmine/resources/command_default.json deleted file mode 100644 index 3d8c2c339..000000000 --- a/src/pocketmine/resources/command_default.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "aliases": [], - "description": "insert_description_here", - "overloads": { - "default": { - "input": { - "parameters": [ - { - "name": "args", - "type": "rawtext", - "optional": true - } - ] - }, - "output": {} - } - }, - "permission": "any" -}