-
Notifications
You must be signed in to change notification settings - Fork 43
[Player Counter] Add Palworld Support #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Boy132
merged 9 commits into
pelican-dev:main
from
makepeacej:feature/palworld-player-count-support
May 4, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9c05266
Added Palworld schema. Adjusted to handle looking at servers env sett…
54873b2
Fix incorrect Palworld metrics API field names
63ccc36
Fix Pint style violations: remove aligned => operators
0c332f0
Updated palworld query schema to check for ok response
6389ca5
adjusted some spacing for pint
1fa85da
Removed server schema interface and adjusted original to include server
d49d018
Adjusted GameQuery.php to pass in server param
084d361
Apply suggestions from code review
Boy132 0eb3a9e
add back $server param
Boy132 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
player-counter/src/Extensions/Query/Schemas/PalworldQueryTypeSchema.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| <?php | ||
|
|
||
| namespace Boy132\PlayerCounter\Extensions\Query\Schemas; | ||
|
|
||
| use App\Models\Server; | ||
| use Boy132\PlayerCounter\Extensions\Query\QueryTypeSchemaInterface; | ||
|
Boy132 marked this conversation as resolved.
|
||
| use Exception; | ||
| use Illuminate\Support\Facades\Http; | ||
|
|
||
| class PalworldQueryTypeSchema implements QueryTypeSchemaInterface | ||
| { | ||
| public function getId(): string | ||
| { | ||
| return 'palworld'; | ||
| } | ||
|
|
||
| public function getName(): string | ||
| { | ||
| return 'Palworld'; | ||
| } | ||
|
|
||
| public function process(Server $server, string $ip, int $port): ?array | ||
| { | ||
| $adminPassword = $server->variables() | ||
| ->where('env_variable', 'ADMIN_PASSWORD') | ||
| ->first()?->server_value; | ||
|
|
||
| if (!$adminPassword) { | ||
| return null; | ||
| } | ||
|
|
||
| try { | ||
| $base = "http://{$ip}:{$port}"; | ||
| [$playersResp, $metricsResp] = Http::pool(fn ($pool) => [ | ||
| $pool->timeout(5)->withBasicAuth('admin', $adminPassword)->get("{$base}/v1/api/players"), | ||
| $pool->timeout(5)->withBasicAuth('admin', $adminPassword)->get("{$base}/v1/api/metrics"), | ||
| ]); | ||
|
|
||
| if (!$playersResp->ok()) { | ||
| return null; | ||
| } | ||
|
|
||
| $data = $playersResp->json(); | ||
| $players = array_map(fn ($p) => [ | ||
| 'id' => $p['playeruid'] ?? $p['steamid'] ?? '', | ||
| 'name' => $p['name'] ?? '', | ||
| ], $data['players'] ?? []); | ||
|
|
||
| $maxPlayers = $metricsResp->ok() ? ($metricsResp->json()['maxplayernum'] ?? 32) : 32; | ||
|
|
||
| return [ | ||
| 'hostname' => $server->name, | ||
| 'map' => 'Palpagos Islands', | ||
| 'current_players' => count($players), | ||
| 'max_players' => $maxPlayers, | ||
| 'players' => $players, | ||
| ]; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| } catch (Exception $exception) { | ||
| report($exception); | ||
|
|
||
| return null; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.