PocketMine-MP
5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
UpdateSoftEnumPacket.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
13
declare(strict_types=1);
14
15
namespace
pocketmine\network\mcpe\protocol;
16
17
use
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
;
18
use
function
count;
19
20
class
UpdateSoftEnumPacket
extends
DataPacket
implements
ClientboundPacket
{
21
public
const
NETWORK_ID = ProtocolInfo::UPDATE_SOFT_ENUM_PACKET;
22
23
public
const
TYPE_ADD = 0;
24
public
const
TYPE_REMOVE = 1;
25
public
const
TYPE_SET = 2;
26
27
public
string
$enumName;
29
public
array $values = [];
30
public
int
$type;
31
36
public
static
function
create
(
string
$enumName, array $values,
int
$type) : self{
37
$result = new self;
38
$result->enumName = $enumName;
39
$result->values = $values;
40
$result->type = $type;
41
return
$result;
42
}
43
44
protected
function
decodePayload
(
PacketSerializer
$in) : void{
45
$this->enumName = $in->getString();
46
for
($i = 0, $count = $in->
getUnsignedVarInt
(); $i < $count; ++$i){
47
$this->values[] = $in->getString();
48
}
49
$this->type = $in->
getByte
();
50
}
51
52
protected
function
encodePayload
(
PacketSerializer
$out) : void{
53
$out->putString($this->enumName);
54
$out->
putUnsignedVarInt
(count($this->values));
55
foreach
($this->values as $v){
56
$out->putString($v);
57
}
58
$out->putByte($this->type);
59
}
60
61
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
62
return $handler->handleUpdateSoftEnum($this);
63
}
64
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:21
pocketmine\network\mcpe\protocol\UpdateSoftEnumPacket
Definition
UpdateSoftEnumPacket.php:20
pocketmine\network\mcpe\protocol\UpdateSoftEnumPacket\decodePayload
decodePayload(PacketSerializer $in)
Definition
UpdateSoftEnumPacket.php:44
pocketmine\network\mcpe\protocol\UpdateSoftEnumPacket\create
static create(string $enumName, array $values, int $type)
Definition
UpdateSoftEnumPacket.php:36
pocketmine\network\mcpe\protocol\UpdateSoftEnumPacket\handle
handle(PacketHandlerInterface $handler)
Definition
UpdateSoftEnumPacket.php:61
pocketmine\network\mcpe\protocol\UpdateSoftEnumPacket\encodePayload
encodePayload(PacketSerializer $out)
Definition
UpdateSoftEnumPacket.php:52
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
Definition
bedrock-protocol/src/serializer/PacketSerializer.php:66
pocketmine\utils\BinaryStream\getByte
getByte()
Definition
BinaryStream.php:117
pocketmine\utils\BinaryStream\getUnsignedVarInt
getUnsignedVarInt()
Definition
BinaryStream.php:307
pocketmine\utils\BinaryStream\putUnsignedVarInt
putUnsignedVarInt(int $v)
Definition
BinaryStream.php:314
pocketmine\network\mcpe\protocol\ClientboundPacket
Definition
ClientboundPacket.php:17
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
vendor
pocketmine
bedrock-protocol
src
UpdateSoftEnumPacket.php
Generated by
1.12.0