E

minecraft plugin of hearts

Kodari AI
KodariAug 17 at 4:31 pm 3
HeartSystem
A Minecraft plugin that introduces a heart-based health system, replacing traditional health bars with collectible hearts. Players start with a configurable number of hearts and can earn additional hearts by defeating mobs, completing challenges, or finding heart drops. The plugin features a custom GUI for managing hearts, heart loss on death with configurable penalties, and a leaderboard tracking the highest heart counts. Includes support for heart particles, sound effects, and a hearts shop where players can trade resources for extra hearts. Fully configurable via YAML, with per-player heart data stored in a database for persistence across sessions.
  1. Create the Gradle/plugin metadata and configurable heart-stealing settings.

  2. Implement persistent heart storage with cross-version max-health application.

  3. Add player join/respawn/death handling plus /hearts administration commands.

Created a complete Hearts Minecraft plugin featuring:

  • Persistent player heart totals in hearts.yml

  • Heart stealing on player kills

  • Configurable minimum, maximum, initial hearts, and kill rewards

  • Automatic max-health synchronization

  • /hearts, /hearts <player>, /hearts set|add|remove|reset, and /hearts reload

  • Admin permissions and tab completion

  • Cross-version health handling through XSeries

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
8 463
src/main/java/com/kodari/hearts/HeartsPlugin.java
package com.kodari.hearts;

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

public final class HeartsPlugin extends JavaPlugin {

    private HeartManager heartManager;

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

        heartManager = new HeartManager(this);
        getServer().getPluginManager().registerEvents(new HeartsListener(this), this);

        PluginCommand command = getCommand("hearts");
        if (command != null) {
            HeartsCommand heartsCommand = new HeartsCommand(this);
            command.setExecutor(heartsCommand);
            command.setTabCompleter(heartsCommand);
        }
    }

    @Override
    public void onDisable() {
        if (heartManager != null) {
            heartManager.save();
        }
    }

    public HeartManager getHeartManager() {
        return heartManager;
    }

    public String message(String key, String... replacements) {
        String message = getConfig().getString("messages." + key, key);
        for (int i = 0; i + 1 < replacements.length; i += 2) {
            message = message.replace(replacements[i], replacements[i + 1]);
        }
        return ChatColor.translateAlternateColorCodes('&', message);
    }
}