0
0
mirror of https://github.com/pmmp/BedrockProtocol.git synced 2025-08-15 23:02:54 +00:00
Files
BedrockProtocol/src/PurchaseReceiptPacket.php
2022-01-10 21:21:59 +00:00

54 lines
1.4 KiB
PHP

<?php
/*
* This file is part of BedrockProtocol.
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
*
* BedrockProtocol is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use function count;
class PurchaseReceiptPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::PURCHASE_RECEIPT_PACKET;
/** @var string[] */
public array $entries = [];
/**
* @generate-create-func
* @param string[] $entries
*/
public static function create(array $entries) : self{
$result = new self;
$result->entries = $entries;
return $result;
}
protected function decodePayload(PacketSerializer $in) : void{
$count = $in->getUnsignedVarInt();
for($i = 0; $i < $count; ++$i){
$this->entries[] = $in->getString();
}
}
protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt(count($this->entries));
foreach($this->entries as $entry){
$out->putString($entry);
}
}
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handlePurchaseReceipt($this);
}
}