Accept null for targets in Human->sendSkin()

For humans, it'll send to all viewers. For players, it'll send to all viewers, and the player itself.
This commit is contained in:
Dylan K. Taylor 2017-10-29 11:18:34 +00:00
parent f79e4237df
commit 600d80331a
2 changed files with 20 additions and 3 deletions

View File

@ -762,6 +762,20 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
return true;
}
/**
* {@inheritdoc}
*
* If null is given, will additionally send the skin to the player itself as well as its viewers.
*/
public function sendSkin(array $targets = null) : void{
if($targets === null){
$targets = $this->hasSpawned;
$targets[] = $this;
}
parent::sendSkin($targets);
}
/**
* Gets the player IP address
*

View File

@ -129,13 +129,16 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
}
/**
* @param Player[] $targets
* Sends the human's skin to the specified list of players. If null is given for targets, the skin will be sent to
* all viewers.
*
* @param Player[]|null $targets
*/
public function sendSkin(array $targets) : void{
public function sendSkin(array $targets = null) : void{
$pk = new PlayerSkinPacket();
$pk->uuid = $this->getUniqueId();
$pk->skin = $this->skin;
$this->server->broadcastPacket($targets, $pk);
$this->server->broadcastPacket($targets ?? $this->hasSpawned, $pk);
}
public function jump(){