PocketMine-MP 5.21.1 git-e598364f0695495cbe71ddf0b62f134b51091c6e
IncompatibleProtocolVersion.php
1<?php
2
3/*
4 * This file is part of RakLib.
5 * Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/RakLib>
6 *
7 * RakLib is not affiliated with Jenkins Software LLC nor RakNet.
8 *
9 * RakLib is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 */
14
15declare(strict_types=1);
16
17namespace raklib\protocol;
18
20 public static $ID = MessageIdentifiers::ID_INCOMPATIBLE_PROTOCOL_VERSION;
21
22 public int $protocolVersion;
23 public int $serverId;
24
25 public static function create(int $protocolVersion, int $serverId) : self{
26 $result = new self;
27 $result->protocolVersion = $protocolVersion;
28 $result->serverId = $serverId;
29 return $result;
30 }
31
32 protected function encodePayload(PacketSerializer $out) : void{
33 $out->putByte($this->protocolVersion);
34 $this->writeMagic($out);
35 $out->putLong($this->serverId);
36 }
37
38 protected function decodePayload(PacketSerializer $in) : void{
39 $this->protocolVersion = $in->getByte();
40 $this->readMagic($in);
41 $this->serverId = $in->getLong();
42 }
43}