Skip to content

Add runtime deletion for single plot areas - #4923

Open
tantaf123 wants to merge 7 commits into
IntellectualSites:mainfrom
tantaf123:feature/delete-single-plot-area
Open

Add runtime deletion for single plot areas#4923
tantaf123 wants to merge 7 commits into
IntellectualSites:mainfrom
tantaf123:feature/delete-single-plot-area

Conversation

@tantaf123

@tantaf123 tantaf123 commented Aug 17, 2026

Copy link
Copy Markdown

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:

  • Is implemented as a subcommand of /plot area.
  • Only operates on partial areas containing the single 1;1 plot.
  • Refuses to remove an area while it contains claimed plot data.
  • Requires confirmation before removal.
  • Revalidates the area after confirmation.
  • Removes the area's entry from worlds.yml.
  • Unregisters the area from the active PlotAreaManager.
  • Does not modify or regenerate the existing Minecraft terrain.
  • Uses PlotSquared's localized caption system for command messages rather than hardcoded locale-specific strings.

This keeps deletion narrowly scoped to single plot areas and leaves the existing broader /plot area delete behaviour unchanged.

Submitter Checklist

  • I am opening from a topic branch and not my main branch.
  • I ensure that the pull request title represents the desired changelog entry.
  • New public fields and methods are annotated with @since TODO.
  • I read and followed the contribution guidelines.

@tantaf123
tantaf123 requested a review from a team as a code owner August 17, 2026 18:18
@NotMyFault
NotMyFault requested a lite review from Copilot August 17, 2026 18:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.yml persistence.

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.

Comment on lines +139 to +142
player.sendMessage(StaticCaption.of(
"<prefix><dark_aqua>Successfully removed single plot area <gold>" + currentArea.getId()
+ "</gold>. Existing Minecraft terrain was not changed.</dark_aqua>"
));
Comment on lines +111 to +124
// 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;
}
@PierreSchwang

Copy link
Copy Markdown
Member

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)

@tantaf123

Copy link
Copy Markdown
Author

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!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment on lines +885 to +889
if (area.getType() != PlotAreaType.PARTIAL
|| !singlePlotId.equals(area.getMin())
|| !singlePlotId.equals(area.getMax())) {
player.sendMessage(TranslatableCaption.of("single.worldcreation_location"));
return false;
Comment on lines +904 to +911
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>",
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.

remove single plot areas easily

4 participants