Skip to content

Commit 91eb2e9

Browse files
committed
fix resolvePlayerList
1 parent ac130b8 commit 91eb2e9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Ping.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace DevLancer\MinecraftStatus;
1010

11+
use DevLancer\MinecraftStatus\Exception\ConnectionException;
1112
use DevLancer\MinecraftStatus\Exception\NotConnectedException;
1213
use DevLancer\MinecraftStatus\Exception\ReceiveStatusException;
1314

@@ -20,6 +21,12 @@ class Ping extends AbstractPing implements PlayerListInterface, FaviconInterface
2021

2122
protected int $delay = 0;
2223

24+
/**
25+
* @inheritDoc
26+
* @return Ping
27+
* @throws ConnectionException Thrown when failed to connect to resource
28+
* @throws ReceiveStatusException Thrown when the status has not been obtained or resolved
29+
*/
2330
public function connect(): Ping
2431
{
2532
parent::connect();
@@ -92,12 +99,13 @@ protected function getStatus(): void
9299
*/
93100
protected function resolvePlayerList(array $data): array
94101
{
102+
$players = [];
95103
if (isset($data['players']['sample'])) {
96104
foreach ($data['players']['sample'] as $value)
97-
$this->players[] = $value;
105+
$players[] = $value;
98106
}
99107

100-
return [];
108+
return $players;
101109
}
102110

103111
/**

0 commit comments

Comments
 (0)