_fizz4r
📎 1 file 1,665 chars
📄
pasted-code-1792690933412.txt
txt 36 lines
▶
Create a simple Death Swap plugin for Minecraft Paper 1.21.x (Java 21, Maven).
Output every file in full. Keep it lean: no features beyond those listed.

GAMEPLAY
- Every 4-6 minutes (configurable), all players swap locations using a shuffled
  cycle (A->B->C->A) so nobody swaps with themselves. O(n), any player count.
- Players win by causing others to die through indirect accidents. Dead players
  become spectators. Last player alive wins.
- Game states: WAITING -> RUNNING -> ENDING, with a min player count and a
  short start countdown.
- Safe teleport: use teleportAsync(), preload the chunk first, find solid ground.

TIMER
- The swap countdown is hidden until public_timer_seconds (default 60) remain.
- At that point, show ONE shared BossBar to all alive players and send a
  "Swap in 60 seconds!" title and sound.
- In the final 10 seconds, add an action bar message and a sound each second.
- After each swap, hide the bar and reset. Never create one bar per player.

KILL FEED
- When a player dies, broadcast "'s trap killed ". Credit the
  player whose old position the victim was at, within 30 seconds after a swap.
  Otherwise broadcast " died to ".

PERFORMANCE
- One scheduler task ticking once per second, otherwise event-driven.
- UUID-keyed maps only, never store Player objects, clean up on quit.
- Eliminate players who stay disconnected over 60 seconds.

COMMANDS
- /deathswap start | stop | join | leave | reload (permissions: deathswap.admin,
  deathswap.play)

CONFIG
- config.yml with: swap min/max, public_timer_seconds, kill credit window,
  min players, PvP on/off.
Kodari AI
KodariOct 22 at 5:45 pm 2
DeathSwapArena
A Minecraft Paper plugin implementing a Death Swap minigame. Players are teleported in a shuffled cycle every configurable 4-6 minutes, aiming to cause indirect deaths. Features a WAITING/RUNNING/ENDING state machine with start countdown, hidden swap timer that reveals a shared BossBar and title when 60 seconds remain, plus per-second action bar alerts in the final 10 seconds. Includes a kill feed crediting the player whose old position caused a death within a 30-second window, UUID-keyed player tracking with cleanup for disconnects, spectator mode for eliminated players, and safe teleportation using teleportAsync with chunk preloading. Commands for start, stop, join, leave, and reload with permission checks, plus a configurable config.yml for swap intervals, timer thresholds, kill credit window, minimum players, and PvP toggle.
  1. Add Maven/Paper 1.21 project metadata and the requested configuration.

  2. Implement the game manager, safe shuffled swaps, shared timer UI, and elimination tracking.

  3. Wire commands and Bukkit events for joining, deaths, PvP, and disconnects.

Created the Paper 1.21.x Death Swap plugin with Maven metadata, configuration, /deathswap commands, shuffled safe teleports, a shared countdown BossBar, kill credit, spectator eliminations, PvP control, and 60-second disconnect elimination.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
7 777
src/main/java/com/kodari/deathswap/DeathSwapPlugin.java
package com.kodari.deathswap;

import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class DeathSwapPlugin extends JavaPlugin {
    private GameManager gameManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        gameManager = new GameManager(this);
        Bukkit.getPluginManager().registerEvents(new GameListener(this, gameManager), this);
        getCommand("deathswap").setExecutor(new DeathSwapCommand(this, gameManager));
    }

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