This commit is contained in:
nossr50
2024-02-14 13:11:32 -08:00
parent 5bfca3c218
commit 85f27fdbdb
5 changed files with 79 additions and 28 deletions

View File

@@ -1,9 +1,12 @@
package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.datatypes.MobHealthbarType;
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;
import com.gmail.nossr50.util.MobHealthbarUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.google.common.base.Objects;
import org.bukkit.entity.LivingEntity;
@@ -82,15 +85,21 @@ public class RuptureTask extends CancellableRunnable {
//Ensure victim has health
if (healthBeforeRuptureIsApplied > 0.01) {
// TODO: Needs updating for new spigot API
double damage = calculateAdjustedTickDamage(); //Use raw damage for Rupture
//Send a fake damage event
McMMOEntityDamageByRuptureEvent event =
new McMMOEntityDamageByRuptureEvent(ruptureSource, targetEntity, calculateAdjustedTickDamage());
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (damage <= 0 || healthBeforeRuptureIsApplied - damage <= 0) {
//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)
return true;
}
double damagedHealth = healthBeforeRuptureIsApplied - damage;
targetEntity.setHealth(damagedHealth); //Hurt entity without the unwanted side effects of damage()}
MobHealthbarUtils.handleMobHealthbars(targetEntity, damage, mcMMO.p);
}
return false;