topcoder431

Generate me a basic duel plugin where players can duel pvp. This will teleport them in a box at different points where they must run to each other and battle, give them iron armour and swords with a bow. after a person dies it ananouces the winner and sends them back to the spawn. allow for the command /duel <player>

Kodari AI
KodariAug 26 at 10:31 pm 2
DuelArena
A Minecraft plugin enabling player-versus-player duels. When a player uses /duel &lt;player&gt;, both participants are teleported to a boxed arena at opposite corners, equipped with iron armor, a sword, and a bow. They must run toward each other and battle until one dies. Upon death, the plugin announces the winner in chat and teleports both players back to the world spawn. The plugin manages duel requests, prevents interference during active duels, and handles disconnections gracefully.
  1. Create the Gradle/Paper plugin scaffold and default arena configuration.

  2. Add duel state, arena construction/restoration, inventory kits, and winner cleanup.

  3. Register /duel, accept/deny handling, combat restrictions, death, quit, and respawn events.

Created a complete basic duel plugin with:

  • /duel <player> challenge command

  • /duel accept <player> and /duel deny [player]

  • Configurable glass-box arena

  • Teleportation to opposite arena positions

  • Iron armor, iron sword, bow, and arrows

  • PvP restrictions inside the duel

  • Winner announcement after death

  • Inventory and player-state restoration

  • Teleportation back to spawn

  • Cleanup on logout and plugin shutdown

Configure arena coordinates in src/main/resources/config.yml.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
11 791
src/main/java/com/example/basicduel/DuelPlugin.java
package com.example.basicduel;

import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Objects;

public final class DuelPlugin extends JavaPlugin {

    private DuelManager duelManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        duelManager = new DuelManager(this);
        DuelCommand duelCommand = new DuelCommand(duelManager);
        PluginCommand command = Objects.requireNonNull(getCommand("duel"));
        command.setExecutor(duelCommand);
        command.setTabCompleter(duelCommand);

        getServer().getPluginManager().registerEvents(new DuelListener(duelManager), this);
    }

    @Override
    public void onDisable() {
        if (duelManager != null) {
            duelManager.shutdown();
        }
    }
}