jojomaciel09

make me a hardcore plugin that if you die then you get automatically permanently banned from the server

Kodari AI
KodariMay 11 at 5:39 am 4,919 (v2)

I’ll create a hardcore mode plugin that permanently bans players upon death.

HardcoreBans
A hardcore survival plugin that permanently bans players from the server when they die. Features include configurable ban messages, death broadcasts, admin bypass permissions, and optional respawn grace period. Perfect for creating high-stakes hardcore servers where every decision matters. Supports custom ban reasons and automatic cleanup of player data upon permanent ban.

Created HardcoreBans — a hardcore survival plugin that permanently bans players when they die.

Features:

  • Automatic permanent ban on death

  • Configurable ban messages with custom messages per death cause (fall, lava, drowning, void, mob attacks)

  • Death broadcasts to notify all players when someone is banned

  • Admin bypass permission (hardcorebans.bypass) for staff/testing

  • Optional player data deletion (playerdata, stats, advancements)

  • Admin command /hardcorebans reload to reload config without restart

  • Fully configurable enable/disable toggle

  • Support for temporary bans (configurable duration)

The plugin is ready to use — just build and drop it on your server for maximum hardcore mode!

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
5 259
src/main/java/com/hardcorebans/HardcoreBans.java
package com.hardcorebans;

import com.hardcorebans.listeners.DeathListener;
import lombok.Getter;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class HardcoreBans extends JavaPlugin {

    private DeathListener deathListener;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.deathListener = new DeathListener(this);
        getServer().getPluginManager().registerEvents(deathListener, this);
        
        getLogger().info("HardcoreBans has been enabled!");
        getLogger().info("Hardcore mode is " + (getConfig().getBoolean("enabled") ? "ACTIVE" : "DISABLED"));
    }

    @Override
    public void onDisable() {
        getLogger().info("HardcoreBans has been disabled!");
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (command.getName().equalsIgnoreCase("hardcorebans")) {
            if (!sender.hasPermission("hardcorebans.admin")) {
                sender.sendMessage(color("&cYou don't have permission to use this command!"));
                return true;
            }

            if (args.length == 0) {
                sender.sendMessage(color("&6&lHardcoreBans &7v" + getDescription().getVersion()));
                sender.sendMessage(color("&7Status: " + (getConfig().getBoolean("enabled") ? "&aEnabled" : "&cDisabled")));
                sender.sendMessage(color("&7Use &e/hardcorebans reload &7to reload the config"));
                return true;
            }

            if (args[0].equalsIgnoreCase("reload")) {
                reloadConfig();
                sender.sendMessage(color("&aConfiguration reloaded successfully!"));
                sender.sendMessage(color("&7Hardcore mode is now " + (getConfig().getBoolean("enabled") ? "&aENABLED" : "&cDISABLED")));
                return true;
            }

            sender.sendMessage(color("&cUsage: /hardcorebans [reload]"));
            return true;
        }

        return false;
    }

    public String color(String text) {
        return ChatColor.translateAlternateColorCodes('&', text);
    }

    public String getBanReason(String deathCause) {
        FileConfiguration config = getConfig();
        
        if (config.contains("custom-messages." + deathCause)) {
            String customMessage = config.getString("custom-messages." + deathCause);
            if (customMessage != null && !customMessage.isEmpty()) {
                return color(customMessage);
            }
        }
        
        return color(config.getString("ban-reason", "&cYou died in hardcore mode! You are permanently banned."));
    }
}