Zac Grogan

create a plugin that puts 3 blue hearts where your xp amount would be (above the bar). when you are killed by a player, you will loose 1 heart but if killed by anything else, you will not loose them. when you die and have 0 blue hearts left, you will not be able to go into survival mode unless a server opperator does /revive <player>. the player that has lost all blue hearts will respawn in spectator mode. if you kill a player, you will recive an enchantment upgrade on your armour and tools ( e.g. prot 1 and eff 3 will go to prot 2 and eff 4 ) you may not be able to obtain any enchantment above level 2 on any item. if a book that nattuyrally generates has a higher enchantment level, it will decrese when the chest loot is generated. librarian villagers will only be able to sell enchanted books at level 1. the only waty to obtain higher enchantments is to kill another player. also make armour trims give armour + durabuility depending on how rare the trim is and the material with silence armour trim giving +250 dura with diamond and coast giving +25 dura with diamond. make enchanted golden apples give 1 blue heart but cannot be found in the wild. it must be crafted with 4 neth ingots and 1 totem of undying in any combination. also make it so you cant have more than 2 totems in your inventory at once ( offhand and inside shulkers included). also make it that elytras cannot be enchanted. also add a /mobs <on | off> toggle for anyone to use to prevent hostile mobs from spawning.

Kodari AI
KodariSep 7 at 6:09 am 11
HeartboundSurvival
Adds a blue heart system above the XP bar where players start with 3 hearts. Player kills grant one enchantment upgrade to armor and tools, capped at level 2, while naturally generated enchanted books are downgraded and librarians sell only level 1 books. Armor trims provide bonus durability based on rarity and material. Enchanted golden apples are craftable with 4 netherite ingots and 1 totem, granting a blue heart, but cannot be found in the wild. Players with zero hearts respawn in spectator mode and require /revive from an operator to return to survival. Limits totem inventory to 2, prevents elytra enchanting, and adds a /mobs toggle to disable hostile spawning.
  1. Create the Paper plugin foundation and commands.

  2. Implement persistent blue-heart lives, death, respawn, and revival rules.

  3. Enforce combat enchant progression, loot/trade limits, trims, and elytra restrictions.

  4. Add enchanted-apple crafting, totem limits, and hostile-mob toggling.

Created the BlueHearts Paper plugin with persistent lives, PvP-only heart loss, spectator lockout/revival, PvP enchant upgrades, loot/trade enchant restrictions, trim durability bonuses, custom enchanted-apple crafting, recursive totem limits, elytra enchant blocking, and /mobs hostile-spawn toggling.

Zac Grogan

hi, two things, the hearts arnt accual hearts so could you get the accual heart icon, not the skinny heart. it would be good if you sorced minecfafts accual heart emojie instead of a icon but both work either way. i want the writing next to the hearts removed and they replace the spot where your xp bar displays your levels. 2nd thing, item upgrades dont work since you cant enchant the same item twice. can you delete the item when its upgraded and replace it with the same item and trims but just 1 level of enchantment higher e.g. prot 1 + upgrade/kill = prot 2. make sure whatever is upgraded goes back to the same item slot that is was in before the kill. also make it if any player kills another player, the player that killed the player gets resistance 10 for 30 seconds to help prevent any unset timing with the inventory restock. make sure however you do it, the player that kills another player will recive an enchant upgrade. make sure upgraded cap out at their max. also if its possible, can you make the player have 20 hearts but the top layer is absorption hearts. these hearts will auto regen back to 10 hearts. the regeneration time will take 1m per heart. absorption hearts will only be taken if a mob or player attacks another player. also fix the /mobs because it needs to only turn off mobs for those who have it turned off. e.g. 2 players have it on and 1 doesnt like the mobs, when player 1 turns it off, mobs will still spawn for player 2

Kodari AI
KodariSep 9 at 7:13 am 12
  1. Replace the blue-heart display with Minecraft heart glyphs at the XP-level position, and add regenerating combat-only absorption health.

  2. Rebuild PvP item upgrades so upgraded items keep their slot, trims, and capped enchantments; add a short kill-protection effect.

  3. Make /mobs a per-player hostile-mob visibility toggle.

  • Use the heavier ❤ glyph without label text and suppress the vanilla XP-level number.

  • Give every player a ten-heart absorption layer, restoring one heart every minute.

  • Preserve that layer against environmental damage while allowing player- and hostile-mob combat to consume it.

  1. Item upgrades: replacing each eligible item in its original inventory slot after removing and reapplying each increased enchantment.

  2. Kill protection: applying Resistance X for 30 seconds immediately after a player kill.3. /mobs: storing each player’s preference and hiding hostile mobs only from players who choose off, without changing spawning for everyone else.

  1. Heart display now uses solid Minecraft-style ❤ glyphs with no label and suppresses the XP-level number.

  2. Added a 10-heart absorption layer that restores one heart per minute. Environmental damage preserves it; player and hostile-mob attacks can consume it.

  3. PvP upgrades now clone and replace eligible armor/tools in their original slots, preserving trims and item data while increasing enchantments only up to level 2. Killers receive Resistance X for 30 seconds.

  4. /mobs off now hides hostile mobs only for the player who runs it; mobs remain visible and continue spawning for everyone else.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 720
src/main/java/com/kodari/bluehearts/BlueHeartsPlugin.java
package com.kodari.bluehearts;

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.block.ShulkerBox;
import org.bukkit.block.BlockState;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentOffer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerItemDamageEvent;
import org.bukkit.event.entity.VillagerAcquireTradeEvent;
import org.bukkit.event.enchantment.EnchantItemEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.PrepareAnvilEvent;
import org.bukkit.event.enchantment.PrepareItemEnchantEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.world.LootGenerateEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.MerchantRecipe;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.meta.ArmorMeta;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class BlueHeartsPlugin extends JavaPlugin implements Listener, CommandExecutor {

    private static final int MAX_HEARTS = 3;
    private static final int MAX_ENCHANT_LEVEL = 2;
    private static final double MAX_ABSORPTION = 20.0;
    private static final double ABSORPTION_REGEN_PER_MINUTE = 2.0;

    private NamespacedKey heartsKey;
    private NamespacedKey absorptionInitializedKey;
    private NamespacedKey absorptionRegenAtKey;
    private NamespacedKey hostileMobsDisabledKey;
    private NamespacedKey trimInitializedKey;
    private NamespacedKey trimDurabilityKey;
    private NamespacedKey enchantedAppleRecipeKey;

    @Override
    public void onEnable() {
        heartsKey = new NamespacedKey(this, "blue_hearts");
        absorptionInitializedKey = new NamespacedKey(this, "combat_absorption_initialized");
        absorptionRegenAtKey = new NamespacedKey(this, "combat_absorption_regen_at");
        hostileMobsDisabledKey = new NamespacedKey(this, "hostile_mobs_disabled");
        trimInitializedKey = new NamespacedKey(this, "trim_durability_initialized");
        trimDurabilityKey = new NamespacedKey(this, "trim_durability_remaining");
        enchantedAppleRecipeKey = new NamespacedKey(this, "enchanted_golden_apple");

        Bukkit.getPluginManager().registerEvents(this, this);
        Objects.requireNonNull(getCommand("revive")).setExecutor(this);
        Objects.requireNonNull(getCommand("mobs")).setExecutor(this);
        registerEnchantedAppleRecipe();

        Bukkit.getScheduler().runTaskTimer(this, () -> {
            for (Player player : Bukkit.getOnlinePlayers()) {
                ensureHearts(player);
                regenerateCombatAbsorption(player);
                enforceTotemLimit(player);
                sanitizeInventory(player.getInventory());
                if (isHostileMobsDisabled(player)) {
                    setHostileMobVisibility(player, false);
                }
                showHearts(player);
            }
        }, 20L, 20L);
    }

    private void registerEnchantedAppleRecipe() {
        Material enchantedApple = material("ENCHANTED_GOLDEN_APPLE");
        Material netheriteIngot = material("NETHERITE_INGOT");
        Material totem = material("TOTEM_OF_UNDYING");
        if (enchantedApple == null || netheriteIngot == null || totem == null) {
            return;
        }

        ShapelessRecipe recipe = new ShapelessRecipe(enchantedAppleRecipeKey, new ItemStack(enchantedApple));
        recipe.addIngredient(4, netheriteIngot);
        recipe.addIngredient(totem);
        Bukkit.addRecipe(recipe);
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        ensureHearts(event.getPlayer());
        initializeCombatAbsorption(event.getPlayer());
        enforceTotemLimit(event.getPlayer());
        sanitizeInventory(event.getPlayer().getInventory());
        showHearts(event.getPlayer());
    }

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onPlayerDeath(PlayerDeathEvent event) {
        Player victim = event.getEntity();
        ensureHearts(victim);

        Player killer = victim.getKiller();
        if (killer == null) {
            return;
        }

        setHearts(victim, Math.max(0, getHearts(victim) - 1));
        upgradeKillerEquipment(killer);
        XPotion.matchXPotion("DAMAGE_RESISTANCE")
                .map(potion -> potion.buildPotionEffect(600, 9))
                .ifPresent(killer::addPotionEffect);
        showHearts(killer);
    }

    @EventHandler
    public void onRespawn(PlayerRespawnEvent event) {
        Player player = event.getPlayer();
        if (getHearts(player) > 0) {
            return;
        }

        Bukkit.getScheduler().runTask(this, () -> {
            player.setGameMode(GameMode.SPECTATOR);
            player.sendMessage(ChatColor.BLUE + "You have no blue hearts remaining. An operator must use /revive " + player.getName() + ".");
        });
    }

    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    public void onGameModeChange(PlayerGameModeChangeEvent event) {
        if (event.getNewGameMode() == GameMode.SURVIVAL && getHearts(event.getPlayer()) == 0) {
            event.setCancelled(true);
            event.getPlayer().sendMessage(ChatColor.BLUE + "You need an operator to revive you before entering survival mode.");
        }
    }

    @EventHandler(ignoreCancelled = true)
    public void onEnchantedAppleConsume(PlayerItemConsumeEvent event) {
        if (!isType(event.getItem(), "ENCHANTED_GOLDEN_APPLE")) {
            return;
        }

        Player player = event.getPlayer();
        setHearts(player, Math.min(MAX_HEARTS, getHearts(player) + 1));
        showHearts(player);
    }

    @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
    public void onNonCombatDamage(EntityDamageEvent event) {
        if (!(event.getEntity() instanceof Player player) || isCombatDamage(event)) {
            return;
        }

        double absorption = player.getAbsorptionAmount();
        if (absorption <= 0.0) {
            return;
        }

        player.setAbsorptionAmount(0.0);
        Bukkit.getScheduler().runTask(this, () -> {
            if (player.isOnline()) {
                player.setAbsorptionAmount(Math.max(player.getAbsorptionAmount(), absorption));
            }
        });
    }

    @EventHandler(ignoreCancelled = true)
    public void onEnchant(EnchantItemEvent event) {
        if (isType(event.getItem(), "ELYTRA")) {
            event.setCancelled(true);
            event.getEnchanter().sendMessage(ChatColor.RED + "Elytras cannot be enchanted.");
            return;
        }
        event.getEnchantsToAdd().replaceAll((enchantment, level) -> Math.min(MAX_ENCHANT_LEVEL, level));