LifeSteal SMP Plugin

LifeSteal SMP Plugin

14.5k Downloads

Hearts being lost by enviremental damage. (I fixed it for you.)

SirMrStep opened this issue ยท 9 comments

commented

It seems the environmentStealHearts tag in your config wasn't getting checked at the PlayerDeathEvent, so i fixed it for you.
Here is the code (i only added one check)

@EventHandler(priority = EventPriority.HIGHEST)
    public void onKill(PlayerDeathEvent event) {
        Player killed = event.getEntity();
        Player killer = event.getEntity().getKiller();
        if(killer != null) {
            modifyHealth(killer, 2);
            if(shouldEliminate(killed)) {
                eliminate(killed, killer);
                //event.setCancelled(true);
                return;
            }
            modifyHealth(killed, -2);
            return;
        } else {
            if(shouldEliminate(killed)) {
                eliminate(killed, null);
                //event.setCancelled(true);
                return;
            }
            if(Configuration.environmentStealsHearts()) { // < right here
                modifyHealth(killed, -2);
            }
        }

        String killerUUID = Configuration.getKiller(killed.getUniqueId());
        if(killerUUID != null) {
            Player player = Bukkit.getPlayer(UUID.fromString(killerUUID));
            if(player != null) killed.setSpectatorTarget(player);
        }
    }
commented

Fixed as of 1.6 (also craftable hearts)

commented

This is not to be a dick btw, I just wanted to help out.

commented

Indeed, however if you would have looked at the modifyHealth there should be that check already, tho I might have messed up

commented

do i delete the config code and paste that in

commented

Indeed, however if you would have looked at the modifyHealth there should be that check already, tho I might have messed up

You did in fact NOT add this to the modifyHealth and there seems to be another problem. You did not have a minimum health check, so when the player has 2hp and you try to remove 2hp it results in a console error. This is what i am fixing atm.

commented

new code i put for modifyHealth is

    public static void modifyHealth(Player player, int scale) {
        if(getMaxHealth(player).getValue() > 2) {
            AttributeInstance maxHp = getMaxHealth(player);
            maxHp.setBaseValue(maxHp.getValue() + scale);
            if(Configuration.shouldScaleHealth()) player.setHealth(player.getHealth() + scale);
        }
    }
commented

do i delete the config code and paste that in

No, this is java code, I edited the source code of the plugin. If you are not familiar with java I suggest you don't touch it and let the dev update the plugin himself to fix this issue. This is merely me informing him that the issue exist and showing him a way to fix it (mostly fixed it cause some person reached out to me saying he liked this plugin but this feature he wanted to use didn't work properly).

commented

Oh then I forgot to commit! Wops, anyways it was already in ver 1.6 sorry for miscomunication, it should be releasing this month, hopefully

commented

Is three any way you release a jar with just the fix as I can't use the plugin because hearts lost to the environment can't be gained back without commands and it is impossible to keep track of who is supposed to have less hearts and who lost hearts to the environment.