feat: connect via rcon

This commit is contained in:
2026-07-09 14:51:56 +02:00
parent d2c7fecd55
commit 9a3902ae96
13 changed files with 481 additions and 38 deletions
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Services;
use App\Models\AccessRequests;
class RconAccessGrantor
{
public function __construct(
private readonly MinecraftRconClient $rconClient,
) {}
public function grant(AccessRequests $accessRequest): string
{
return $this->rconClient->command($this->commandFor($accessRequest->game_username));
}
private function commandFor(string $gameUsername): string
{
$accessCommand = (string) config('rcon.access_command', 'whitelist add {username}');
if (! str_contains($accessCommand, '{username}')) {
$accessCommand = trim($accessCommand).' {username}';
}
return str_replace('{username}', $gameUsername, $accessCommand);
}
}