PocketMine-MP 5.18.1 git-9381fc4172e5dce4cada1cb356050c8a2ab57b94
PhotoTransferPacket.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
18
20 public const NETWORK_ID = ProtocolInfo::PHOTO_TRANSFER_PACKET;
21
22 public string $photoName;
23 public string $photoData;
24 public string $bookId; //photos are stored in a sibling directory to the games folder (screenshots/(some UUID)/bookID/example.png)
25 public int $type;
26 public int $sourceType;
27 public int $ownerActorUniqueId;
28 public string $newPhotoName; //???
29
33 public static function create(
34 string $photoName,
35 string $photoData,
36 string $bookId,
37 int $type,
38 int $sourceType,
39 int $ownerActorUniqueId,
40 string $newPhotoName,
41 ) : self{
42 $result = new self;
43 $result->photoName = $photoName;
44 $result->photoData = $photoData;
45 $result->bookId = $bookId;
46 $result->type = $type;
47 $result->sourceType = $sourceType;
48 $result->ownerActorUniqueId = $ownerActorUniqueId;
49 $result->newPhotoName = $newPhotoName;
50 return $result;
51 }
52
53 protected function decodePayload(PacketSerializer $in) : void{
54 $this->photoName = $in->getString();
55 $this->photoData = $in->getString();
56 $this->bookId = $in->getString();
57 $this->type = $in->getByte();
58 $this->sourceType = $in->getByte();
59 $this->ownerActorUniqueId = $in->getLLong(); //...............
60 $this->newPhotoName = $in->getString();
61 }
62
63 protected function encodePayload(PacketSerializer $out) : void{
64 $out->putString($this->photoName);
65 $out->putString($this->photoData);
66 $out->putString($this->bookId);
67 $out->putByte($this->type);
68 $out->putByte($this->sourceType);
69 $out->putLLong($this->ownerActorUniqueId);
70 $out->putString($this->newPhotoName);
71 }
72
73 public function handle(PacketHandlerInterface $handler) : bool{
74 return $handler->handlePhotoTransfer($this);
75 }
76}
static create(string $photoName, string $photoData, string $bookId, int $type, int $sourceType, int $ownerActorUniqueId, string $newPhotoName,)