PocketMine-MP
5.23.3 git-fbaa125d0ce21ffef98fc1630881a92bedfbaa73
Loading...
Searching...
No Matches
DeathInfoPacket.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
23
class
DeathInfoPacket
extends
DataPacket
implements
ClientboundPacket
{
24
public
const
NETWORK_ID = ProtocolInfo::DEATH_INFO_PACKET;
25
26
private
string
$messageTranslationKey;
28
private
array $messageParameters;
29
34
public
static
function
create
(
string
$messageTranslationKey, array $messageParameters) : self{
35
$result = new self;
36
$result->messageTranslationKey = $messageTranslationKey;
37
$result->messageParameters = $messageParameters;
38
return
$result;
39
}
40
41
public
function
getMessageTranslationKey() : string{ return $this->messageTranslationKey; }
42
44
public
function
getMessageParameters
() : array{ return $this->messageParameters; }
45
46
protected
function
decodePayload
(
PacketSerializer
$in) : void{
47
$this->messageTranslationKey = $in->getString();
48
49
$this->messageParameters = [];
50
for
($i = 0, $len = $in->
getUnsignedVarInt
(); $i < $len; $i++){
51
$this->messageParameters[] = $in->getString();
52
}
53
}
54
55
protected
function
encodePayload
(
PacketSerializer
$out) : void{
56
$out->putString($this->messageTranslationKey);
57
58
$out->
putUnsignedVarInt
(count($this->messageParameters));
59
foreach
($this->messageParameters as $parameter){
60
$out->putString($parameter);
61
}
62
}
63
64
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
65
return $handler->handleDeathInfo($this);
66
}
67
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:21
pocketmine\network\mcpe\protocol\DeathInfoPacket
Definition
DeathInfoPacket.php:23
pocketmine\network\mcpe\protocol\DeathInfoPacket\decodePayload
decodePayload(PacketSerializer $in)
Definition
DeathInfoPacket.php:46
pocketmine\network\mcpe\protocol\DeathInfoPacket\encodePayload
encodePayload(PacketSerializer $out)
Definition
DeathInfoPacket.php:55
pocketmine\network\mcpe\protocol\DeathInfoPacket\getMessageParameters
getMessageParameters()
Definition
DeathInfoPacket.php:44
pocketmine\network\mcpe\protocol\DeathInfoPacket\handle
handle(PacketHandlerInterface $handler)
Definition
DeathInfoPacket.php:64
pocketmine\network\mcpe\protocol\DeathInfoPacket\create
static create(string $messageTranslationKey, array $messageParameters)
Definition
DeathInfoPacket.php:34
pocketmine\network\mcpe\protocol\serializer\PacketSerializer
Definition
bedrock-protocol/src/serializer/PacketSerializer.php:66
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
DeathInfoPacket.php
Generated by
1.12.0