Fix spigot api break for entity damage events

This commit is contained in:
nossr50
2024-02-13 17:47:54 -08:00
parent 94754b150c
commit 5bfca3c218
8 changed files with 47 additions and 112 deletions

View File

@@ -1,7 +1,6 @@
package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.skills.rupture.McMMOEntityDamageByRuptureEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
@@ -83,18 +82,14 @@ public class RuptureTask extends CancellableRunnable {
//Ensure victim has health
if (healthBeforeRuptureIsApplied > 0.01) {
//Send a fake damage event
McMMOEntityDamageByRuptureEvent event = new McMMOEntityDamageByRuptureEvent(ruptureSource, targetEntity, calculateAdjustedTickDamage());
mcMMO.p.getServer().getPluginManager().callEvent(event);
// TODO: Needs updating for new spigot API
double damage = calculateAdjustedTickDamage(); //Use raw damage for Rupture
//Ensure the event wasn't cancelled and damage is still greater than 0
double damage = event.getDamage(); //Use raw damage for Rupture
if (event.isCancelled() || damage <= 0 || healthBeforeRuptureIsApplied - damage <= 0)
if (damage <= 0 || healthBeforeRuptureIsApplied - damage <= 0) {
return true;
}
double damagedHealth = healthBeforeRuptureIsApplied - damage;
targetEntity.setHealth(damagedHealth); //Hurt entity without the unwanted side effects of damage()}
}