PocketMine-MP 5.37.1 git-cef37e7835c666594588f957a47b27d521c6a58e
Loading...
Searching...
No Matches
ShowStoreOfferPacket.php
1<?php
2
3/*
4 * This file is part of BedrockProtocol.
5 * Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
6 *
7 * BedrockProtocol is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 */
12
13declare(strict_types=1);
14
15namespace pocketmine\network\mcpe\protocol;
16
17use pmmp\encoding\Byte;
18use pmmp\encoding\ByteBufferReader;
19use pmmp\encoding\ByteBufferWriter;
21use pocketmine\network\mcpe\protocol\types\ShowStoreOfferRedirectType;
22use Ramsey\Uuid\UuidInterface;
23
25 public const NETWORK_ID = ProtocolInfo::SHOW_STORE_OFFER_PACKET;
26
27 public UuidInterface $offerId;
28 public ShowStoreOfferRedirectType $redirectType;
29
33 public static function create(UuidInterface $offerId, ShowStoreOfferRedirectType $redirectType) : self{
34 $result = new self;
35 $result->offerId = $offerId;
36 $result->redirectType = $redirectType;
37 return $result;
38 }
39
40 protected function decodePayload(ByteBufferReader $in) : void{
41 $this->offerId = CommonTypes::getUUID($in);
42 $this->redirectType = ShowStoreOfferRedirectType::fromPacket(Byte::readUnsigned($in));
43 }
44
45 protected function encodePayload(ByteBufferWriter $out) : void{
46 CommonTypes::putUUID($out, $this->offerId);
47 Byte::writeUnsigned($out, $this->redirectType->value);
48 }
49
50 public function handle(PacketHandlerInterface $handler) : bool{
51 return $handler->handleShowStoreOffer($this);
52 }
53}
static create(UuidInterface $offerId, ShowStoreOfferRedirectType $redirectType)