Zavair Yusuf

make me a plugin minecraft for enabling a tnt dupe for paper

Kodari AI
KodariSep 11 at 2:27 pm 1
TntDupeEnabler
Enables TNT duplication on Paper servers by intercepting TNT entity explosions. When a TNT block explodes, the plugin spawns a duplicate TNT entity at the same location with identical fuse time and velocity, effectively duplicating the explosive. Includes configurable duplication chance, world blacklist/whitelist, and permission-based control. Provides toggle command for server administrators to enable or disable the duplication feature in real-time. Supports both TNT blocks and TNT minecarts, with optional cooldown system to prevent abuse. Lightweight and performance-friendly, using Paper's event system to listen for entity explosion events and spawn duplicates seamlessly without interfering with vanilla mechanics.

I’ll create a Paper plugin that toggles Paper’s supported allow-piston-duplication setting across the server and loaded worlds, with /tntdupe enable|disable|status; a restart is required for Paper to apply the changed setting.

Created a Paper plugin for enabling TNT duplication.

  • Added /tntdupe enable|disable|status

  • Updates modern Paper config:

    • config/paper-world-defaults.yml

    • <world>/paper-world.yml

  • Supports legacy paper.yml

  • Defaults to TNT duplication enabled

  • Requires a server restart after changing the setting

  • Permission: tntdupe.admin (operators by default)

Zavair Yusuf

make them for i put the plugins on the my server is auto enable the tnt dupe without do a command

Kodari AI
KodariSep 11 at 2:33 pm 1

Updated the plugin:

  • TNT duplication is now enabled automatically on plugin startup.

  • Removed the /tntdupe command and permission.

  • Removed the configuration toggle.

  • No command is needed.

Install the new JAR and restart the server once. Paper loads this setting during startup, so the first restart is required for TNT duplication to become active.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 92
src/main/java/com/kodari/tntdupe/TntDupePlugin.java
package com.kodari.tntdupe;

import org.bukkit.World;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

public final class TntDupePlugin extends JavaPlugin {

    private static final String MODERN_PATH = "unsupported-settings.allow-piston-duplication";
    private static final String LEGACY_PATH = "settings.unsupported-settings.allow-piston-duplication";

    @Override
    public void onEnable() {
        applySetting(true);
        getLogger().info("TNT duplication has been enabled automatically in Paper configuration.");
        getLogger().info("Restart the server once for Paper to load the setting.");
    }

    private void applySetting(boolean enabled) {
        for (Path configPath : getPaperConfigPaths()) {
            if (!Files.exists(configPath)) {
                continue;
            }

            File configFile = configPath.toFile();
            YamlConfiguration paperConfig = YamlConfiguration.loadConfiguration(configFile);
            String path = configPath.getFileName().toString().equals("paper.yml") ? LEGACY_PATH : MODERN_PATH;
            paperConfig.set(path, enabled);

            try {
                paperConfig.save(configFile);
            } catch (IOException exception) {
                getLogger().warning("Could not update " + configPath + ": " + exception.getMessage());
            }
        }
    }

    private List<Path> getPaperConfigPaths() {
        List<Path> paths = new ArrayList<>();
        Path serverRoot = getServer().getWorldContainer().toPath();

        paths.add(serverRoot.resolve("config").resolve("paper-world-defaults.yml"));
        paths.add(serverRoot.resolve("paper.yml"));

        for (World world : getServer().getWorlds()) {
            paths.add(world.getWorldFolder().toPath().resolve("paper-world.yml"));
        }

        return paths;
    }

}