mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
Fix spigot api break for entity damage events
This commit is contained in:
@ -15,7 +15,10 @@ import com.gmail.nossr50.events.experience.McMMOPlayerLevelChangeEvent;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
import com.gmail.nossr50.events.fake.*;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerFishEvent;
|
||||
import com.gmail.nossr50.events.hardcore.McMMOPlayerPreDeathPenaltyEvent;
|
||||
import com.gmail.nossr50.events.hardcore.McMMOPlayerStatLossEvent;
|
||||
import com.gmail.nossr50.events.hardcore.McMMOPlayerVampirismEvent;
|
||||
@ -83,17 +86,6 @@ public final class EventUtils {
|
||||
return event instanceof FakeEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if damage is from natural sources
|
||||
* This cannot be used to determine if damage is from vanilla MC, it just checks to see if the damage is from a complex behaviour in mcMMO such as bleed.
|
||||
*
|
||||
* @param event this event
|
||||
* @return true if damage is NOT from an unnatural mcMMO skill (such as bleed DOTs)
|
||||
*/
|
||||
public static boolean isDamageFromMcMMOComplexBehaviour(@NotNull Event event) {
|
||||
return event instanceof FakeEntityDamageEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* This little method is just to make the code more readable
|
||||
*
|
||||
|
@ -7,8 +7,6 @@ import com.gmail.nossr50.datatypes.meta.OldName;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.metadata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.metadata.MobMetadataService;
|
||||
@ -29,7 +27,6 @@ import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
@ -527,7 +524,6 @@ public final class CombatUtils {
|
||||
* @param target LivingEntity which to attempt to damage
|
||||
* @param damage Amount of damage to attempt to do
|
||||
*/
|
||||
@Deprecated
|
||||
public static void dealDamage(@NotNull LivingEntity target, double damage) {
|
||||
dealDamage(target, damage, DamageCause.CUSTOM, null);
|
||||
}
|
||||
@ -572,10 +568,15 @@ public final class CombatUtils {
|
||||
if (target.isDead()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(canDamage(attacker, target, cause, damage)) {
|
||||
try {
|
||||
// TODO: Check for Spigot API for DamageSource, if DamageSource is found then send out a damage() with a custom damage source
|
||||
applyIgnoreDamageMetadata(target);
|
||||
target.damage(damage);
|
||||
if (attacker != null) {
|
||||
target.damage(damage, attacker);
|
||||
} else {
|
||||
target.damage(damage);
|
||||
}
|
||||
} finally {
|
||||
removeIgnoreDamageMetadata(target);
|
||||
}
|
||||
}
|
||||
@ -885,19 +886,6 @@ public final class CombatUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canDamage(@Nullable Entity attacker, @NotNull Entity target, @NotNull DamageCause damageCause, double damage) {
|
||||
EntityDamageEvent damageEvent;
|
||||
if (attacker != null) {
|
||||
damageEvent = new FakeEntityDamageByEntityEvent(attacker, target, damageCause, damage);
|
||||
} else {
|
||||
damageEvent = new FakeEntityDamageEvent(target, damageCause, damage);
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(damageEvent);
|
||||
|
||||
return !damageEvent.isCancelled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the upgrade tier of the item in hand.
|
||||
*
|
||||
|
Reference in New Issue
Block a user