PocketMine-MP
5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
LessonProgressPacket.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 pmmp\encoding\ByteBufferReader;
18
use pmmp\encoding\ByteBufferWriter;
19
use pmmp\encoding\VarInt;
20
use
pocketmine\network\mcpe\protocol\serializer\CommonTypes
;
21
25
class
LessonProgressPacket
extends
DataPacket
implements
ClientboundPacket
{
26
public
const
NETWORK_ID = ProtocolInfo::LESSON_PROGRESS_PACKET;
27
28
public
const
ACTION_START = 0;
29
public
const
ACTION_FINISH = 1;
30
public
const
ACTION_RESTART = 2;
31
32
private
int
$action;
33
private
int
$score;
34
private
string
$activityId;
35
39
public
static
function
create
(
int
$action,
int
$score,
string
$activityId) : self{
40
$result = new self;
41
$result->action = $action;
42
$result->score = $score;
43
$result->activityId = $activityId;
44
return
$result;
45
}
46
47
public
function
getAction() : int{ return $this->action; }
48
49
public
function
getScore() : int{ return $this->score; }
50
51
public
function
getActivityId() : string{ return $this->activityId; }
52
53
protected
function
decodePayload
(ByteBufferReader $in) : void{
54
$this->action = VarInt::readSignedInt($in);
55
$this->score = VarInt::readSignedInt($in);
56
$this->activityId = CommonTypes::getString($in);
57
}
58
59
protected
function
encodePayload
(ByteBufferWriter $out) : void{
60
VarInt::writeSignedInt($out, $this->action);
61
VarInt::writeSignedInt($out, $this->score);
62
CommonTypes::putString($out, $this->activityId);
63
}
64
65
public
function
handle
(
PacketHandlerInterface
$handler) : bool{
66
return $handler->handleLessonProgress($this);
67
}
68
}
pocketmine\network\mcpe\protocol\DataPacket
Definition
DataPacket.php:23
pocketmine\network\mcpe\protocol\LessonProgressPacket
Definition
LessonProgressPacket.php:25
pocketmine\network\mcpe\protocol\LessonProgressPacket\decodePayload
decodePayload(ByteBufferReader $in)
Definition
LessonProgressPacket.php:53
pocketmine\network\mcpe\protocol\LessonProgressPacket\create
static create(int $action, int $score, string $activityId)
Definition
LessonProgressPacket.php:39
pocketmine\network\mcpe\protocol\LessonProgressPacket\handle
handle(PacketHandlerInterface $handler)
Definition
LessonProgressPacket.php:65
pocketmine\network\mcpe\protocol\LessonProgressPacket\encodePayload
encodePayload(ByteBufferWriter $out)
Definition
LessonProgressPacket.php:59
pocketmine\network\mcpe\protocol\serializer\CommonTypes
Definition
CommonTypes.php:70
pocketmine\network\mcpe\protocol\ClientboundPacket
Definition
ClientboundPacket.php:17
pocketmine\network\mcpe\protocol\PacketHandlerInterface
Definition
PacketHandlerInterface.php:20
vendor
pocketmine
bedrock-protocol
src
LessonProgressPacket.php
Generated by
1.12.0