B

Here’s the deal:

The World: A custom-made map.

I want the terrain to automatically regenerate after players mine or build. (rollback like CoreProtect)

I need it to respect player claims (WorldGuard) - blocks inside a claim should NOT regenerate while the claim exists.

BUT, if the claim is deleted/expired, the area should then regenerate back to its original state.

Basically, I want my custom map to stay pristine, but let players have their permanent bases while also being able to destroy and build blocks.

Kodari AI
KodariFeb 25 at 5:05 pm 16,139 (v2)

I’ll create a terrain regeneration plugin that preserves your custom map while respecting WorldGuard claims.

TerrainRegeneration
An automatic terrain restoration system that regenerates blocks to their original state after mining or building. Fully integrates with WorldGuard to respect player claims - blocks inside regions never regenerate while claimed, but automatically restore when claims are deleted or expire. Perfect for preserving custom maps while allowing temporary building and resource gathering in unclaimed areas.

Let me create a comprehensive terrain regeneration system with WorldGuard integration.

Plan:

  • Track all block changes with original state in SQLite database

  • Schedule regeneration after configurable delay for blocks outside claims

  • Check WorldGuard regions before regenerating (skip if now claimed)

  • Command to trigger regeneration for deleted region areas

  • Batch regeneration to prevent lag

Perfect! I’ve created a complete terrain regeneration system with WorldGuard integration.

Key Features:

  • Automatic Block Tracking: Records original block states when players mine/build

  • Smart Regeneration: Blocks outside claims regenerate after 5 minutes (configurable)

  • WorldGuard Integration: Blocks inside regions are never regenerated while the claim exists

  • Claim Deletion Handling: When regions are deleted, use /tregen force region <id> <world> to regenerate

  • SQLite Storage: Persistent storage survives server restarts

  • Batch Processing: Prevents lag by processing blocks in batches

  • Multi-world Support: Configure which worlds to track

Commands:

  • /tregen reload - Reload configuration

  • /tregen stats - Show tracking statistics

  • /tregen force all - Force regenerate everything

  • /tregen force region <id> <world> - Regenerate a deleted region

  • /tregen debug - Show debug information

How It Works:

  1. When a block is broken/placed, the original state is stored with timestamp

  2. System checks WorldGuard to see if block is in a region (stores region ID if yes)

  3. Every second, checks for blocks older than the regeneration delay

  4. Before regenerating, verifies block isn’t now in a region

  5. If block was in a region and that region still exists, skips regeneration

  6. When you delete a region, run the force command to regenerate that area

The system intelligently preserves your custom map while respecting player claims!

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
13 1,033
src/main/java/com/terrainregen/TerrainRegenPlugin.java
package com.terrainregen;

import com.terrainregen.config.ConfigManager;
import com.terrainregen.listener.BlockChangeListener;
import com.terrainregen.listener.ChunkUnloadListener;
import com.terrainregen.manager.BlockTracker;
import com.terrainregen.manager.RegenerationManager;
import com.terrainregen.manager.WorldGuardHook;
import com.terrainregen.command.TerrainRegenCommand;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class TerrainRegenPlugin extends JavaPlugin {

    private ConfigManager configManager;
    private WorldGuardHook worldGuardHook;
    private BlockTracker blockTracker;
    private RegenerationManager regenerationManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        
        this.worldGuardHook = new WorldGuardHook(this);
        if (worldGuardHook.isEnabled()) {
            getLogger().info("WorldGuard integration enabled");
        } else {
            getLogger().warning("WorldGuard not found - all areas will regenerate");
        }
        
        this.blockTracker = new BlockTracker(this);
        if (!blockTracker.initialize()) {
            getLogger().severe("Failed to initialize block tracker - disabling plugin");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        
        this.regenerationManager = new RegenerationManager(this);
        regenerationManager.start();
        
        Bukkit.getPluginManager().registerEvents(new BlockChangeListener(this), this);
        Bukkit.getPluginManager().registerEvents(new ChunkUnloadListener(this), this);
        
        getCommand("terrainregen").setExecutor(new TerrainRegenCommand(this));
        
        getLogger().info("TerrainRegeneration enabled successfully");
    }

    @Override
    public void onDisable() {
        if (regenerationManager != null) {
            regenerationManager.stop();
        }
        
        if (blockTracker != null) {
            blockTracker.shutdown();
        }
        
        getLogger().info("TerrainRegeneration disabled");
    }

    public void reload() {
        reloadConfig();
        configManager = new ConfigManager(this);
        
        if (regenerationManager != null) {
            regenerationManager.stop();
            regenerationManager.start();
        }
        
        getLogger().info("Configuration reloaded");
    }
}