owner_of_unstable_smp_75041
📎 1 file 4,632 chars
📄
pasted-code-1773251506351.txt
txt 81 lines
▶
Create a Paper Minecraft plugin called "DeathBanPlugin" with the following specifications. Read every point carefully and ensure nothing is missed. This plugin must handle all previously discussed features, plus the following:  

1. **Core Death Ban Mechanics**
   - Players are **temporarily banned** only when killed by another player (PvP).  
   - Ban triggers **even if the player clicks “Respawn” after death**.  
   - Natural deaths (fall, lava, mobs, void) **do NOT trigger a ban**.  
   - Ban duration is **configurable** in seconds (default 24 hours).  
   - Ban applies to **UUID, IP, or both**, configurable separately (`ban-uuid: true/false`, `ban-ip: true/false`).  
   - On death by PvP:
     - Switch player to **spectator mode** for a configurable duration (default 3 seconds).  
     - Disconnect with a **customizable kick message**.  
     - Show a **custom ban message** after disconnect, like operator bans.  
     - Store ban info in a persistent YAML file (`bans.yml`) including: UUID, player name, IP, killer name, banned-at timestamp, unban-at timestamp.  
   - After ban expires:
     - Automatically **remove the entry** from the ban file.  
     - If the player is online and still in spectator mode, switch to **survival** and send **unban message**.  
     - If the player joins after the ban expires, ensure they spawn in **survival mode**, not spectator.  

2. **Configuration Options**
   - `ban-duration` (seconds)  
   - `spectator-duration` (seconds before disconnect)  
   - `check-interval` (seconds between automatic unban checks)  
   - `ban-ip: true/false`  
   - `ban-uuid: true/false`  
   - `play-sound: true/false` (plays sound on PvP death)  
   - Messages (all configurable) with placeholders `{player}`, `{killer}`, `{duration}`, `{remaining}`, `{banned-at}`, `{unban-at}`:
     - `ban-message`, `kick-message`, `ban-reason`, `unban-message`, `already-banned`, `not-banned`, `player-not-found`, `unbanned-target`, `unbanned-sender`, `ban-info`, `reload-success`.  
   - Sound settings:
     - `death-sound` (default `ENTITY_WITHER_DEATH`), `volume`, `pitch`.  

3. **Gameplay Features**
   - Play the configured sound at the killer’s location.  
   - Ban triggers **even if the player clicks Respawn** after death.  
   - Ensure **gamemode restoration** for online and newly joining players.  
   - Prevent bypass:
     - Name changes do not bypass bans (ban by UUID/IP).  
     - If `ban-ip: true`, other accounts on same IP cannot bypass.  

4. **Administrative Commands**
   - `/deathban unban `: unban and restore survival.  
   - `/deathban info `: show banned-at, unban-at, killer, remaining.  
   - `/deathban reload`: reload config and messages.  
   - Commands respect **LuckPerms permissions** if installed.  

5. **File Storage**
   - Store banned players in `bans.yml`:
     ```
     bans:
       :
         name: 
         uuid: 
         ip: 
         killer: 
         banned-at: 
         unban-at: 
     ```
   - Entries automatically removed when ban expires.  
   - Check online players every `check-interval` seconds for gamemode restoration and notifications.  

6. **Edge Cases**
   - Non-player deaths → no ban.  
   - Player disconnects during spectator → ban still applies.  
   - Player online when ban expires → survival restored.  
   - Player joins after ban expires → survival restored.  
   - Placeholders must work in all messages.  

7. **Technical Requirements**
   - Compatible with **Paper 1.21+**.  
   - Supports offline/cracked servers with consistent UUIDs.  
   - Proper error handling if UUID/IP already banned.  
   - Anti-bypass measures: combine UUID/IP bans, prevent name changes, restore gamemode after unban, handle both online and offline players.  

8. **Testing & Safety**
   - Ensure PvP-only deaths trigger bans, natural deaths do not.  
   - Ensure clicking Respawn still triggers the deathban.  
   - Ensure IP + UUID enforcement prevents basic bypass attempts.  
   - Ensure gamemode restoration works for online and newly joining players.  
   - All messages, sounds, placeholders, and config options must function correctly.

**IMPORTANT:** This must fix all previous issues, including players bypassing bans or staying in spectator after unban. Include **every feature discussed**, double-check all placeholders, automatic unban handling, file storage, PvP-only logic, IP + UUID enforcement, spectator → survival restoration, Respawn click enforcement, and admin commands.  
Kodari AI
KodariMar 11 at 5:54 pm 16,709 (v2)

I’ll create a comprehensive Death Ban plugin with all the features you specified.

DeathBanPlugin
A comprehensive PvP death ban system for Paper servers. Players are temporarily banned when killed by other players, with configurable ban durations, spectator mode transitions, and automatic unban handling. Features UUID and IP-based banning, customizable messages with placeholders, sound effects, and admin commands for ban management. Includes automatic gamemode restoration and anti-bypass measures for offline and online players.

All files have been created successfully! The DeathBanPlugin is now complete with:

Core Features Implemented:

  • PvP-only death bans (natural deaths ignored)

  • Spectator mode transition before kick

  • UUID and IP-based banning (configurable)

  • Automatic gamemode restoration for online and joining players

  • Persistent ban storage in bans.yml

  • Scheduled unban checks every 60 seconds (configurable)

  • Custom death sound at killer location

Admin Commands:

  • /deathban unban <player> - Remove ban and restore survival mode

  • /deathban info <player> - View ban details with timestamps

  • /deathban reload - Reload configuration

Anti-Bypass Measures:

  • UUID-based banning (survives name changes)

  • IP-based banning (prevents alt accounts)

  • Respawn button doesn’t bypass (delayed kick system)

  • Automatic gamemode restoration prevents spectator mode stuck

Configuration:

  • 24-hour default ban duration (86400 seconds)

  • 3-second spectator mode before kick

  • Fully customizable messages with placeholders

  • Configurable sound effects

All placeholders work: {player}, {killer}, {duration}, {remaining}, {banned-at}, {unban-at}

The plugin handles all edge cases: online unban notifications, offline player bans, expired ban cleanup, and gamemode restoration for both online and joining players.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
12 795
src/main/java/com/deathban/DeathBanPlugin.java
package com.deathban;

import com.deathban.command.DeathBanCommand;
import com.deathban.listener.DeathListener;
import com.deathban.listener.JoinListener;
import com.deathban.manager.BanManager;
import com.deathban.manager.ConfigManager;
import com.deathban.manager.MessageManager;
import com.deathban.task.UnbanTask;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class DeathBanPlugin extends JavaPlugin {
    private ConfigManager configManager;
    private MessageManager messageManager;
    private BanManager banManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        this.messageManager = new MessageManager(this);
        this.banManager = new BanManager(this);
        
        banManager.loadBans();
        
        Bukkit.getPluginManager().registerEvents(new DeathListener(this), this);
        Bukkit.getPluginManager().registerEvents(new JoinListener(this), this);
        
        getCommand("deathban").setExecutor(new DeathBanCommand(this));
        
        long checkInterval = configManager.getCheckInterval() * 20L;
        Bukkit.getScheduler().runTaskTimer(this, new UnbanTask(this), checkInterval, checkInterval);
        
        getLogger().info("DeathBanPlugin has been enabled!");
    }

    @Override
    public void onDisable() {
        if (banManager != null) {
            banManager.saveBans();
        }
        getLogger().info("DeathBanPlugin has been disabled!");
    }

    public void reload() {
        reloadConfig();
        configManager = new ConfigManager(this);
        messageManager = new MessageManager(this);
        banManager.loadBans();
    }
}