PocketMine-MP 5.44.3 git-327e8a1690982f1ac3634944d705ebad5d91f4ad
Loading...
Searching...
No Matches
PresenceInfo.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\types;
16
17use pmmp\encoding\ByteBufferReader;
18use pmmp\encoding\ByteBufferWriter;
20
24final class PresenceInfo{
25 public function __construct(
26 private ?string $experienceName,
27 private ?string $worldName,
28 private string $richPresenceId
29 ){}
30
31 public function getExperienceName() : ?string{ return $this->experienceName; }
32
33 public function getWorldName() : ?string{ return $this->worldName; }
34
35 public function getRichPresenceId() : string{ return $this->richPresenceId; }
36
37 public static function read(ByteBufferReader $in) : self{
38 $experienceName = CommonTypes::readOptional($in, CommonTypes::getString(...));
39 $worldName = CommonTypes::readOptional($in, CommonTypes::getString(...));
40 $richPresenceId = CommonTypes::getString($in);
41
42 return new self($experienceName, $worldName, $richPresenceId);
43 }
44
45 public function write(ByteBufferWriter $out) : void{
46 CommonTypes::writeOptional($out, $this->experienceName, CommonTypes::putString(...));
47 CommonTypes::writeOptional($out, $this->worldName, CommonTypes::putString(...));
48 CommonTypes::putString($out, $this->richPresenceId);
49 }
50}