Use assoc instead of object for command data, fix data modifications affecting all commands

how did I do manage to do somthing this stupid -_- smh what an idiot
Lucky permission is a root node, or the whole commands system would've been compromised. Epic fail.
This commit is contained in:
Dylan K. Taylor
2017-03-14 11:39:59 +00:00
parent 3138e02acb
commit d26713ab59
2 changed files with 32 additions and 28 deletions

View File

@ -534,16 +534,14 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
}
public function sendCommandData(){
$data = new \stdClass();
$count = 0;
$data = [];
foreach($this->server->getCommandMap()->getCommands() as $command){
if(($cmdData = $command->generateCustomCommandData($this)) !== null){
++$count;
$data->{$command->getName()}->versions[0] = $cmdData;
if(count($cmdData = $command->generateCustomCommandData($this)) > 0){
$data[$command->getName()]["versions"][0] = $cmdData;
}
}
if($count > 0){
if(count($data) > 0){
//TODO: structure checking
$pk = new AvailableCommandsPacket();
$pk->commands = json_encode($data);