diff --git a/player-counter/lang/en/query.php b/player-counter/lang/en/query.php index 54502a4b..84f1ae46 100644 --- a/player-counter/lang/en/query.php +++ b/player-counter/lang/en/query.php @@ -14,6 +14,7 @@ 'unknown' => 'Unknown', 'kick' => 'Kick', + 'ban' => 'Ban', 'whitelisted' => 'Whitelisted', 'add_to_whitelist' => 'Add to whitelist', @@ -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', diff --git a/player-counter/plugin.json b/player-counter/plugin.json index 1e8ad72a..20fedb77 100644 --- a/player-counter/plugin.json +++ b/player-counter/plugin.json @@ -18,4 +18,4 @@ "xpaw/php-minecraft-query": "^5.0.0", "xpaw/php-source-query-class": "^5.0.0" } -} \ No newline at end of file +} diff --git a/player-counter/src/Filament/Server/Pages/PlayersPage.php b/player-counter/src/Filament/Server/Pages/PlayersPage.php index 279474a7..b2ed1780 100644 --- a/player-counter/src/Filament/Server/Pages/PlayersPage.php +++ b/player-counter/src/Filament/Server/Pages/PlayersPage.php @@ -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'))