PocketMine-MP 5.21.2 git-09bf203267aca9b83a09640e17bfac0fc7b58ff8
Loading...
Searching...
No Matches
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 int $emoteLengthTicks;
28 private string $xboxUserId;
29 private string $platformChatId;
30 private int $flags;
31
35 public static function create(int $actorRuntimeId, string $emoteId, int $emoteLengthTicks, string $xboxUserId, string $platformChatId, int $flags) : self{
36 $result = new self;
37 $result->actorRuntimeId = $actorRuntimeId;
38 $result->emoteId = $emoteId;
39 $result->emoteLengthTicks = $emoteLengthTicks;
40 $result->xboxUserId = $xboxUserId;
41 $result->platformChatId = $platformChatId;
42 $result->flags = $flags;
43 return $result;
44 }
45
46 public function getActorRuntimeId() : int{
47 return $this->actorRuntimeId;
48 }
49
50 public function getEmoteId() : string{
51 return $this->emoteId;
52 }
53
54 public function getEmoteLengthTicks() : int{ return $this->emoteLengthTicks; }
55
56 public function getXboxUserId() : string{ return $this->xboxUserId; }
57
58 public function getPlatformChatId() : string{ return $this->platformChatId; }
59
60 public function getFlags() : int{
61 return $this->flags;
62 }
63
64 protected function decodePayload(PacketSerializer $in) : void{
65 $this->actorRuntimeId = $in->getActorRuntimeId();
66 $this->emoteId = $in->getString();
67 $this->emoteLengthTicks = $in->getUnsignedVarInt();
68 $this->xboxUserId = $in->getString();
69 $this->platformChatId = $in->getString();
70 $this->flags = $in->getByte();
71 }
72
73 protected function encodePayload(PacketSerializer $out) : void{
74 $out->putActorRuntimeId($this->actorRuntimeId);
75 $out->putString($this->emoteId);
76 $out->putUnsignedVarInt($this->emoteLengthTicks);
77 $out->putString($this->xboxUserId);
78 $out->putString($this->platformChatId);
79 $out->putByte($this->flags);
80 }
81
82 public function handle(PacketHandlerInterface $handler) : bool{
83 return $handler->handleEmote($this);
84 }
85}
static create(int $actorRuntimeId, string $emoteId, int $emoteLengthTicks, string $xboxUserId, string $platformChatId, int $flags)
handle(PacketHandlerInterface $handler)