🆙 More fixes 🆙

This commit is contained in:
Remco
2026-01-20 17:48:16 +01:00
parent 5b3645abba
commit 9a8fa8b1ff
7 changed files with 55 additions and 42 deletions
+14 -9
View File
@@ -276,23 +276,28 @@ class RconService
$this->closeConnection();
}
public function sendSafelyFromDashboard(string $action, array $args, string $errorMessage): void
public function sendSafelyFromDashboard(string $action, mixed $args, string $errorMessage): void
{
$argsArr = is_array($args) ? $args : [];
try {
switch ($action) {
case 'sendBadge':
/** @var \App\Models\User $user */
$user = $args[0];
/** @var string $badge */
$badge = (string) ($args[1] ?? '');
$userArg = $argsArr[0] ?? null;
if (! ($userArg instanceof \App\Models\User)) {
break;
}
$user = $userArg;
$badge = is_string($argsArr[1] ?? null) ? $argsArr[1] : '';
$this->giveBadge($user, $badge);
break;
case 'removeBadge':
// No direct RCON command defined for removing badges; use alert for now
/** @var \App\Models\User $user */
$user = $args[0];
/** @var string $badge */
$badge = (string) ($args[1] ?? '');
$userArg = $argsArr[0] ?? null;
if (! ($userArg instanceof \App\Models\User)) {
break;
}
$user = $userArg;
$badge = is_string($argsArr[1] ?? null) ? $argsArr[1] : '';
$this->alertUser($user, sprintf('Badge %s removed.', $badge));
break;
default: