sp1ky14

Create me a lifesteal plugins:

when you kill a player you get 1 heart and the victim lost 1 heart (only lose heart when get kill by players not environment kills) and the max heart a player can get is 15, so when a maxed out heart players kill another player, instead of getting another heart since its maxed, a heart will fall out (item - wither star) and when a player right click the heart they will get 1 heart.

also add this only admin command:

/heart add/remove (player) (amount)

/heartcheck (player) - to check how many heart a player have

Kodari AI
KodariJul 28 at 7:31 am 4
LifestealHearts
A player-versus-player lifesteal plugin where killing another player grants the killer one heart and removes one heart from the victim. Players can reach a maximum of 15 hearts. When a maxed player earns a heart, a collectible Nether Star heart drops instead. Right-clicking the heart item grants one heart. Includes persistent heart storage, join synchronization, environment-kill protection, and operator-only commands for adding, removing, and checking player hearts.
  • Create the Gradle project and plugin metadata.

  • Implement persistent heart management and maximum-health synchronization.

  • Add player-kill rewards, heart drops, and right-click heart consumption.

  • Add operator-only /heart and /heartcheck commands.

sp1ky14

when a player got killed and lost all the heart they didnt got ban, they get set at 1 heart forever so pls fix it

Kodari AI
KodariJul 29 at 6:18 am 4

Fixed:

  • Minimum hearts can now reach 0 instead of being clamped to 1.

  • When a player loses their final heart from a player kill, they are permanently banned and kicked.

  • Their heart count is saved as 0.

  • Their maximum health is safely set to 1 HP before removal.

  • Environment deaths still do not remove hearts or ban players.

sp1ky14

its still give player 1 heart after they died with 1 heart left, for example:

1 have 1 heart left, and a player kill me, instead of getting ban i get respawn with still 1 heart left and they still get another heart, PLS FIX IT BRO

Kodari AI
KodariJul 29 at 7:26 am 2

I’ll fix the death flow so the victim reaches 0 hearts before respawn, is banned immediately, and the killer only receives the heart when the victim is not eliminated.

Fixed the actual issue:

  • A victim who had 1 heart now gets set to 0 hearts, not 1.

  • They are banned and kicked immediately.

  • The killer does not receive a heart when the victim is eliminated.

  • The victim’s 0-heart value is saved, so they cannot respawn with 1 heart.

sp1ky14

nono, for the victim who only got 1 hearts left, the killer still get the heart when they get eliminated but i just want the victim who only got 1 hearts left to get BANED immediately, and broadcast to the whole server that the victim just get eliminated

Kodari AI
KodariJul 29 at 7:30 am 2

Fixed the elimination flow:

  • A player with 1 heart who is killed is set to 0 hearts.

  • They are immediately banned and kicked.

  • The killer still receives the 1 heart as normal.

  • A server-wide broadcast announces the eliminated player.

  • The eliminated player cannot respawn with 1 heart because their saved value remains 0.

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

import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public final class LifestealPlugin extends JavaPlugin {

    private HeartManager heartManager;

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

        heartManager = new HeartManager(this);
        heartManager.load();

        getServer().getPluginManager().registerEvents(new LifestealListener(heartManager), this);

        HeartCommand heartCommand = new HeartCommand(heartManager);

        PluginCommand heart = getCommand("heart");
        if (heart != null) {
            heart.setExecutor(heartCommand);
            heart.setTabCompleter(heartCommand);
        }

        PluginCommand heartCheck = getCommand("heartcheck");
        if (heartCheck != null) {
            heartCheck.setExecutor(heartCommand);
            heartCheck.setTabCompleter(heartCommand);
        }

        for (Player player : Bukkit.getOnlinePlayers()) {
            heartManager.applyHealth(player, 0);
        }
    }

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