PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
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
17use pmmp\encoding\Byte;
18use pmmp\encoding\ByteBufferReader;
19use pmmp\encoding\ByteBufferWriter;
20use pmmp\encoding\VarInt;
22
24 public const NETWORK_ID = ProtocolInfo::EMOTE_PACKET;
25
26 public const FLAG_SERVER = 1 << 0;
27 public const FLAG_MUTE_ANNOUNCEMENT = 1 << 1;
28
29 private int $actorRuntimeId;
30 private string $emoteId;
31 private int $emoteLengthTicks;
32 private string $xboxUserId;
33 private string $platformChatId;
34 private int $flags;
35
39 public static function create(int $actorRuntimeId, string $emoteId, int $emoteLengthTicks, string $xboxUserId, string $platformChatId, int $flags) : self{
40 $result = new self;
41 $result->actorRuntimeId = $actorRuntimeId;
42 $result->emoteId = $emoteId;
43 $result->emoteLengthTicks = $emoteLengthTicks;
44 $result->xboxUserId = $xboxUserId;
45 $result->platformChatId = $platformChatId;
46 $result->flags = $flags;
47 return $result;
48 }
49
50 public function getActorRuntimeId() : int{
51 return $this->actorRuntimeId;
52 }
53
54 public function getEmoteId() : string{
55 return $this->emoteId;
56 }
57
58 public function getEmoteLengthTicks() : int{ return $this->emoteLengthTicks; }
59
60 public function getXboxUserId() : string{ return $this->xboxUserId; }
61
62 public function getPlatformChatId() : string{ return $this->platformChatId; }
63
64 public function getFlags() : int{
65 return $this->flags;
66 }
67
68 protected function decodePayload(ByteBufferReader $in) : void{
69 $this->actorRuntimeId = CommonTypes::getActorRuntimeId($in);
70 $this->emoteId = CommonTypes::getString($in);
71 $this->emoteLengthTicks = VarInt::readUnsignedInt($in);
72 $this->xboxUserId = CommonTypes::getString($in);
73 $this->platformChatId = CommonTypes::getString($in);
74 $this->flags = Byte::readUnsigned($in);
75 }
76
77 protected function encodePayload(ByteBufferWriter $out) : void{
78 CommonTypes::putActorRuntimeId($out, $this->actorRuntimeId);
79 CommonTypes::putString($out, $this->emoteId);
80 VarInt::writeUnsignedInt($out, $this->emoteLengthTicks);
81 CommonTypes::putString($out, $this->xboxUserId);
82 CommonTypes::putString($out, $this->platformChatId);
83 Byte::writeUnsigned($out, $this->flags);
84 }
85
86 public function handle(PacketHandlerInterface $handler) : bool{
87 return $handler->handleEmote($this);
88 }
89}
static create(int $actorRuntimeId, string $emoteId, int $emoteLengthTicks, string $xboxUserId, string $platformChatId, int $flags)
handle(PacketHandlerInterface $handler)