Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions player-counter/lang/en/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'unknown' => 'Unknown',

'kick' => 'Kick',
'ban' => 'Ban',

'whitelisted' => 'Whitelisted',
'add_to_whitelist' => 'Add to whitelist',
Expand All @@ -38,6 +39,9 @@
'player_kicked' => 'Player kicked from server',
'player_kick_failed' => 'Could not kick player',

'player_banned' => 'Player banned from server',
'player_ban_failed' => 'Could not ban player',

'player_whitelist_add' => 'Player added to whitelist',
'player_whitelist_remove' => 'Player removed from whitelist',
'player_whitelist_failed' => 'Could not change whitelist',
Expand Down
2 changes: 1 addition & 1 deletion player-counter/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"xpaw/php-minecraft-query": "^5.0.0",
"xpaw/php-source-query-class": "^5.0.0"
}
}
}
30 changes: 30 additions & 0 deletions player-counter/src/Filament/Server/Pages/PlayersPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,36 @@ public function table(Table $table): Table
->send();
}
}),
Action::make('exclude_ban')
->visible(fn () => $isMinecraft)
->label(trans('player-counter::query.ban'))
->icon('tabler-hammer')
->color('danger')
->requiresConfirmation()
->action(function (array $record) {
/** @var Server $server */
$server = Filament::getTenant();

try {
$server->send('ban ' . $record['name']);

Notification::make()
->title(trans('player-counter::query.notifications.player_banned'))
->body($record['name'])
->success()
->send();

$this->refreshPage();
} catch (Exception $exception) {
report($exception);

Notification::make()
->title(trans('player-counter::query.notifications.player_ban_failed'))
->body($exception->getMessage())
->danger()
->send();
}
}),
Action::make('exclude_whitelist')
->visible(fn () => $isMinecraft)
->label(fn (array $record) => in_array($record['name'], $whitelist) ? trans('player-counter::query.remove_from_whitelist') : trans('player-counter::query.add_to_whitelist'))
Expand Down