PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
PlayStatusPacket.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\BE;
18use pmmp\encoding\ByteBufferReader;
19use pmmp\encoding\ByteBufferWriter;
20
22 public const NETWORK_ID = ProtocolInfo::PLAY_STATUS_PACKET;
23
24 public const LOGIN_SUCCESS = 0;
25 public const LOGIN_FAILED_CLIENT = 1;
26 public const LOGIN_FAILED_SERVER = 2;
27 public const PLAYER_SPAWN = 3;
28 public const LOGIN_FAILED_INVALID_TENANT = 4;
29 public const LOGIN_FAILED_VANILLA_EDU = 5;
30 public const LOGIN_FAILED_EDU_VANILLA = 6;
31 public const LOGIN_FAILED_SERVER_FULL = 7;
32 public const LOGIN_FAILED_EDITOR_VANILLA = 8;
33 public const LOGIN_FAILED_VANILLA_EDITOR = 9;
34
35 public int $status;
36
40 public static function create(int $status) : self{
41 $result = new self;
42 $result->status = $status;
43 return $result;
44 }
45
46 protected function decodePayload(ByteBufferReader $in) : void{
47 $this->status = BE::readUnsignedInt($in);
48 }
49
50 public function canBeSentBeforeLogin() : bool{
51 return true;
52 }
53
54 protected function encodePayload(ByteBufferWriter $out) : void{
55 BE::writeUnsignedInt($out, $this->status);
56 }
57
58 public function handle(PacketHandlerInterface $handler) : bool{
59 return $handler->handlePlayStatus($this);
60 }
61}