PocketMine-MP 5.21.3 git-fcef015f32c0b0709cfd4d6f1b3c32f484b25bde
Loading...
Searching...
No Matches
PacketViolationWarningPacket.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::PACKET_VIOLATION_WARNING_PACKET;
21
22 public const TYPE_MALFORMED = 0;
23
24 public const SEVERITY_WARNING = 0;
25 public const SEVERITY_FINAL_WARNING = 1;
26 public const SEVERITY_TERMINATING_CONNECTION = 2;
27
28 private int $type;
29 private int $severity;
30 private int $packetId;
31 private string $message;
32
36 public static function create(int $type, int $severity, int $packetId, string $message) : self{
37 $result = new self;
38 $result->type = $type;
39 $result->severity = $severity;
40 $result->packetId = $packetId;
41 $result->message = $message;
42 return $result;
43 }
44
45 public function getType() : int{ return $this->type; }
46
47 public function getSeverity() : int{ return $this->severity; }
48
49 public function getPacketId() : int{ return $this->packetId; }
50
51 public function getMessage() : string{ return $this->message; }
52
53 protected function decodePayload(PacketSerializer $in) : void{
54 $this->type = $in->getVarInt();
55 $this->severity = $in->getVarInt();
56 $this->packetId = $in->getVarInt();
57 $this->message = $in->getString();
58 }
59
60 protected function encodePayload(PacketSerializer $out) : void{
61 $out->putVarInt($this->type);
62 $out->putVarInt($this->severity);
63 $out->putVarInt($this->packetId);
64 $out->putString($this->message);
65 }
66
67 public function handle(PacketHandlerInterface $handler) : bool{
68 return $handler->handlePacketViolationWarning($this);
69 }
70}
static create(int $type, int $severity, int $packetId, string $message)