PocketMine-MP 5.18.1 git-9381fc4172e5dce4cada1cb356050c8a2ab57b94
EmotePacket.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::EMOTE_PACKET;
21
22 public const FLAG_SERVER = 1 << 0;
23 public const FLAG_MUTE_ANNOUNCEMENT = 1 << 1;
24
25 private int $actorRuntimeId;
26 private string $emoteId;
27 private string $xboxUserId;
28 private string $platformChatId;
29 private int $flags;
30
34 public static function create(int $actorRuntimeId, string $emoteId, string $xboxUserId, string $platformChatId, int $flags) : self{
35 $result = new self;
36 $result->actorRuntimeId = $actorRuntimeId;
37 $result->emoteId = $emoteId;
38 $result->xboxUserId = $xboxUserId;
39 $result->platformChatId = $platformChatId;
40 $result->flags = $flags;
41 return $result;
42 }
43
44 public function getActorRuntimeId() : int{
45 return $this->actorRuntimeId;
46 }
47
48 public function getEmoteId() : string{
49 return $this->emoteId;
50 }
51
52 public function getXboxUserId() : string{ return $this->xboxUserId; }
53
54 public function getPlatformChatId() : string{ return $this->platformChatId; }
55
56 public function getFlags() : int{
57 return $this->flags;
58 }
59
60 protected function decodePayload(PacketSerializer $in) : void{
61 $this->actorRuntimeId = $in->getActorRuntimeId();
62 $this->emoteId = $in->getString();
63 $this->xboxUserId = $in->getString();
64 $this->platformChatId = $in->getString();
65 $this->flags = $in->getByte();
66 }
67
68 protected function encodePayload(PacketSerializer $out) : void{
69 $out->putActorRuntimeId($this->actorRuntimeId);
70 $out->putString($this->emoteId);
71 $out->putString($this->xboxUserId);
72 $out->putString($this->platformChatId);
73 $out->putByte($this->flags);
74 }
75
76 public function handle(PacketHandlerInterface $handler) : bool{
77 return $handler->handleEmote($this);
78 }
79}
static create(int $actorRuntimeId, string $emoteId, string $xboxUserId, string $platformChatId, int $flags)
Definition: EmotePacket.php:34
handle(PacketHandlerInterface $handler)
Definition: EmotePacket.php:76