Resend command data when op status changes

This commit is contained in:
Dylan K. Taylor 2016-10-06 13:19:40 +01:00
parent 018897062c
commit 192fba9c88

View File

@ -440,6 +440,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
}
$this->recalculatePermissions();
$this->sendCommandData();
}
/**
@ -503,6 +504,19 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
return $this->perm->getEffectivePermissions();
}
public function sendCommandData(){
$pk = new AvailableCommandsPacket();
$data = [];
foreach($this->server->getCommandMap()->getCommands() as $command){
$data[$command->getName()] = $command->generateJsonData($this);
}
if(count($data) > 0){
//TODO: structure checking
$pk->commands = json_encode($data);
$this->dataPacket($pk);
}
}
/**
* @param SourceInterface $interface
* @param null $clientID
@ -1713,14 +1727,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
if($this->isOp()){
$this->setRemoveFormat(false);
}
$pk = new AvailableCommandsPacket();
$data = [];
foreach($this->server->getCommandMap()->getCommands() as $command){
$data[$command->getName()] = $command->generateJsonData($this);
}
$pk->commands = json_encode($data);
$this->dataPacket($pk);
$this->sendCommandData();
if($this->isCreative()){
$this->inventory->sendCreativeContents();