PocketMine-MP 5.17.1 git-df4ada81e5d74a14046f27cf44a37dcee69d657e
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
19
25 public const NETWORK_ID = ProtocolInfo::REQUEST_PERMISSIONS_PACKET;
26
27 public const FLAG_BUILD = 1 << 0;
28 public const FLAG_MINE = 1 << 1;
29 public const FLAG_DOORS_AND_SWITCHES = 1 << 2;
30 public const FLAG_OPEN_CONTAINERS = 1 << 3;
31 public const FLAG_ATTACK_PLAYERS = 1 << 4;
32 public const FLAG_ATTACK_MOBS = 1 << 5;
33 public const FLAG_OPERATOR = 1 << 6;
34 public const FLAG_TELEPORT = 1 << 7;
35
36 private int $targetActorUniqueId;
38 private int $playerPermission;
39 private int $customFlags;
40
44 public static function create(int $targetActorUniqueId, int $playerPermission, int $customFlags) : self{
45 $result = new self;
46 $result->targetActorUniqueId = $targetActorUniqueId;
47 $result->playerPermission = $playerPermission;
48 $result->customFlags = $customFlags;
49 return $result;
50 }
51
52 public function getTargetActorUniqueId() : int{ return $this->targetActorUniqueId; }
53
55 public function getPlayerPermission() : int{ return $this->playerPermission; }
56
57 public function getCustomFlags() : int{ return $this->customFlags; }
58
59 protected function decodePayload(PacketSerializer $in) : void{
60 $this->targetActorUniqueId = $in->getLLong();
61 $this->playerPermission = $in->getVarInt();
62 $this->customFlags = $in->getLShort();
63 }
64
65 protected function encodePayload(PacketSerializer $out) : void{
66 $out->putLLong($this->targetActorUniqueId);
67 $out->putVarInt($this->playerPermission);
68 $out->putLShort($this->customFlags);
69 }
70
71 public function handle(PacketHandlerInterface $handler) : bool{
72 return $handler->handleRequestPermissions($this);
73 }
74}
static create(int $targetActorUniqueId, int $playerPermission, int $customFlags)