Repository navigation
Add admin command to reset a player's generator data (#149) - #160
Conversation
Adds "/{admin} generator reset <player>", a confirmable admin subcommand
that resets a single island's generator data (unlocked, purchased and
active generators) without touching the rest of the database.
- StoneGeneratorManager.resetIslandData wipes the island's stored data
and recreates a fresh default data object so the island keeps working.
- New ResetCommand subcommand (permission admin.stone-generator.reset)
with player tab-completion and a confirmation prompt.
- New en-US locale strings for the command and the success message.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D7NWPeGXmsUJnnX42X24Rd
There was a problem hiding this comment.
Pull request overview
Adds an admin-facing, confirmable command to reset a single player’s island generator data (unlocked/purchased/active generators) without wiping the whole database, by deleting the island’s stored generator data and immediately recreating defaults so the island keeps operating.
Changes:
- Added
StoneGeneratorManager.resetIslandData(Island)to wipe an island’s generator data and reinitialize defaults. - Added
generator reset <player>as a newGeneratorAdminCommandsubcommand with confirmation + tab completion. - Added new locale strings for the command help/confirmation and a success message; added/updated unit tests for the new behavior and help listing.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/main/java/world/bentobox/magiccobblestonegenerator/managers/StoneGeneratorManager.java |
Adds resetIslandData() that wipes stored island generator data and reinitializes defaults. |
src/main/java/world/bentobox/magiccobblestonegenerator/commands/admin/GeneratorAdminCommand.java |
Registers and implements the new confirmable reset admin subcommand (with tab completion). |
src/main/resources/locales/en-US.yml |
Adds admin reset command help/confirmation strings and a reset success message. |
src/test/java/world/bentobox/magiccobblestonegenerator/managers/StoneGeneratorManagerTest.java |
Adds a unit test covering reset behavior (deletes stored data). |
src/test/java/world/bentobox/magiccobblestonegenerator/commands/admin/GeneratorAdminCommandTest.java |
Adds tests for reset command setup and execution (help and no-island error); updates help listing assertions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
SonarCloud flagged the new ResetCommand as duplicating GeneratorWhyCommand (identical player tab-completion and target-resolution). Extract two shared static helpers in GeneratorAdminCommand - playerTabComplete and resolveTargetUUID - and use them from both subcommands, removing the duplicated block. Review feedback: - resetIslandData now recreates the data object via addIslandData, which works even for ownerless islands (e.g. spawn), where validateIslandData returns early; validateIslandData is still called for owned islands. This ensures reset never deletes data without recreating it. - The reset command falls back to the typed argument for the player name when the server cannot resolve a name for the UUID, so confirmation and success messages are never blank. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D7NWPeGXmsUJnnX42X24Rd
|
Addressed the SonarCloud duplication and both review comments in a24e91d: SonarCloud duplication (37-line block): the new Review comments:
Full suite green (106 tests). |
The static helpers only removed part of the duplication SonarCloud flagged between ResetCommand and GeneratorWhyCommand; the identical execute preamble (arg check + UUID resolution) and tab-completion remained. Introduce an abstract PlayerTargetCommand base (extends ConfirmableCommand) that handles argument validation, target-UUID resolution and player tab-completion, and delegates to an abstract executeForTarget(user, name, uuid). GeneratorWhyCommand and ResetCommand now extend it and only implement setup() and their own executeForTarget, removing the duplicated block. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D7NWPeGXmsUJnnX42X24Rd
|
Follow-up on the duplication: the shared static helpers only removed part of it — the identical execute preamble (arg check + UUID resolution) and tab-completion still matched between
Note: Sonar's other reported pair (the two identical Full suite green (106 tests). |
The remaining SonarCloud duplication was the structurally identical constructor + setup() shared by GeneratorWhyCommand and ResetCommand (Sonar normalizes the differing string literals). Implement setup() once in the PlayerTargetCommand base, deriving the permission and locale keys from the subcommand label, and remove the per-command setup() overrides. The subcommands now only provide a constructor and their own executeForTarget. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D7NWPeGXmsUJnnX42X24Rd
|
|
Duplication cleared — SonarCloud now reports 0.0% new duplicated lines and the Code Analysis check passes (commit 6dc1f06). The last remaining block was the structurally identical constructor + Full suite green (106 tests). |



Closes #149
Feature
Adds
/{admin} generator reset <player>— a way for admins to reset a single player's island generator data (unlocked, purchased and active generators) without wiping the whole database or deleting files.Change
StoneGeneratorManager.resetIslandData(island)removes the island's stored data and immediately recreates a fresh default data object, so the island keeps working (default generators re-applied, permission unlocks re-evaluated).ResetCommandsubcommand ofGeneratorAdminCommand:admin.stone-generator.resetcommands.admin.resetentries (parameters/description/confirmation) and agenerator-data-resetsuccess message.Tests
StoneGeneratorManagerTest.testResetIslandData— reset deletes the island's stored data.GeneratorAdminCommandTest: setup (permission/params/description), no-args → help, and target-with-no-island → error. Updated the help-listing test for the new subcommand.Full suite: 106 tests pass.
🤖 Generated with Claude Code