PocketMine-MP 5.19.1 git-5cc1068cd43264d3363295eb8d6901e02f467897
AgentActionEventPacket.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
24 public const NETWORK_ID = ProtocolInfo::AGENT_ACTION_EVENT_PACKET;
25
26 private string $requestId;
28 private int $action;
29 private string $responseJson;
30
34 public static function create(string $requestId, int $action, string $responseJson) : self{
35 $result = new self;
36 $result->requestId = $requestId;
37 $result->action = $action;
38 $result->responseJson = $responseJson;
39 return $result;
40 }
41
42 public function getRequestId() : string{ return $this->requestId; }
43
45 public function getAction() : int{ return $this->action; }
46
47 public function getResponseJson() : string{ return $this->responseJson; }
48
49 protected function decodePayload(PacketSerializer $in) : void{
50 $this->requestId = $in->getString();
51 $this->action = $in->getLInt();
52 $this->responseJson = $in->getString();
53 }
54
55 protected function encodePayload(PacketSerializer $out) : void{
56 $out->putString($this->requestId);
57 $out->putLInt($this->action);
58 $out->putString($this->responseJson);
59 }
60
61 public function handle(PacketHandlerInterface $handler) : bool{
62 return $handler->handleAgentActionEvent($this);
63 }
64}
static create(string $requestId, int $action, string $responseJson)