Fixed player list self-duplication

This commit is contained in:
Dylan K. Taylor 2017-05-02 11:18:32 +01:00
parent 6d90f91be0
commit f889bf9cf5
3 changed files with 21 additions and 5 deletions

View File

@ -2199,9 +2199,6 @@ class Server{
$pk = new PlayerListPacket();
$pk->type = PlayerListPacket::TYPE_ADD;
foreach($this->playerList as $player){
if($p === $player){
continue; //fixes duplicates
}
$pk->entries[] = [$player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->getSkinId(), $player->getSkinData()];
}

View File

@ -177,11 +177,19 @@ class BinaryStream extends \stdClass{
}
public function getUUID(){
return UUID::fromBinary($this->get(16));
//This is actually two little-endian longs: UUID Most followed by UUID Least
$part1 = $this->getLInt();
$part0 = $this->getLInt();
$part3 = $this->getLInt();
$part2 = $this->getLInt();
return new UUID($part0, $part1, $part2, $part3);
}
public function putUUID(UUID $uuid){
$this->put($uuid->toBinary());
$this->putLInt($uuid->getPart(1));
$this->putLInt($uuid->getPart(0));
$this->putLInt($uuid->getPart(3));
$this->putLInt($uuid->getPart(2));
}
public function getSlot(){

View File

@ -102,4 +102,15 @@ class UUID{
public function __toString(){
return $this->toString();
}
public function getPart(int $partNumber){
if($partNumber < 0 or $partNumber > 3){
throw new \InvalidArgumentException("Invalid UUID part index $partNumber");
}
return $this->parts[$partNumber];
}
public function getParts() : array{
return $this->parts;
}
}