PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
RequestPermissionsPacket.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\ByteBufferReader;
18use pmmp\encoding\ByteBufferWriter;
19use pmmp\encoding\LE;
20use pmmp\encoding\VarInt;
22
28 public const NETWORK_ID = ProtocolInfo::REQUEST_PERMISSIONS_PACKET;
29
30 public const FLAG_BUILD = 1 << 0;
31 public const FLAG_MINE = 1 << 1;
32 public const FLAG_DOORS_AND_SWITCHES = 1 << 2;
33 public const FLAG_OPEN_CONTAINERS = 1 << 3;
34 public const FLAG_ATTACK_PLAYERS = 1 << 4;
35 public const FLAG_ATTACK_MOBS = 1 << 5;
36 public const FLAG_OPERATOR = 1 << 6;
37 public const FLAG_TELEPORT = 1 << 7;
38
39 private int $targetActorUniqueId;
41 private int $playerPermission;
42 private int $customFlags;
43
47 public static function create(int $targetActorUniqueId, int $playerPermission, int $customFlags) : self{
48 $result = new self;
49 $result->targetActorUniqueId = $targetActorUniqueId;
50 $result->playerPermission = $playerPermission;
51 $result->customFlags = $customFlags;
52 return $result;
53 }
54
55 public function getTargetActorUniqueId() : int{ return $this->targetActorUniqueId; }
56
58 public function getPlayerPermission() : int{ return $this->playerPermission; }
59
60 public function getCustomFlags() : int{ return $this->customFlags; }
61
62 protected function decodePayload(ByteBufferReader $in) : void{
63 $this->targetActorUniqueId = LE::readSignedLong($in);
64 $this->playerPermission = VarInt::readSignedInt($in);
65 $this->customFlags = LE::readUnsignedShort($in);
66 }
67
68 protected function encodePayload(ByteBufferWriter $out) : void{
69 LE::writeSignedLong($out, $this->targetActorUniqueId);
70 VarInt::writeSignedInt($out, $this->playerPermission);
71 LE::writeUnsignedShort($out, $this->customFlags);
72 }
73
74 public function handle(PacketHandlerInterface $handler) : bool{
75 return $handler->handleRequestPermissions($this);
76 }
77}
static create(int $targetActorUniqueId, int $playerPermission, int $customFlags)