Skip to content

Commit 1248c62

Browse files
committed
disable player counter when using 0.0.0.0 or :: as allocation ip
1 parent 53451ad commit 1248c62

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

player-counter/src/Filament/Server/Pages/PlayersPage.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ public static function canAccess(): bool
4040
/** @var Server $server */
4141
$server = Filament::getTenant();
4242

43-
return parent::canAccess() && $server->allocation && $server->egg->gameQuery()->exists(); // @phpstan-ignore method.notFound
43+
if (!$server->allocation || $server->allocation->ip === '0.0.0.0' || $server->allocation->ip === '::') {
44+
return false;
45+
}
46+
47+
// @phpstan-ignore method.notFound
48+
if (!$server->egg->gameQuery()->exists()) {
49+
return false;
50+
}
51+
52+
return parent::canAccess();
4453
}
4554

4655
public static function getNavigationLabel(): string

player-counter/src/Filament/Server/Widgets/ServerPlayerWidget.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,20 @@ public static function canView(): bool
1717
/** @var Server $server */
1818
$server = Filament::getTenant();
1919

20-
return !$server->isInConflictState() && $server->allocation && $server->egg->gameQuery()->exists() && !$server->retrieveStatus()->isOffline(); // @phpstan-ignore method.notFound
20+
if ($server->isInConflictState()) {
21+
return false;
22+
}
23+
24+
if (!$server->allocation || $server->allocation->ip === '0.0.0.0' || $server->allocation->ip === '::') {
25+
return false;
26+
}
27+
28+
// @phpstan-ignore method.notFound
29+
if (!$server->egg->gameQuery()->exists()) {
30+
return false;
31+
}
32+
33+
return !$server->retrieveStatus()->isOffline();
2134
}
2235

2336
protected function getStats(): array

0 commit comments

Comments
 (0)