artupo007

could you make a plugin that replicates mechanics of lifesteal world (like reduce max enchanmets, no trade cooldown, need the egg to craft the mace)

Kodari AI
KodariAug 11 at 8:53 pm 2
LifestealWorld
A Minecraft plugin replicating Lifesteal World mechanics. Reduces maximum enchantment levels for all applicable enchantments, removes villager trade cooldowns for instant trading, and requires a specific egg item as a crafting ingredient for the mace. Implements custom crafting recipes, enchantment level caps, and trade cooldown removal to recreate the unique gameplay experience of the Lifesteal World server.
  1. Added a Paper plugin project with Gradle configuration and plugin metadata.

  2. Added configurable maximum enchantment levels, capped during enchanting and anvil combinations.

  3. Added no-trade-cooldown behavior by resetting villager trade uses and increasing max uses.

  4. Added a custom mace recipe requiring Heavy Core, Breeze Rod, and Dragon Egg.

  5. Added XSeries dependency and manifest.kod configuration for cross-version material support.

artupo007

also add the essential mechanics of lifesteal (killing = hearts, a recipe for hearts and a strengh 2 with 8 minutes potion)

Kodari AI
KodariAug 11 at 8:55 pm 1
  1. Add kill-based heart stealing with configurable max-health bounds.

  2. Add a craftable heart item and recipe.

  3. Add a Strength II potion recipe lasting 8 minutes.

  • Register a custom heart item and recipe, with right-click consumption for one permanent heart.

  • Update player max health on PvP kills, bounded by configurable minimum and maximum hearts.

  • Register a custom Strength II potion recipe with an 8-minute effect.

Implemented the essential Lifesteal mechanics:

  • Killing a player:

    • Killer gains 1 heart.

    • Victim loses 1 heart.

    • Configurable minimum and maximum heart limits.

  • Added craftable Heart item:

    • 8 Gold Ingots surrounding a Nether Star.

    • Right-clicking consumes it and grants one permanent heart.

  • Added custom Strength II potion recipe:

    • Lasts 8 minutes.

    • Uses a potion, Blaze Powder, and Redstone.

  • Added configuration options for heart amounts, limits, and potion duration/amplifier.

artupo007

and finally make the cheap golden apple enchant, make the heart recepy more difficult and add the 8 min strengh 2 potion like a 3 option (that you can still make 1:30 strengh 2 and 8 min strengh 1)

Kodari AI
KodariAug 11 at 8:58 pm 1
  1. Add a configurable cheaper enchanted-golden-apple recipe.

  2. Make the heart recipe more difficult without removing heart consumption.

  3. Register potion variants so Strength II remains 1:30, Strength I remains 8:00, and Strength II also has an 8:00 option.

[Generation stopped]

artupo007

and finally make the cheap golden apple craft, make the heart recepy more difficult and add the 8 min strengh 2 potion like a 3 option (that you can still make 1:30 strengh 2 and 8 min strengh 1)

Kodari AI
KodariAug 11 at 8:59 pm 1
  1. Add the cheap enchanted-golden-apple crafting recipe.

  2. Replace the heart recipe with a more difficult recipe.

  3. Add an 8-minute Strength II potion recipe while preserving vanilla Strength II (1:30) and Strength I (8:00).

Implemented:

  • Cheap enchanted golden apple recipe: 8 gold ingots surrounding an apple.

  • More difficult heart recipe: 8 gold blocks surrounding a Nether Star.

  • Strength potion options preserved/added:

    • Strength I — vanilla 8 minutes

    • Strength II — vanilla 1:30

    • Strength II — custom 8-minute recipe using the existing custom recipe

Updated:

  • LifestealWorldPlugin.java

  • config.yml

artupo007

delete the echanted golden apple craft and make the regular golden apple craft requery 4 golden ingots instead of 8, and make that the heart requieres 4 gold blocks, 4 trial keys and a ghast tear

Kodari AI
KodariAug 11 at 9:00 pm 1
  1. Remove the enchanted golden apple recipe.

  2. Change the regular golden apple recipe to require four gold ingots.

  3. Replace the heart recipe with four gold blocks, four trial keys, and one ghast tear.

  • Removed the enchanted golden apple recipe entirely.

  • Added a regular golden apple recipe requiring 4 gold ingots and 1 apple.

  • Updated the heart recipe to require:

    • 4 gold blocks

    • 4 trial keys

    • 1 ghast tear

  • Updated the recipe comments in config.yml.

artupo007

make it for the 1.21.11

Kodari AI
KodariAug 11 at 9:04 pm 1
  1. Update the server API/build target to Minecraft 1.21.11.

  2. Verify the plugin code and recipe materials against the updated API, then patch any compatibility issues.

Updated the plugin for Minecraft/Paper 1.21.11:

  • Changed the Paper API dependency to 1.21.11-R0.1-SNAPSHOT.

  • Updated plugin.yml to use API version 1.21.11.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
settings.gradle
Code
7 370
src/main/java/com/kodari/lifestealworld/LifestealWorldPlugin.java
package com.kodari.lifestealworld;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;

import com.cryptomorin.xseries.XPotion;

public final class LifestealWorldPlugin extends JavaPlugin {

    private NamespacedKey heartItemKey;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        heartItemKey = new NamespacedKey(this, "heart_item");
        getServer().getPluginManager().registerEvents(new LifestealMechanicsListener(this), this);
        registerMaceRecipe();
        registerHeartRecipe();
        registerGoldenAppleRecipe();
        registerStrengthPotionRecipe();
    }

    private void registerMaceRecipe() {
        ItemStack mace = item("MACE");
        Material heavyCore = material("HEAVY_CORE");
        Material breezeRod = material("BREEZE_ROD");

        if (mace == null || heavyCore == null || breezeRod == null) {
            getLogger().warning("The mace recipe could not be registered because this server does not provide mace materials.");
            return;
        }

        NamespacedKey key = new NamespacedKey(this, "lifesteal_mace");
        getServer().removeRecipe(key);

        ShapedRecipe recipe = new ShapedRecipe(key, mace);
        if (getConfig().getBoolean("require-dragon-egg-for-mace", true)) {
            Material dragonEgg = material("DRAGON_EGG");
            if (dragonEgg == null) {
                getLogger().warning("The mace recipe requires a dragon egg, but the material is unavailable.");
                return;
            }
            recipe.shape("E", "H", "B");
            recipe.setIngredient('E', dragonEgg);
        } else {
            recipe.shape("H", "B");
        }
        recipe.setIngredient('H', heavyCore);
        recipe.setIngredient('B', breezeRod);
        getServer().addRecipe(recipe);
    }

    private void registerHeartRecipe() {
        ItemStack heart = createHeartItem();
        Material goldBlock = material("GOLD_BLOCK");
        Material trialKey = material("TRIAL_KEY");
        Material ghastTear = material("GHAST_TEAR");
        if (heart == null || goldBlock == null || trialKey == null || ghastTear == null) {
            getLogger().warning("The heart recipe could not be registered because a required material is unavailable.");
            return;
        }

        NamespacedKey key = new NamespacedKey(this, "lifesteal_heart");
        getServer().removeRecipe(key);
        ShapedRecipe recipe = new ShapedRecipe(key, heart);
        recipe.shape("GKG", "KHK", "GKG");
        recipe.setIngredient('G', goldBlock);
        recipe.setIngredient('K', trialKey);
        recipe.setIngredient('H', ghastTear);
        getServer().addRecipe(recipe);
    }

    private void registerGoldenAppleRecipe() {
        getServer().removeRecipe(new NamespacedKey(this, "lifesteal_enchanted_golden_apple"));
        ItemStack goldenApple = item("GOLDEN_APPLE");
        Material gold = material("GOLD_INGOT");
        Material apple = material("APPLE");
        if (goldenApple == null || gold == null || apple == null) {
            getLogger().warning("The golden apple recipe could not be registered because a required material is unavailable.");
            return;
        }

        NamespacedKey key = new NamespacedKey(this, "lifesteal_golden_apple");
        getServer().removeRecipe(key);
        ShapedRecipe recipe = new ShapedRecipe(key, goldenApple);
        recipe.shape("G G", " A ", "G G");
        recipe.setIngredient('G', gold);
        recipe.setIngredient('A', apple);
        getServer().addRecipe(recipe);
    }

    private void registerStrengthPotionRecipe() {
        ItemStack potion = createStrengthPotion();
        Material blazePowder = material("BLAZE_POWDER");
        Material redstone = material("REDSTONE");
        Material basePotion = material("POTION");
        if (potion == null || blazePowder == null || redstone == null || basePotion == null) {
            getLogger().warning("The Strength potion recipe could not be registered because a required material is unavailable.");
            return;
        }

        NamespacedKey key = new NamespacedKey(this, "lifesteal_strength_two");
        getServer().removeRecipe(key);
        ShapedRecipe recipe = new ShapedRecipe(key, potion);
        recipe.shape("BRB", "RPR", "BRB");
        recipe.setIngredient('B', blazePowder);
        recipe.setIngredient('R', redstone);
        recipe.setIngredient('P', basePotion);
        getServer().addRecipe(recipe);
    }

    ItemStack createHeartItem() {
        ItemStack heart = item("NETHER_STAR");
        if (heart == null) {
            return null;
        }
        ItemMeta meta = heart.getItemMeta();
        if (meta == null) {
            return heart;
        }
        meta.setDisplayName("§cHeart");
        meta.getPersistentDataContainer().set(heartItemKey, PersistentDataType.BYTE, (byte) 1);
        heart.setItemMeta(meta);
        return heart;
    }

    ItemStack createStrengthPotion() {
        ItemStack potion = item("POTION");
        if (potion == null || !(potion.getItemMeta() instanceof PotionMeta meta)) {
            return null;
        }
        int duration = Math.max(1, getConfig().getInt("strength-potion.duration-seconds", 480)) * 20;
        int amplifier = Math.max(0, getConfig().getInt("strength-potion.amplifier", 1));
        XPotion.matchXPotion("STRENGTH")
                .map(effect -> effect.buildPotionEffect(duration, amplifier))
                .ifPresent(effect -> meta.addCustomEffect(effect, true));
        meta.setDisplayName("§cStrength II (8:00)");
        potion.setItemMeta(meta);
        return potion;
    }

    boolean isHeartItem(ItemStack item) {
        if (item == null || !item.hasItemMeta() || heartItemKey == null) {
            return false;
        }
        Byte marker = item.getItemMeta().getPersistentDataContainer().get(heartItemKey, PersistentDataType.BYTE);
        return marker != null && marker == (byte) 1;
    }

    boolean changeMaxHealth(org.bukkit.entity.Player player, double hearts) {
        return com.cryptomorin.xseries.XAttribute.of("max_health").map(attribute -> {
            org.bukkit.attribute.AttributeInstance instance = player.getAttribute(attribute.get());
            if (instance == null) {
                return false;
            }
            double minimum = Math.max(1, getConfig().getInt("lifesteal.min-hearts", 1)) * 2.0;
            double maximum = Math.max(minimum, getConfig().getInt("lifesteal.max-hearts", 20) * 2.0);
            double next = Math.max(minimum, Math.min(maximum, instance.getBaseValue() + hearts * 2.0));
            if (Double.compare(instance.getBaseValue(), next) == 0) {
                return false;
            }
            instance.setBaseValue(next);
            if (player.getHealth() > next) {
                player.setHealth(next);
            }
            return true;
        }).orElse(false);
    }

    private ItemStack item(String name) {
        return XMaterial.matchXMaterial(name).map(XMaterial::parseItem).orElse(null);
    }

    private Material material(String name) {
        return XMaterial.matchXMaterial(name).map(XMaterial::parseMaterial).orElse(null);
    }
}