dfdgf
📎 1 file 4,727 chars
📄
pasted-code-1791646681118.txt
txt 78 lines
▶
Create a complete, production-ready Lifesteal plugin for Paper 1.21.11 (Java 21, Maven or Gradle, using the Paper API). Provide the full project structure and all source files, ready to compile.

CORE FEATURES

1. Heart system
   - Every player starts with 10 hearts (20 HP) by default (configurable).
   - Hearts are stored as max health using the GENERIC_MAX_HEALTH attribute (use the correct 1.21 attribute name: Attribute.MAX_HEALTH).
   - Persist each player's heart count (use PersistentDataContainer or a data.yml/SQLite file) so it survives restarts and relogs.
   - Configurable minimum hearts (default 1) and maximum hearts (default 20, or unlimited).

2. Lifesteal on kill
   - When a player kills another player, the killer gains 1 heart (+2 max HP) and the victim loses 1 heart.
   - If the killer is already at max hearts, drop a Heart item instead of adding one.
   - Only count PvP kills (player killed by player). Optional config: whether natural/environment deaths also cost a heart.
   - Handle edge cases: kill by projectile (arrows, tridents), kill by pet is ignored, no heart gain for killing the same player repeatedly within X seconds (optional anti-farming, configurable).

3. Elimination
   - When a player reaches 0 hearts, they are banned or put into spectator mode (configurable), with a custom message. Add an option for revival.

4. Withdraw heart command
   - Command: /withdraw heart (also alias /withdrawheart). Optionally support /withdraw heart .
   - Removes 1 heart (2 max HP) from the player and gives them a Heart item.
   - Block withdrawal if it would drop the player below the minimum hearts.
   - Send clear success/error messages.

5. Heart item with custom texture
   - The Heart item must look like an actual heart in the inventory and in hand.
   - Use a custom resource-pack-based model with the 1.21.x item model system:
       * Set the `item_model` data component (e.g. "lifesteal:heart") on the item, OR use CustomModelData (the new component format), whichever is correct for 1.21.11.
       * Base item: NETHER_STAR or RED_DYE (configurable).
   - Also generate the resource pack:
       * pack.mcmeta with the correct pack_format for 1.21.11
       * assets/lifesteal/items/heart.json (item model definition)
       * assets/lifesteal/models/item/heart.json
       * assets/lifesteal/textures/item/heart.png (describe how to create a 16x16 pixel heart, or provide a Python/Java snippet that generates the PNG)
   - Give instructions to host the pack and force it on players via server.properties (resource-pack, resource-pack-sha1, require-resource-pack) or via Paper's API.
   - Heart item should have: custom display name (e.g. "§c❤ Heart"), lore, enchant glint, and a PDC tag so it cannot be faked via an anvil rename.

6. Using the Heart item
   - Right-click with the Heart item to consume it and gain 1 heart (+2 max HP).
   - Respect the max hearts limit, show a message, and play a sound/particle effect on use.

7. Death effects
   - When a player dies, spawn a lightning strike at the death location using world.strikeLightningEffect() (visual only, no damage or fire).
   - Play a sound at the death location (e.g. Sound.ENTITY_LIGHTNING_BOLT_THUNDER or ENTITY_WITHER_DEATH), configurable.
   - Optional: broadcast a custom death message, such as "§c lost a heart to ".

CONFIGURATION (config.yml)
   - Starting hearts, min hearts, max hearts
   - Lightning on/off, sound name, volume, pitch
   - Action at 0 hearts (BAN / SPECTATOR)
   - Heart item material, name, lore, item model key
   - All messages (with color codes / MiniMessage support)
   - Anti-farming cooldown

COMMANDS & PERMISSIONS
   - /withdraw heart  -> lifesteal.withdraw (default: true)
   - /lifesteal reload -> lifesteal.admin
   - /lifesteal sethearts   -> lifesteal.admin
   - /lifesteal give   -> lifesteal.admin
   - /lifesteal revive  -> lifesteal.admin
   - Tab completion for all commands.

CODE QUALITY
   - Use the modern Paper API (Adventure/MiniMessage, no deprecated methods).
   - Clean package structure: commands, listeners, managers, utils.
   - plugin.yml with api-version: '1.21'.
   - Handle player join (reapply saved max health), respawn (max health resets on respawn, so reapply it), and quit.
   - Null-safe, thread-safe, and with comments explaining key parts.

OUTPUT FORMAT
   1. Project folder tree
   2. pom.xml (or build.gradle)
   3. plugin.yml and config.yml
   4. All Java classes in full
   5. Full resource pack files + texture generation instructions
   6. Build and install steps
   7. A short testing checklist
Kodari AI
KodariOct 10 at 3:40 pm 2
LifestealHearts
A comprehensive Lifesteal plugin for Paper 1.21.11 that implements a heart-based PvP system. Players start with configurable hearts, gain hearts by killing opponents, and lose hearts when killed. Features include persistent heart storage, elimination mechanics (ban or spectator), a withdraw heart command, custom heart items with resource pack integration, anti-farming cooldowns, death effects like lightning strikes, and full admin commands for managing hearts and reviving players. Built with modern Paper API using Adventure/MiniMessage, PersistentDataContainer for data persistence, and a complete resource pack generation system for custom heart textures.
  1. Create the Gradle project, plugin descriptor, and configurable defaults.

  2. Implement persisted heart management, tagged heart items, PvP/death handling, and commands.

  3. Add the 1.21 item-model resource-pack definitions and setup notes.

Created the Lifesteal project with persisted hearts, PvP transfers and anti-farming cooldown, elimination, tagged heart items, commands, configuration, and the 1.21 item-model resource-pack definitions.

Project structure

Plain Text
settings.gradle
build.gradle
src/main/resources/
  plugin.yml
  config.yml
src/main/java/com/kodari/lifesteal/
  LifestealPlugin.java
  command/
    LifestealCommand.java
    WithdrawCommand.java
  listener/
    LifestealListener.java
  manager/
    HeartItemManager.java
    HeartManager.java
  util/
    Messages.java
resource-pack/
  pack.mcmeta
  README.txt
  assets/lifesteal/items/heart.json
  assets/lifesteal/models/item/heart.json

The resource-pack JSON is included, but the heart.png texture is not: texture generation is disabled for this project. Enable it via Settings → Generation and ask for the 16×16 heart texture, or enable it for all projects at https://kodari.ai/settings?tab=features. Then add the PNG at resource-pack/assets/lifesteal/textures/item/heart.png.

Build and install: Click Compile in the top bar (phone: ⋮ → Compile Project), then click Compile in the window. Download the successful build and place the JAR in the server’s plugins folder. Host the completed resource-pack ZIP over HTTPS and configure the server to send it to players.

Quick test checklist: Verify starting hearts and saved hearts after relog/restart; PvP transfers, max-heart item drops, cooldown, and zero-heart elimination; /withdraw heart [amount], /lifesteal sethearts, /lifesteal give, /lifesteal revive, and heart-item use at and below the heart limit.

dfdgf

i have all files of a plugin can you compile it??

Kodari AI
KodariOct 10 at 3:43 pm 1

Yes. On desktop, click Compile in the top bar; on phone, tap ⋮ → Compile Project. Then click Compile in the window. When it succeeds, click Download to get the plugin JAR.

Kodari can make mistakes. Review important code before using.
Files
resource-pack
src
build.gradle
settings.gradle
Code
15 771
src/main/java/com/kodari/lifesteal/LifestealPlugin.java
package com.kodari.lifesteal;

import com.kodari.lifesteal.command.LifestealCommand;
import com.kodari.lifesteal.command.WithdrawCommand;
import com.kodari.lifesteal.listener.LifestealListener;
import com.kodari.lifesteal.manager.HeartItemManager;
import com.kodari.lifesteal.manager.HeartManager;
import com.kodari.lifesteal.util.Messages;
import net.kyori.adventure.text.Component;
import org.bukkit.BanList;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Date;
import java.util.Objects;

public final class LifestealPlugin extends JavaPlugin {
    private HeartManager heartManager;
    private HeartItemManager heartItemManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        this.heartManager = new HeartManager(this);
        this.heartItemManager = new HeartItemManager(this);

        LifestealListener listener = new LifestealListener(this);
        Bukkit.getPluginManager().registerEvents(listener, this);

        LifestealCommand lifestealCommand = new LifestealCommand(this);
        Objects.requireNonNull(getCommand("lifesteal")).setExecutor(lifestealCommand);
        Objects.requireNonNull(getCommand("lifesteal")).setTabCompleter(lifestealCommand);
        WithdrawCommand withdrawCommand = new WithdrawCommand(this);
        Objects.requireNonNull(getCommand("withdraw")).setExecutor(withdrawCommand);
        Objects.requireNonNull(getCommand("withdraw")).setTabCompleter(withdrawCommand);

        for (Player player : Bukkit.getOnlinePlayers()) {
            heartManager.loadPlayer(player);
        }
    }

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

    public HeartManager getHeartManager() {
        return heartManager;
    }

    public HeartItemManager getHeartItemManager() {
        return heartItemManager;
    }

    public void send(Player player, String message) {
        player.sendMessage(Messages.component(getConfig().getString("messages.prefix", "") + message));
    }

    public void eliminate(Player player) {
        String action = getConfig().getString("elimination.action", "BAN");
        String message = getConfig().getString("elimination.message", "<red>You have been eliminated.</red>")
                .replace("<player>", player.getName());
        Component component = Messages.component(message);
        if ("SPECTATOR".equalsIgnoreCase(action)) {
            player.setGameMode(GameMode.SPECTATOR);
            send(player, getConfig().getString("messages.eliminated", "<red>You have been eliminated.</red>"));
            return;
        }
        Bukkit.getBanList(BanList.Type.NAME).addBan(player.getName(), message, (Date) null, getName());
        Bukkit.getScheduler().runTask(this, () -> player.kick(component));
    }
}