PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
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
17use pmmp\encoding\Byte;
18use pmmp\encoding\ByteBufferReader;
19use pmmp\encoding\ByteBufferWriter;
20use pmmp\encoding\LE;
22
24 public const NETWORK_ID = ProtocolInfo::PHOTO_TRANSFER_PACKET;
25
26 public string $photoName;
27 public string $photoData;
28 public string $bookId; //photos are stored in a sibling directory to the games folder (screenshots/(some UUID)/bookID/example.png)
29 public int $type;
30 public int $sourceType;
31 public int $ownerActorUniqueId;
32 public string $newPhotoName; //???
33
37 public static function create(
38 string $photoName,
39 string $photoData,
40 string $bookId,
41 int $type,
42 int $sourceType,
43 int $ownerActorUniqueId,
44 string $newPhotoName,
45 ) : self{
46 $result = new self;
47 $result->photoName = $photoName;
48 $result->photoData = $photoData;
49 $result->bookId = $bookId;
50 $result->type = $type;
51 $result->sourceType = $sourceType;
52 $result->ownerActorUniqueId = $ownerActorUniqueId;
53 $result->newPhotoName = $newPhotoName;
54 return $result;
55 }
56
57 protected function decodePayload(ByteBufferReader $in) : void{
58 $this->photoName = CommonTypes::getString($in);
59 $this->photoData = CommonTypes::getString($in);
60 $this->bookId = CommonTypes::getString($in);
61 $this->type = Byte::readUnsigned($in);
62 $this->sourceType = Byte::readUnsigned($in);
63 $this->ownerActorUniqueId = LE::readSignedLong($in); //...............
64 $this->newPhotoName = CommonTypes::getString($in);
65 }
66
67 protected function encodePayload(ByteBufferWriter $out) : void{
68 CommonTypes::putString($out, $this->photoName);
69 CommonTypes::putString($out, $this->photoData);
70 CommonTypes::putString($out, $this->bookId);
71 Byte::writeUnsigned($out, $this->type);
72 Byte::writeUnsigned($out, $this->sourceType);
73 LE::writeSignedLong($out, $this->ownerActorUniqueId);
74 CommonTypes::putString($out, $this->newPhotoName);
75 }
76
77 public function handle(PacketHandlerInterface $handler) : bool{
78 return $handler->handlePhotoTransfer($this);
79 }
80}
static create(string $photoName, string $photoData, string $bookId, int $type, int $sourceType, int $ownerActorUniqueId, string $newPhotoName,)