Skip to content

Commit 6dc1f06

Browse files
tastybentoclaude
andcommitted
Move subcommand setup() into PlayerTargetCommand base (#149)
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) <[email protected]> Claude-Session: https://claude.ai/code/session_01D7NWPeGXmsUJnnX42X24Rd
1 parent ed109d0 commit 6dc1f06

1 file changed

Lines changed: 12 additions & 22 deletions

File tree

src/main/java/world/bentobox/magiccobblestonegenerator/commands/admin/GeneratorAdminCommand.java

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@ protected PlayerTargetCommand(StoneGeneratorAddon addon, CompositeCommand parent
111111
}
112112

113113

114+
@Override
115+
public void setup()
116+
{
117+
// Permission and locale references are derived from the subcommand label.
118+
this.setPermission("admin.stone-generator." + this.getLabel());
119+
this.setParametersHelp(Constants.ADMIN_COMMANDS + this.getLabel() + ".parameters");
120+
this.setDescription(Constants.ADMIN_COMMANDS + this.getLabel() + ".description");
121+
122+
this.setOnlyPlayer(false);
123+
}
124+
125+
114126
@Override
115127
public boolean execute(User user, String label, List<String> args)
116128
{
@@ -243,17 +255,6 @@ public GeneratorWhyCommand(StoneGeneratorAddon addon, CompositeCommand parentCom
243255
}
244256

245257

246-
@Override
247-
public void setup()
248-
{
249-
this.setPermission("admin.stone-generator.why");
250-
this.setParametersHelp(Constants.ADMIN_COMMANDS + "why.parameters");
251-
this.setDescription(Constants.ADMIN_COMMANDS + "why.description");
252-
253-
this.setOnlyPlayer(false);
254-
}
255-
256-
257258
@Override
258259
protected boolean executeForTarget(User user, String targetName, UUID targetUUID)
259260
{
@@ -329,17 +330,6 @@ public ResetCommand(StoneGeneratorAddon addon, CompositeCommand parentCommand)
329330
}
330331

331332

332-
@Override
333-
public void setup()
334-
{
335-
this.setPermission("admin.stone-generator.reset");
336-
this.setParametersHelp(Constants.ADMIN_COMMANDS + "reset.parameters");
337-
this.setDescription(Constants.ADMIN_COMMANDS + "reset.description");
338-
339-
this.setOnlyPlayer(false);
340-
}
341-
342-
343333
@Override
344334
protected boolean executeForTarget(User user, String targetName, UUID targetUUID)
345335
{

0 commit comments

Comments
 (0)