mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Added static create() functions for many packets
There are a few motivations here: 1) Less boilerplate code (this can be written inline) 2) It's possible to provide multiple constructors for different packet variations to reduce the chance of errors. 3) It makes things catch fire on updates in ways that static analysers can understand.
This commit is contained in:
@ -84,20 +84,14 @@ class FloatingTextParticle implements Particle{
|
||||
if($this->entityId === null){
|
||||
$this->entityId = EntityFactory::nextRuntimeId();
|
||||
}else{
|
||||
$pk0 = new RemoveEntityPacket();
|
||||
$pk0->entityUniqueId = $this->entityId;
|
||||
|
||||
$p[] = $pk0;
|
||||
$p[] = RemoveEntityPacket::create($this->entityId);
|
||||
}
|
||||
|
||||
if(!$this->invisible){
|
||||
$uuid = UUID::fromRandom();
|
||||
$name = $this->title . ($this->text !== "" ? "\n" . $this->text : "");
|
||||
|
||||
$add = new PlayerListPacket();
|
||||
$add->type = PlayerListPacket::TYPE_ADD;
|
||||
$add->entries = [PlayerListEntry::createAdditionEntry($uuid, $this->entityId, $name, new Skin("Standard_Custom", str_repeat("\x00", 8192)))];
|
||||
$p[] = $add;
|
||||
$p[] = PlayerListPacket::add([PlayerListEntry::createAdditionEntry($uuid, $this->entityId, $name, new Skin("Standard_Custom", str_repeat("\x00", 8192)))]);
|
||||
|
||||
$pk = new AddPlayerPacket();
|
||||
$pk->uuid = $uuid;
|
||||
@ -116,10 +110,7 @@ class FloatingTextParticle implements Particle{
|
||||
|
||||
$p[] = $pk;
|
||||
|
||||
$remove = new PlayerListPacket();
|
||||
$remove->type = PlayerListPacket::TYPE_REMOVE;
|
||||
$remove->entries = [PlayerListEntry::createRemovalEntry($uuid)];
|
||||
$p[] = $remove;
|
||||
$p[] = PlayerListPacket::remove([PlayerListEntry::createRemovalEntry($uuid)]);
|
||||
}
|
||||
|
||||
return $p;
|
||||
|
Reference in New Issue
Block a user