linixity_1412

so create a plugin like when a player kills another player then the player who died will loose 2 hearts and like when a player is at 10 hearts it should show before its username name and after its username a heart symbol first at 10 it should be green colored hearts then at 8 it should be like yellow and at 6 light yellow at 4 orange and at 2 red and after he dies while being on 2 hearts he should be banned from the server

Kodari AI
KodariApr 17 at 12:31 pm 12,674 (v2)
HardcoreHearts
A PvP hardcore hearts plugin where players lose 2 hearts upon being killed by another player. The player's nametag displays colored heart symbols (prefix and suffix) reflecting their current heart count: green at 10, yellow at 8, light yellow at 6, orange at 4, and red at 2. If a player dies while at their last 2 hearts, they are permanently banned from the server. Heart data persists across restarts via YAML storage.

Planning the class structure:

  • HardcoreHearts — main plugin, initializes all managers

  • DataManager — loads/saves player heart data to YAML

  • HeartManager — applies max health via XAttribute, manages scoreboard team nametags

  • PlayerListener — handles PvP death, respawn, and join events

  • Scoreboard teams per heart tier (10/8/6/4/2) with colored ❤ prefix and suffix

Here’s a summary of everything built:

HardcoreHearts — fully functional plugin with:

  • PvP Death System — only player kills trigger heart loss (2 hearts per death), self/environmental deaths are ignored

  • Nametag Display — scoreboard teams apply colored ❤ as prefix & suffix around the player name: 🟢 green (10) → 🟡 yellow (8) → ⚪ light (6) → 🟠 orange (4) → 🔴 red (2)

  • Permanent Ban — when a player at ≤2 hearts is killed, they are banned via Bukkit’s BanList with a configurable message

  • Data Persistence — heart counts saved to data.yml, survive server restarts and carry over on rejoin

  • Admin Commands — /sethearts <player> <amount> and /resethearts <player> for manual management; /hearts [player] for checking counts

  • All values (max hearts, hearts lost, messages, ban message) are configurable in config.yml

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
11 540
src/main/java/com/hardcorehearts/HardcoreHearts.java
package com.hardcorehearts;

import com.hardcorehearts.commands.HeartsCommand;
import com.hardcorehearts.commands.SetHeartsCommand;
import com.hardcorehearts.commands.ResetHeartsCommand;
import com.hardcorehearts.listeners.PlayerListener;
import com.hardcorehearts.managers.DataManager;
import com.hardcorehearts.managers.HeartManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

public class HardcoreHearts extends JavaPlugin {

    @Getter private DataManager dataManager;
    @Getter private HeartManager heartManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        this.dataManager = new DataManager(this);
        this.heartManager = new HeartManager(this);
        dataManager.load();
        heartManager.setupTeams();
        getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
        getCommand("hearts").setExecutor(new HeartsCommand(this));
        getCommand("sethearts").setExecutor(new SetHeartsCommand(this));
        getCommand("resethearts").setExecutor(new ResetHeartsCommand(this));
        getLogger().info("HardcoreHearts enabled.");
    }

    @Override
    public void onDisable() {
        if (dataManager != null) {
            dataManager.saveAll();
        }
        if (heartManager != null) {
            heartManager.removeTeams();
        }
        getLogger().info("HardcoreHearts disabled.");
    }
}