Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

A Paper plugin that rewilds abandoned, mined-out land back to fresh terrain from the world's seed, and keeps every block players placed exactly where it is. Paths, builds, chests and protected places stay; the holes, quarries and craters around them fill back in.

**Status:** pre-release. 0.3.0 is a redesign and has passed its tests on throwaway Paper 26.3 servers with a bot as the player (see [Testing](#testing)). It hasn't run on a real server, and nobody has looked at a rewilded area in a real game client yet.
**Status:** pre-release. 0.4.0 adds gradual healing of explosion holes and a hook for the Magic plugin; those have passed unit tests only, and haven't run on a server yet. 0.3.0 is a redesign and has passed its tests on throwaway Paper 26.3 servers with a bot as the player (see [Testing](#testing)). It hasn't run on a real server, and nobody has looked at a rewilded area in a real game client yet.

- Paper 26.1 and newer, Java 25. Not Spigot, and not 1.21.x.
- Off in every world until you turn it on. Dry run by default. Worlds in `never-reset-worlds`, such as kids' worlds, can never be turned on by mistake.
- Off in every world until you turn it on. Dry run by default. Worlds in `never-reset-worlds`, such as creative and lobby worlds, can never be turned on by mistake.
- Nothing resets until an admin has said which plugins to respect, an admin approves a run, and every run can be undone.

## How it works
Expand Down Expand Up @@ -61,6 +61,25 @@ Sometimes the chunk is kept whole, by a pet or a respawn point, or someone still

Before either kind of change, the plugin checks the bedrock pattern of the fresh copy against the real chunk, and refuses if they differ. A repair doesn't happen if anything that keeps the chunk whole reaches below the cut, if players changed or visited anything down there recently, or if the chunk is in a claim, at spawn or in an admin-protected area. It only runs in overworld-type worlds.

### Explosion holes heal gradually

From 0.4.0, a hole a creeper or TNT blows in natural land heals on its own, a step at a time, with no admin approval. Rewild writes down the blocks the blast destroyed and puts them back about once a day:

1. The ground fills from the bottom up, a few layers a step. Grass, podzol and moss go back as plain dirt first.
2. The next step the grass comes back on that dirt, and each tree the blast felled gets a sapling of its own wood.
3. Then a young tree: the lower half of the trunk and the leaves near it.
4. Last, the rest of the trees, loose leaves, flowers, grass and snow.

A typical crater, 3 or 4 layers deep, takes about a week. A deeper hole fills more layers a step, so it still takes about a week.

A hole only heals on its own when all of this holds: the world is enabled, the land was generated after Rewild started tracking it, the blast destroyed nothing a player placed and no container, and no player's block or filled container, claim, kept area, admin-protected area, respawn point or Magic block is within 8 blocks. Any other hole waits for an admin's approved run, as before.

Healing waits while a player is within 24 blocks, while the hole's chunks aren't loaded, and while anything that would stop a reset is wrong (the claim plugin is down, say). Each step only fills air, water and blocks anything may replace, such as short grass and snow, plus the dirt or sapling an earlier step laid. It never fills a block something is in, and never replaces a block a player put there since. While `dry-run` is true, each step is only reported in the log. `/rewild healing` lists the holes healing now.

### Magic

Wherever the Magic plugin is running, Rewild keeps its blocks and automata in place, with 8 blocks around each for its structure (`magic.keep-radius`), and the areas its spells changed that Magic will put back itself. A blast that's part of a spell is left to Magic. List the worlds where Magic is played in `magic.worlds`: nothing in those worlds resets or heals unless Magic is running and answers.

## Safety

- **Dry run by default.** With `dry-run: true`, an approved run is checked at the next restart and reported in the log, and no world file changes.
Expand Down Expand Up @@ -108,6 +127,7 @@ All commands need `rewild.admin`, which ops have. Players get no commands.
| `/rewild keep list [world] [--json]` | Lists kept areas, with who kept them and whether they count. |
| `/rewild unkeep <id>` | Removes a kept area. `/rewild unkeep <world> <x y z> [<x y z>] [plugin:<Name>]` removes one by its exact corners. |
| `/rewild plugins [--json]` | Lists installed plugins and which Rewild respects. `respect <Name>...`, `ignore <Name>...` and `ignore-rest` answer. |
| `/rewild healing` | Lists explosion holes healing on their own, with where they are and the next step. `step <id>` runs the next step now (it still waits for nearby players), and `cancel <id>` stops one, leaving what's back. |
| `/rewild reload` | Reloads config.yml, keep-plugins.yml and the kept areas. |

With `bluemap.enabled: true`, the last scan also appears as a BlueMap layer. It's off by default, because kept chunks show where people build and sleep. Only turn it on for a map that only admins can open.
Expand Down Expand Up @@ -143,6 +163,9 @@ If a respected provider throws, nothing in that world resets. If LanternGraves i
- A below-ground repair drops mobs and items under the cut, and doesn't bring back mineshaft minecarts.
- GriefPrevention is the only claim plugin supported. Animated Architecture has no hook, but its builds are made of player-placed blocks, which the tracker sees.
- Undo restores a chunk as it was before the run, so anything built in it since is lost.
- Healing has passed unit tests only (0.4.0). It hasn't run on a server yet, with a bot or a player.
- If a healing sapling grows into a tree on its own before the young-tree step, that step leaves the trunk alone and adds the young tree's leaves and logs around it where there's air.
- A healed hole gets back the blocks the blast destroyed. Water or lava that flowed in and set into stone or obsidian is left as it is, because it isn't air.

## Testing

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = "com.extantape"
version = "0.3.2"
version = "0.4.0"

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
Expand Down
6 changes: 6 additions & 0 deletions docs/decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ Decisions in the design brief that weren't reopened: off by default in every wor
## 2026-11-14

- **No old names (owner, D196):** "Make sure none of the plugins retain old references or commands". The folder move from the plugin's earlier name and its tests are removed. Released as 0.3.2.

## 2026-11-22

- **Every survival world, and gradual healing (owner, D224, 2026-11-16):** "If it's survival, even magic, it should be on that. It should probably plug into the magic plugin so it doesn't delete things from that realm, but it still should rewild." Pace: "About a week (Recommended)". Explosions: "Explosion holes heal on their own". Kids' worlds get the same rules as any other survival world, so the docs no longer suggest listing them in `never-reset-worlds`.
- **How 0.4.0 heals (the lead's design, for the owner's say):** a qualifying explosion hole is recorded as it happens and put back in daily steps: ground bottom up over `days - 3` steps (grass as dirt first), then grass and a sapling per felled tree, then the young tree (lower half of the trunk and leaves within 2 blocks), then the rest of the tree and small plants. A hole qualifies only in known land, with nothing player-placed or filled destroyed, and no build, filled container, claim, kept area, protected area, respawn point or Magic block within `healing.build-radius` (8). Healing pauses within `healing.pause-radius` (24) of a player, while chunks are unloaded, and while any reset safety check fails. A step fills only air, liquids and replaceable blocks, or the dirt or sapling an earlier step laid, and skips blocks an entity is in. Dry run logs steps instead of placing them, and completes the job.
- **Magic hook (the lead's design):** read by reflection from Magic's public API (tested against the Magic 11.3 jar's interfaces, not a running server). Magic blocks and automata are kept with `magic.keep-radius` (8) around each, and spell changes Magic will undo are kept too; a blast inside a pending undo is left to Magic. In `magic.worlds`, nothing resets or heals unless Magic is running and answers (fail closed). Magic worlds go in config only after a bot run with Magic installed.
15 changes: 15 additions & 0 deletions docs/releases/v0.4.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Explosion holes heal on their own, gradually (D224), and Rewild keeps the Magic plugin's blocks.

## What's new

- A hole a creeper or TNT blows in natural land heals over about a week with no approval: the ground fills bottom up, about a step a day, then grass, then saplings, young trees and full trees, then flowers. It only heals when nothing a player placed is in it or within 8 blocks, and it waits while a player is within 24 blocks. Other holes wait for an admin's approved run as before.
- `/rewild healing` lists holes healing now. `step <id>` runs the next step, and `cancel <id>` stops one.
- The Magic plugin's blocks, automata and pending spell changes are kept in place. In worlds listed in `magic.worlds`, nothing resets or heals unless Magic is running.

## Upgrading

Replace the jar. New settings (`healing`, `magic`) get their defaults; add them to config.yml to change them. Healing is on by default, and while `dry-run` is true it only reports in the log.

## Tested

Unit tests pass (103). Healing and the Magic hook haven't run on a server yet.
21 changes: 21 additions & 0 deletions docs/test-audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

Kept by this repo's owning session (Minecraft: Plugins Lead), per `~/Code/CLAUDE.md`, "Test self-audits". Newest first.

## 2026-11-22: 0.4.0 gradual healing and the Magic hook (K675)

Offline, unit tests only: no test servers tonight (owner). 103 unit tests pass.

| Promise | Covered by |
| --- | --- |
| A typical crater heals in about a week, bottom up, one band of layers a step | `HealPlanTest.aTypicalCraterTakesAboutAWeekAndFillsBottomUp`, `aDeepHoleTakesMoreLayersPerStepNotMoreDays` |
| Grass comes back as dirt first, and the grass step may replace only that dirt | `grassComesBackAsDirtFirstThenGrassReplacingIt` |
| Felled trees: sapling, then young tree replacing only its sapling, then whole | `aFelledTreeComesBackAsASaplingThenAYoungTreeThenWhole`, `touchingLogsAreOneTreeAndSeparateOnesAreTwo`, `saplingsMatchTheWoodAndStrippedOrUnknownLogsGetNone` |
| Small plants last; air never placed; each block once | `smallPlantsComeBackLast`, `airIsNeverPlacedAndEveryRecordedBlockComesBackOnce`, `nothingToHealMeansNoSteps` |
| **Only natural, known land heals without approval** (fails closed) | `HealCheckAndJobTest.unknownLandNeverHealsOnItsOwn`, `aBlastThroughPlayerBlocksWaitsForAnAdmin`, `aBuildNearbyStopsIt_evenInTheNextChunk`, `aFilledContainerNearbyStopsIt`, `aHoleInKnownNaturalLandHeals` |
| Healing survives a restart; a damaged file is refused, not guessed | `aJobSurvivesARestartExactly`, `aDamagedJobFileIsRefusedNotGuessed` |
| **A Magic world without Magic running never resets or heals**; Magic that can't answer stops resets | `MagicKeepsTest` (5 tests) |
| Settings default to a week and bad values stop resets | `RegenConfigTest.healingIsOnWithAWeekAndMagicWorldsAreRead` |

Gaps, for the bot run before release (not possible tonight):
- The server side of a step: pausing near a player, waiting for unloaded chunks, not overwriting a block placed since, skipping blocks an entity is in, dry run placing nothing, claims and kept areas refusing a hole, and a blast through a chest refusing it. These need a Paper server; add them to `test/` as `heal.mjs`, with `healing.step-hours` forced through `/rewild healing step`.
- The Magic hook against a running Magic 11.3: it was written against the jar's interfaces only.

Skipped: none of the pure rules; the reflection calls themselves are left to the bot run, since a mock would only test the mock.

## 2026-11-12: the 0.3.0 redesign

The redesign changes what a reset does, so every keep and safety promise was mapped again. "Acceptance" is `test/acceptance.mjs` and `test/keep.mjs` on a throwaway Paper 26.3 (build 249) server; "unit" is `src/test`.
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/extantape/rewild/RewildPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public final class RewildPlugin extends JavaPlugin {
private TrackerListener listener;
private ScanService scans;
private RunService runs;
private com.extantape.rewild.heal.HealService healing;
private Preview preview;
private MapLayer mapLayer = MapLayer.NONE;
/** Runs before any world loads: apply or undo approved runs while no chunk is open. */
Expand Down Expand Up @@ -80,6 +81,8 @@ public void onEnable() {
scans = new ScanService(this, tracking);
runs = new RunService(this, tracking);
preview = new Preview(this, scans);
healing = new com.extantape.rewild.heal.HealService(this, tracking);
healing.start();
if (config.blueMap && Bukkit.getPluginManager().getPlugin("BlueMap") != null) {
try {
mapLayer = new BlueMapLayer(getLogger());
Expand Down Expand Up @@ -115,6 +118,7 @@ public String pluginsProblem() {
@Override
public void onDisable() {
if (preview != null) preview.stopAll();
if (healing != null) healing.stop();
mapLayer.close();
if (tracking == null) return;
var snaps = runs.shutdownSnapshots();
Expand Down Expand Up @@ -158,6 +162,10 @@ public RunService runs() {
return runs;
}

public com.extantape.rewild.heal.HealService healing() {
return healing;
}

public Preview preview() {
return preview;
}
Expand Down
41 changes: 39 additions & 2 deletions src/main/java/com/extantape/rewild/cmd/RewildCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/** /rewild: admin-only, registered through Paper's command API. Players get no commands. */
public final class RewildCommand implements BasicCommand {
public static final String PERMISSION = "rewild.admin";
private static final List<String> SUBS = List.of("status", "why", "preview", "scan", "approve", "undo", "protect", "keep", "unkeep", "plugins", "reload");
private static final List<String> SUBS = List.of("status", "why", "preview", "scan", "approve", "undo", "protect", "keep", "unkeep", "plugins", "healing", "reload");
private final RewildPlugin plugin;

public RewildCommand(RewildPlugin plugin) {
Expand Down Expand Up @@ -79,12 +79,13 @@ void run(CommandSender sender, String[] args) {
case "keep" -> keep(sender, args);
case "unkeep" -> unkeep(sender, args);
case "plugins" -> plugins(sender, args);
case "healing" -> healing(sender, args);
case "reload" -> {
List<String> errors = plugin.reload();
if (errors.isEmpty()) say(sender, NamedTextColor.GREEN, "Config reloaded. New thresholds apply to the next scan.");
else say(sender, NamedTextColor.RED, "Config reloaded with problems, so nothing will reset: " + String.join("; ", errors));
}
default -> say(sender, NamedTextColor.GRAY, "/rewild status | why [world] [x z] | preview [radius] | scan [world] | approve <run> | approve generator <world> | undo <run> | protect [radius] [note] | protect remove | protect list | keep <world> <x y z> [<x y z>] [plugin:<Name>] [note] | keep list [world] [--json] | unkeep <id> | plugins [respect|ignore <Name>...] [ignore-rest] [--json] | reload");
default -> say(sender, NamedTextColor.GRAY, "/rewild status | why [world] [x z] | preview [radius] | scan [world] | approve <run> | approve generator <world> | undo <run> | protect [radius] [note] | protect remove | protect list | keep <world> <x y z> [<x y z>] [plugin:<Name>] [note] | keep list [world] [--json] | unkeep <id> | plugins [respect|ignore <Name>...] [ignore-rest] [--json] | healing [step|cancel <id>] | reload");
}
} catch (IOException e) {
say(sender, NamedTextColor.RED, "That failed: " + e.getMessage());
Expand Down Expand Up @@ -525,6 +526,39 @@ private void protect(CommandSender sender, String[] args) throws IOException {
say(sender, NamedTextColor.GREEN, "Protected " + (2 * radius + 1) * (2 * radius + 1) + " chunk(s) around you. They'll never reset.");
}

/** /rewild healing: list holes healing on their own; step one now (still waits for nearby players); cancel one. */
private void healing(CommandSender sender, String[] args) throws IOException {
var h = plugin.healing();
if (args.length >= 3 && args[1].equalsIgnoreCase("cancel")) {
if (h.cancel(args[2])) say(sender, NamedTextColor.GREEN, "Healing " + args[2] + " canceled. What's already back stays.");
else say(sender, NamedTextColor.RED, "No healing called " + args[2] + ". /rewild healing lists them.");
return;
}
if (args.length >= 3 && args[1].equalsIgnoreCase("step")) {
var j = h.all().stream().filter(x -> x.id.equals(args[2])).findFirst().orElse(null);
World w = j == null ? null : Bukkit.getWorld(j.world);
if (j == null || w == null) {
say(sender, NamedTextColor.RED, "No healing called " + args[2] + " in a loaded world. /rewild healing lists them.");
return;
}
say(sender, NamedTextColor.GREEN, h.step(j, w, System.currentTimeMillis(), true));
return;
}
var all = h.all();
if (all.isEmpty()) {
say(sender, NamedTextColor.GRAY, plugin.tracking().config().healExplosions
? "No explosion holes are healing right now." : "Explosion holes don't heal on their own here (healing.explosions is false).");
return;
}
say(sender, NamedTextColor.GREEN, all.size() + " hole(s) healing, about one step every " + plugin.tracking().config().healStepHours + " hours:");
for (var j : all) {
World w = Bukkit.getWorld(j.world);
int[] c = j.center();
say(sender, NamedTextColor.GRAY, j.id + " " + (w == null ? "unloaded world" : w.getName()) + " " + c[0] + " " + c[1] + " " + c[2]
+ " " + j.cells.size() + " blocks, " + j.done + " step(s) done, next " + date(j.next));
}
}

@Override
public java.util.Collection<String> suggest(CommandSourceStack source, String[] args) {
CommandSender sender = source.getSender();
Expand All @@ -547,6 +581,9 @@ public java.util.Collection<String> suggest(CommandSourceStack source, String[]
if (args.length == 3 && sub.equals("approve") && args[1].equalsIgnoreCase("generator")) {
return plugin.tracking().states().stream().map(s -> s.name).filter(n -> n.startsWith(args[2])).toList();
}
if (args.length == 2 && sub.equals("healing")) return List.of("step", "cancel").stream().filter(s -> s.startsWith(args[1])).toList();
if (args.length == 3 && sub.equals("healing") && (args[1].equalsIgnoreCase("step") || args[1].equalsIgnoreCase("cancel")))
return plugin.healing().all().stream().map(j -> j.id).filter(s -> s.startsWith(args[2])).toList();
if (args.length == 2 && sub.equals("protect")) return List.of("remove", "list", "0", "1", "2");
if (args.length == 2 && sub.equals("plugins")) return List.of("respect", "ignore", "ignore-rest", "--json").stream().filter(s -> s.startsWith(args[1])).toList();
if (args.length == 3 && sub.equals("plugins") && (args[1].equalsIgnoreCase("respect") || args[1].equalsIgnoreCase("ignore"))) {
Expand Down
Loading
Loading