Skip to content

Commit a70b21c

Browse files
committed
Fix ServerJoinInformation
1 parent 1962e50 commit a70b21c

4 files changed

Lines changed: 113 additions & 29 deletions

File tree

src/types/GatheringJoinInfo.php

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,21 @@
2222
final class GatheringJoinInfo{
2323

2424
public function __construct(
25-
private string $experienceId,
25+
private UuidInterface $experienceId,
2626
private string $experienceName,
27-
private string $experienceWorldId,
27+
private UuidInterface $experienceWorldId,
2828
private string $experienceWorldName,
2929
private string $creatorId,
3030
private UuidInterface $targetId,
3131
private string $scenarioId,
3232
private string $serverId,
33-
private string $storeId,
34-
private string $storeName,
35-
private bool $presenceConfiguration
3633
){}
3734

38-
public function getExperienceId() : string{ return $this->experienceId; }
35+
public function getExperienceId() : UuidInterface{ return $this->experienceId; }
3936

4037
public function getExperienceName() : string{ return $this->experienceName; }
4138

42-
public function getExperienceWorldId() : string{ return $this->experienceWorldId; }
39+
public function getExperienceWorldId() : UuidInterface{ return $this->experienceWorldId; }
4340

4441
public function getExperienceWorldName() : string{ return $this->experienceWorldName; }
4542

@@ -51,26 +48,16 @@ public function getScenarioId() : string{ return $this->scenarioId; }
5148

5249
public function getServerId() : string{ return $this->serverId; }
5350

54-
public function getStoreId() : string{ return $this->storeId; }
55-
56-
public function getStoreName() : string{ return $this->storeName; }
57-
58-
public function isPresenceConfiguration() : bool{ return $this->presenceConfiguration; }
59-
6051
public static function read(ByteBufferReader $in) : self{
61-
$experienceId = CommonTypes::getString($in);
52+
$experienceId = CommonTypes::getUUID($in);
6253
$experienceName = CommonTypes::getString($in);
63-
$experienceWorldId = CommonTypes::getString($in);
54+
$experienceWorldId = CommonTypes::getUUID($in);
6455
$experienceWorldName = CommonTypes::getString($in);
6556
$creatorId = CommonTypes::getString($in);
6657
$targetId = CommonTypes::getUUID($in);
6758
$scenarioId = CommonTypes::getString($in);
6859
$serverId = CommonTypes::getString($in);
6960

70-
$storeId = CommonTypes::getString($in);
71-
$storeName = CommonTypes::getString($in);
72-
$presenceConfiguration = CommonTypes::getBool($in);
73-
7461
return new self(
7562
$experienceId,
7663
$experienceName,
@@ -80,24 +67,17 @@ public static function read(ByteBufferReader $in) : self{
8067
$targetId,
8168
$scenarioId,
8269
$serverId,
83-
$storeId,
84-
$storeName,
85-
$presenceConfiguration
8670
);
8771
}
8872

8973
public function write(ByteBufferWriter $out) : void{
90-
CommonTypes::putString($out, $this->experienceId);
74+
CommonTypes::putUUID($out, $this->experienceId);
9175
CommonTypes::putString($out, $this->experienceName);
92-
CommonTypes::putString($out, $this->experienceWorldId);
76+
CommonTypes::putUUID($out, $this->experienceWorldId);
9377
CommonTypes::putString($out, $this->experienceWorldName);
9478
CommonTypes::putString($out, $this->creatorId);
9579
CommonTypes::putUUID($out, $this->targetId);
9680
CommonTypes::putString($out, $this->scenarioId);
9781
CommonTypes::putString($out, $this->serverId);
98-
99-
CommonTypes::putString($out, $this->storeId);
100-
CommonTypes::putString($out, $this->storeName);
101-
CommonTypes::putBool($out, $this->presenceConfiguration);
10282
}
10383
}

src/types/PresenceInfo.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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\types;
16+
17+
use pmmp\encoding\ByteBufferReader;
18+
use pmmp\encoding\ByteBufferWriter;
19+
use pocketmine\network\mcpe\protocol\serializer\CommonTypes;
20+
21+
final class PresenceInfo{
22+
23+
public function __construct(
24+
private string $experienceName,
25+
private string $worldName,
26+
){}
27+
28+
public function getExperienceName() : string{ return $this->experienceName; }
29+
30+
public function getWorldName() : string{ return $this->worldName; }
31+
32+
public static function read(ByteBufferReader $in) : self{
33+
$experienceName = CommonTypes::getString($in);
34+
$worldName = CommonTypes::getString($in);
35+
36+
return new self(
37+
$experienceName,
38+
$worldName,
39+
);
40+
}
41+
42+
public function write(ByteBufferWriter $out) : void{
43+
CommonTypes::putString($out, $this->experienceName);
44+
CommonTypes::putString($out, $this->worldName);
45+
}
46+
}

src/types/ServerJoinInformation.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,31 @@ final class ServerJoinInformation{
2222

2323
public function __construct(
2424
private ?GatheringJoinInfo $gatheringJoinInfo,
25+
private ?StoreEntryPointInfo $storeEntryPointInfo,
26+
private ?PresenceInfo $presenceInfo,
2527
){}
2628

2729
public function getGatheringJoinInfo() : ?GatheringJoinInfo{ return $this->gatheringJoinInfo; }
2830

31+
public function getStoreEntryPointInfo() : ?StoreEntryPointInfo{ return $this->storeEntryPointInfo; }
32+
33+
public function getPresenceInfo() : ?PresenceInfo{ return $this->presenceInfo; }
34+
2935
public static function read(ByteBufferReader $in) : self{
3036
$gatheringJoinInfo = CommonTypes::readOptional($in, GatheringJoinInfo::read(...));
37+
$storeEntryPointInfo = CommonTypes::readOptional($in, StoreEntryPointInfo::read(...));
38+
$presenceInfo = CommonTypes::readOptional($in, PresenceInfo::read(...));
3139

3240
return new self(
33-
$gatheringJoinInfo
41+
$gatheringJoinInfo,
42+
$storeEntryPointInfo,
43+
$presenceInfo,
3444
);
3545
}
3646

3747
public function write(ByteBufferWriter $out) : void{
3848
CommonTypes::writeOptional($out, $this->gatheringJoinInfo, fn(ByteBufferWriter $out, GatheringJoinInfo $info) => $info->write($out));
49+
CommonTypes::writeOptional($out, $this->storeEntryPointInfo, fn(ByteBufferWriter $out, StoreEntryPointInfo $info) => $info->write($out));
50+
CommonTypes::writeOptional($out, $this->presenceInfo, fn(ByteBufferWriter $out, PresenceInfo $info) => $info->write($out));
3951
}
4052
}

src/types/StoreEntryPointInfo.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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\types;
16+
17+
use pmmp\encoding\ByteBufferReader;
18+
use pmmp\encoding\ByteBufferWriter;
19+
use pocketmine\network\mcpe\protocol\serializer\CommonTypes;
20+
21+
final class StoreEntryPointInfo{
22+
23+
public function __construct(
24+
private string $id,
25+
private string $name,
26+
){}
27+
28+
public function getId() : string{ return $this->id; }
29+
30+
public function getName() : string{ return $this->name; }
31+
32+
public static function read(ByteBufferReader $in) : self{
33+
$storeId = CommonTypes::getString($in);
34+
$storeName = CommonTypes::getString($in);
35+
36+
return new self(
37+
$storeId,
38+
$storeName,
39+
);
40+
}
41+
42+
public function write(ByteBufferWriter $out) : void{
43+
CommonTypes::putString($out, $this->id);
44+
CommonTypes::putString($out, $this->name);
45+
}
46+
}

0 commit comments

Comments
 (0)