Add runtime deletion for single plot areas - #4923
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new administrative command to delete single-plot partial areas at runtime (targeting the special 1;1-only areas created via /plot area single), removing the area entry from worlds.yml and unregistering it from the active PlotAreaManager without regenerating terrain.
Changes:
- Register a new
/plot deletearea <area>command (alias/plot areadelete) in the main command list. - Implement runtime deletion logic with confirmation, claimed-plot safety checks, and
worlds.ymlpersistence.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Core/src/main/java/com/plotsquared/core/command/MainCommand.java | Registers the new DeleteArea command so it becomes available under /plot. |
| Core/src/main/java/com/plotsquared/core/command/DeleteArea.java | Implements the confirmed runtime deletion flow for single-plot partial areas and updates worlds.yml. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| player.sendMessage(StaticCaption.of( | ||
| "<prefix><dark_aqua>Successfully removed single plot area <gold>" + currentArea.getId() | ||
| + "</gold>. Existing Minecraft terrain was not changed.</dark_aqua>" | ||
| )); |
| // Re-resolve the area after confirmation so stale command state cannot remove a different area. | ||
| final PlotArea currentArea = this.plotAreaManager.getPlotAreaByString(args[0]); | ||
| if (currentArea != area) { | ||
| player.sendMessage(StaticCaption.of( | ||
| "<prefix><red>The plot area changed while waiting for confirmation. Run the command again.</red>" | ||
| )); | ||
| return; | ||
| } | ||
| if (currentArea.getPlotCount() != 0) { | ||
| player.sendMessage(StaticCaption.of( | ||
| "<prefix><red>This single plot area now contains claimed plot data and was not removed.</red>" | ||
| )); | ||
| return; | ||
| } |
|
Without reviewing thoroughly, the command should be part of the "area" command (= subcommand), and localized messages should not be static but rather added to the locale file and referenced by a key (i18n) |
|
Small follow-up: I’ve updated the PR description with some additional implementation details and clarifications, including the safety/revalidation behaviour and scope of the command. Just mentioning it here in case the edited description was missed. Thanks! |
| if (area.getType() != PlotAreaType.PARTIAL | ||
| || !singlePlotId.equals(area.getMin()) | ||
| || !singlePlotId.equals(area.getMax())) { | ||
| player.sendMessage(TranslatableCaption.of("single.worldcreation_location")); | ||
| return false; |
| final PlotArea currentArea = this.plotAreaManager.getPlotAreaByString(args[1]); | ||
| if (currentArea != area | ||
| || currentArea.getType() != PlotAreaType.PARTIAL | ||
| || !singlePlotId.equals(currentArea.getMin()) | ||
| || !singlePlotId.equals(currentArea.getMax())) { | ||
| player.sendMessage(TranslatableCaption.of("single.single_area_delete_invalid_state")); | ||
| return; | ||
| } |
| "set.set_attribute": "<prefix><dark_aqua>Successfully set <attribute> to <value>.</dark_aqua>", | ||
| "area.set_pos2": "You will now set pos2: <command>. Note: The chosen plot size may result in the created area not exactly matching your second position.", | ||
| "single.single_area_delete_claimed": "<prefix><red>This single plot area contains claimed plot data. Delete or unclaim the plot before removing the area.</red>", | ||
| "single.single_area_delete_invalid_state": "<prefix><red>The single plot area current state or configuration entry could not be verified. Run the command again.</red>", |
Overview
Fixes #4603
Description
Adds
/plot area delete <area>to safely remove a single plot area at runtime without requiring a server restart or manual editing of PlotSquared's configuration.The command:
/plot area.1;1plot.worlds.yml.PlotAreaManager.This keeps deletion narrowly scoped to single plot areas and leaves the existing broader
/plot area deletebehaviour unchanged.Submitter Checklist
@sinceTODO.