diff --git a/player-counter/src/Filament/Server/Pages/PlayersPage.php b/player-counter/src/Filament/Server/Pages/PlayersPage.php index c5f58878..142752d2 100644 --- a/player-counter/src/Filament/Server/Pages/PlayersPage.php +++ b/player-counter/src/Filament/Server/Pages/PlayersPage.php @@ -87,6 +87,7 @@ public function table(Table $table): Table $whitelist = []; $ops = []; + $players = []; if ($isMinecraft) { $fileRepository = (new DaemonFileRepository())->setServer($server); @@ -104,15 +105,20 @@ public function table(Table $table): Table } catch (Exception $exception) { report($exception); } + + try { + $players = json_decode($fileRepository->getContent('usercache.json'), true, 512, JSON_THROW_ON_ERROR); + $players = array_map(fn ($data) => ['id' => $data['uuid'],'name' => $data['name']], $players); + } catch (Exception $exception) { + report($exception); + } } return $table - ->records(function (?string $search, int $page, int $recordsPerPage) { + ->records(function (?string $search, int $page, int $recordsPerPage) use ($players) { /** @var Server $server */ $server = Filament::getTenant(); - $players = []; - /** @var ?GameQuery $gameQuery */ $gameQuery = $server->egg->gameQuery; // @phpstan-ignore property.notFound @@ -120,7 +126,7 @@ public function table(Table $table): Table $data = $gameQuery->runQuery($server); if ($data) { - $players = $data['players'] ?? []; + $players = array_unique(array_merge($players, $data['players'] ?? []), SORT_REGULAR); } }