Skip to content

Comments

Update: add ability to ban players on Minecraft Java servers with PlayerCounter plugin#109

Merged
Boy132 merged 3 commits intopelican-dev:mainfrom
YONN2222:playercounter/mc-ban
Feb 20, 2026
Merged

Update: add ability to ban players on Minecraft Java servers with PlayerCounter plugin#109
Boy132 merged 3 commits intopelican-dev:mainfrom
YONN2222:playercounter/mc-ban

Conversation

@YONN2222
Copy link
Contributor

@YONN2222 YONN2222 commented Feb 19, 2026

Little change on the PlayerCounter plugin: add a button to ban people from the server

Summary by CodeRabbit

  • New Features
    • Add player ban action for Minecraft servers — ban players from the UI with confirmation, success/error notifications, and page refresh on success.
  • Localization
    • Added English strings: "Ban", "Player banned from server", and "Could not ban player".

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 19, 2026

Caution

Review failed

The pull request is closed.

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de1d02e and fa78b64.

📒 Files selected for processing (2)
  • player-counter/plugin.json
  • player-counter/src/Filament/Server/Pages/PlayersPage.php

📝 Walkthrough

Walkthrough

Adds a Minecraft "ban" action to the Filament players page and corresponding English translation keys; player-counter/plugin.json only received a trailing newline change.

Changes

Cohort / File(s) Summary
Translation Keys
player-counter/lang/en/query.php
Added top-level ban => Ban and notifications keys: player_banned => Player banned from server, player_ban_failed => Could not ban player.
Plugin Metadata (whitespace)
player-counter/plugin.json
Only trailing newline change; no semantic or version changes.
Player Ban Action
player-counter/src/Filament/Server/Pages/PlayersPage.php
Added exclude_ban action to the players table: visible when Minecraft is active, labeled via trans('player-counter::query.ban'), requires confirmation, sends ban command, emits success/error notifications, and refreshes the page on completion.

Sequence Diagram(s)

sequenceDiagram
  participant Admin as Admin (Filament UI)
  participant Filament as Filament Page
  participant App as Server Backend
  participant MC as Minecraft Server

  Admin->>Filament: Click "Ban" action (confirm)
  Filament->>App: Request: ban player (player id)
  App->>MC: Send ban command to Minecraft server
  alt success
    MC-->>App: Command executed OK
    App-->>Filament: 200 OK / success
    Filament-->>Admin: Show notification "player_banned"
    Filament->>Filament: Refresh players table
  else failure
    MC-->>App: Error/exception
    App-->>Filament: Error response
    Filament-->>Admin: Show notification "player_ban_failed"
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I tapped the hammer, gave a hop and a spin,
A new "ban" word tucked where translations begin,
The UI asked kindly, the backend obeyed,
Notifications sang as the action was made,
A tiny change, a decisive win.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main change: adding a ban player ability to the PlayerCounter plugin for Minecraft Java servers.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
player-counter/src/Filament/Server/Pages/PlayersPage.php (1)

201-220: Minor formatting inconsistency — add blank lines between logical statement groups.

The ban action's closure omits the blank lines that all other actions (exclude_kick, exclude_whitelist, exclude_op) use to separate logical groups within the try/catch blocks. Keeping the same style aids readability.

♻️ Proposed fix
     ->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();
         }
     }),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@player-counter/src/Filament/Server/Pages/PlayersPage.php` around lines 201 -
220, The closure passed to ->action (the ban action) needs the same blank-line
separations used by other actions: add a blank line between obtaining the Server
instance ($server = Filament::getTenant();) and the try block, a blank line
between the server->send('ban ' . $record['name']); call and the subsequent
Notification::make() success block, and a blank line between report($exception);
and the Notification::make() danger block in the catch; keep existing variable
names and structure (the closure, $record, $server, server->send, report,
Notification::make) but insert those blank lines to match the project's
formatting style.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc4c900 and 1668ce6.

📒 Files selected for processing (3)
  • player-counter/lang/en/query.php
  • player-counter/plugin.json
  • player-counter/src/Filament/Server/Pages/PlayersPage.php
🧰 Additional context used
🧬 Code graph analysis (1)
player-counter/src/Filament/Server/Pages/PlayersPage.php (2)
subdomains/src/Models/Subdomain.php (1)
  • server (48-51)
billing/src/Models/Order.php (1)
  • server (63-66)
🔇 Additional comments (2)
player-counter/plugin.json (1)

5-5: Version bump looks appropriate.

Bumping to 1.0.1 for a backwards-compatible feature addition is correct semver hygiene.

player-counter/lang/en/query.php (1)

17-17: Translation keys are correct and well-placed.

The new ban, player_banned, and player_ban_failed keys are grouped consistently alongside their kick counterparts and match the keys referenced in PlayersPage.php.

Also applies to: 42-44

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@player-counter/src/Filament/Server/Pages/PlayersPage.php`:
- Around line 196-220: The ban Action (Action::make('exclude_ban') in
PlayersPage) is destructive but runs immediately; update its definition to
require user confirmation before executing by calling ->requiresConfirmation()
on the Action (optionally configure message/confirm/cancel labels or
modalContent via the same fluent API) so the ban handler only runs after the
user confirms. Ensure the call is added in the Action chain for 'exclude_ban'
alongside existing visible/label/icon/color/action settings.

---

Nitpick comments:
In `@player-counter/src/Filament/Server/Pages/PlayersPage.php`:
- Around line 201-220: The closure passed to ->action (the ban action) needs the
same blank-line separations used by other actions: add a blank line between
obtaining the Server instance ($server = Filament::getTenant();) and the try
block, a blank line between the server->send('ban ' . $record['name']); call and
the subsequent Notification::make() success block, and a blank line between
report($exception); and the Notification::make() danger block in the catch; keep
existing variable names and structure (the closure, $record, $server,
server->send, report, Notification::make) but insert those blank lines to match
the project's formatting style.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
player-counter/src/Filament/Server/Pages/PlayersPage.php (2)

202-221: Minor: add blank lines inside the try block to match the kick-action style.

The exclude_kick action (lines 172–194) separates the send, Notification, and refreshPage calls with blank lines. The ban action omits them, creating a slight inconsistency.

♻️ Formatting alignment with kick action
     ->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();
         }
     }),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@player-counter/src/Filament/Server/Pages/PlayersPage.php` around lines 202 -
221, The try block inside the ban action closure is missing blank lines between
the $server->send('ban ' . $record['name']), the Notification::make() chain, and
$this->refreshPage(); update the anonymous function used in ->action(...) (the
ban action closure where Filament::getTenant() is assigned to $server and
$server->send('ban ...') is called) to insert the same blank-line separations
used in the exclude_kick action: one blank line after the $server->send(...)
call, one blank line after the Notification::make()...->send() call before
calling $this->refreshPage(), keeping all existing logic intact.

196-221: Optionally customise the confirmation modal to show the player's name.

The default ->requiresConfirmation() modal shows a generic "Are you sure?" heading with no indication of who is being banned. Since ban is irreversible without a manual /pardon, surfacing the target name in the modal reduces the risk of accidentally banning the wrong player.

♻️ Proposed enhancement to the confirmation modal
 Action::make('exclude_ban')
     ->visible(fn () => $isMinecraft)
     ->label(trans('player-counter::query.ban'))
     ->icon('tabler-hammer')
     ->color('danger')
     ->requiresConfirmation()
+    ->modalHeading(fn (array $record) => trans('player-counter::query.ban') . ' ' . $record['name'])
+    ->modalDescription(fn (array $record) => $record['name'] . ' will be permanently banned from the server.')
     ->action(function (array $record) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@player-counter/src/Filament/Server/Pages/PlayersPage.php` around lines 196 -
221, The confirmation modal for Action::make('exclude_ban') is generic; update
the Action to show the target player's name by replacing the plain
->requiresConfirmation() with a confirmation configuration that uses
record-aware callbacks (e.g.
->requiresConfirmation()->confirmationTitle(fn(array $record) => "Ban
{$record['name']}?") and ->confirmationDescription(fn(array $record) =>
trans(..., ['name' => $record['name']]))) so the modal title/description include
record['name'] (you can also set a clearer
confirmationButtonLabel/confirmationActionLabel) while keeping the existing
action closure that sends 'ban ' . $record['name'] and handles notifications.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1668ce6 and de1d02e.

📒 Files selected for processing (1)
  • player-counter/src/Filament/Server/Pages/PlayersPage.php
🧰 Additional context used
🧬 Code graph analysis (1)
player-counter/src/Filament/Server/Pages/PlayersPage.php (2)
subdomains/src/Models/Subdomain.php (1)
  • server (48-51)
billing/src/Models/Order.php (1)
  • server (63-66)
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@player-counter/src/Filament/Server/Pages/PlayersPage.php`:
- Around line 196-201: The destructive ban action Action::make('exclude_ban')
now includes ->requiresConfirmation(), addressing the missing confirmation
concern; no further code changes are required—keep the confirmation present on
the Action declaration (Action::make('exclude_ban')->requiresConfirmation()) to
ensure the destructive flow still prompts users.

---

Nitpick comments:
In `@player-counter/src/Filament/Server/Pages/PlayersPage.php`:
- Around line 202-221: The try block inside the ban action closure is missing
blank lines between the $server->send('ban ' . $record['name']), the
Notification::make() chain, and $this->refreshPage(); update the anonymous
function used in ->action(...) (the ban action closure where
Filament::getTenant() is assigned to $server and $server->send('ban ...') is
called) to insert the same blank-line separations used in the exclude_kick
action: one blank line after the $server->send(...) call, one blank line after
the Notification::make()...->send() call before calling $this->refreshPage(),
keeping all existing logic intact.
- Around line 196-221: The confirmation modal for Action::make('exclude_ban') is
generic; update the Action to show the target player's name by replacing the
plain ->requiresConfirmation() with a confirmation configuration that uses
record-aware callbacks (e.g.
->requiresConfirmation()->confirmationTitle(fn(array $record) => "Ban
{$record['name']}?") and ->confirmationDescription(fn(array $record) =>
trans(..., ['name' => $record['name']]))) so the modal title/description include
record['name'] (you can also set a clearer
confirmationButtonLabel/confirmationActionLabel) while keeping the existing
action closure that sends 'ban ' . $record['name'] and handles notifications.

@Boy132 Boy132 merged commit 0b93673 into pelican-dev:main Feb 20, 2026
6 of 7 checks passed
@YONN2222 YONN2222 deleted the playercounter/mc-ban branch February 20, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants