13declare(strict_types=1);
15namespace pocketmine\network\mcpe\protocol;
22 public const NETWORK_ID = ProtocolInfo::SET_SCORE_PACKET;
24 public const TYPE_CHANGE = 0;
25 public const TYPE_REMOVE = 1;
29 public array $entries = [];
35 public static function create(
int $type, array $entries) : self{
37 $result->type = $type;
38 $result->entries = $entries;
43 $this->type = $in->getByte();
49 if($this->type !== self::TYPE_REMOVE){
52 case ScorePacketEntry::TYPE_PLAYER:
53 case ScorePacketEntry::TYPE_ENTITY:
56 case ScorePacketEntry::TYPE_FAKE_PLAYER:
63 $this->entries[] = $entry;
68 $out->putByte($this->type);
70 foreach($this->entries as $entry){
72 $out->putString($entry->objectiveName);
73 $out->putLInt($entry->score);
74 if($this->type !== self::TYPE_REMOVE){
75 $out->putByte($entry->type);
77 case ScorePacketEntry::TYPE_PLAYER:
78 case ScorePacketEntry::TYPE_ENTITY:
79 $out->putActorUniqueId($entry->actorUniqueId);
81 case ScorePacketEntry::TYPE_FAKE_PLAYER:
82 $out->putString($entry->customName);
85 throw new \InvalidArgumentException(
"Unknown entry type $entry->type");
92 return $handler->handleSetScore($this);
decodePayload(PacketSerializer $in)
static create(int $type, array $entries)
encodePayload(PacketSerializer $out)
handle(PacketHandlerInterface $handler)
putUnsignedVarInt(int $v)