mirror of
https://github.com/pmmp/BedrockProtocol.git
synced 2025-02-23 11:36:15 +00:00
53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of BedrockProtocol.
|
|
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
|
|
*
|
|
* BedrockProtocol is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace pocketmine\network\mcpe\protocol;
|
|
|
|
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
|
|
|
|
class MultiplayerSettingsPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
|
public const NETWORK_ID = ProtocolInfo::MULTIPLAYER_SETTINGS_PACKET;
|
|
|
|
public const ACTION_ENABLE_MULTIPLAYER = 0;
|
|
public const ACTION_DISABLE_MULTIPLAYER = 1;
|
|
public const ACTION_REFRESH_JOIN_CODE = 2;
|
|
|
|
private int $action;
|
|
|
|
/**
|
|
* @generate-create-func
|
|
*/
|
|
public static function create(int $action) : self{
|
|
$result = new self;
|
|
$result->action = $action;
|
|
return $result;
|
|
}
|
|
|
|
public function getAction() : int{
|
|
return $this->action;
|
|
}
|
|
|
|
protected function decodePayload(PacketSerializer $in) : void{
|
|
$this->action = $in->getVarInt();
|
|
}
|
|
|
|
protected function encodePayload(PacketSerializer $out) : void{
|
|
$out->putVarInt($this->action);
|
|
}
|
|
|
|
public function handle(PacketHandlerInterface $handler) : bool{
|
|
return $handler->handleMultiplayerSettings($this);
|
|
}
|
|
}
|