Class FinalDamageFallback
java.lang.Object
studio.magemonkey.codex.api.damage.FinalDamageFallback
- All Implemented Interfaces:
org.bukkit.event.Listener
Fires
FinalDamageEvent for every hit on a living entity that no provider fires it for, so that
consumers always listen to that one event and never ask whether a provider is present.
Codex registers this listener when it enables. It listens to EntityDamageEvent at
EventPriority.HIGHEST, ignoring cancelled events, and for each hit:
- does nothing if
FinalDamageEvent.willFire(EntityDamageEvent)says a provider will fire the event, or if the target is not aLivingEntity; - otherwise fires a
FinalDamageEventwhose only damage type isFinalDamageEvent.DEFAULT_TYPE, holdingEntityDamageEvent.getDamage(); - afterwards cancels the Bukkit event if the
FinalDamageEventwas cancelled, or else sets the Bukkit damage to the new total, but only if the total changed. An untouched hit leaves the Bukkit event alone, so its vanilla damage modifiers stay as they are.
DamageContexts.peek(EntityDamageEvent), never claim: the
fallback only reads it, and leaves it to whoever calculates the hit.
What the fallback fires for
WeaponStatsMode.RAWrequests still fire. RAW asks the calculating plugin not to bring the attacker's weapon stats into the hit. It does not hide the hit from consumers: without a provider, skill plugins such as Fabled have always seen these hits and run their triggers on them, and they keep doing so. A consumer that wants to leave RAW hits alone checksFinalDamageEvent.getWeaponStatsMode().- Hits of 0 damage or less, and fake damage events (such as those a plugin fires only to ask whether an attack would be allowed) are not filtered out. Consumers filter what they do not want.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidonDamage(org.bukkit.event.entity.EntityDamageEvent event) FiresFinalDamageEventfor the hit unless a provider will.
-
Constructor Details
-
FinalDamageFallback
public FinalDamageFallback(@NotNull org.bukkit.plugin.PluginManager pluginManager) - Parameters:
pluginManager- the plugin manager theFinalDamageEventis called through
-
-
Method Details
-
onDamage
public void onDamage(@NotNull org.bukkit.event.entity.EntityDamageEvent event) FiresFinalDamageEventfor the hit unless a provider will. See the class description.- Parameters:
event- the Bukkit damage event
-