diff options
author | Wesley Wolfe <wesley.d.wolfe+git@gmail.com> | 2014-07-13 00:04:32 -0500 |
---|---|---|
committer | Wesley Wolfe <wesley.d.wolfe+git@gmail.com> | 2014-07-13 00:07:38 -0500 |
commit | c7398b9fdf058dc99c5a4c84838245a5d3699e59 (patch) | |
tree | 24483fee0535cbe2ca0080fae6cdc732853596d7 /src/main/java/org/bukkit | |
parent | 319a9c20eb4416295e7fb32f0d011ee4ff62ed77 (diff) | |
download | craftbukkit-c7398b9fdf058dc99c5a4c84838245a5d3699e59.tar craftbukkit-c7398b9fdf058dc99c5a4c84838245a5d3699e59.tar.gz craftbukkit-c7398b9fdf058dc99c5a4c84838245a5d3699e59.tar.lz craftbukkit-c7398b9fdf058dc99c5a4c84838245a5d3699e59.tar.xz craftbukkit-c7398b9fdf058dc99c5a4c84838245a5d3699e59.zip |
Provide modifier functions to EntityDamageEvent. Fixes BUKKIT-5688
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 7e277692..2c0065df 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -8,6 +8,7 @@ import java.util.Map; import com.google.common.base.Function; import com.google.common.base.Functions; + import net.minecraft.server.ChunkCoordinates; import net.minecraft.server.Container; import net.minecraft.server.DamageSource; @@ -80,8 +81,6 @@ import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.meta.BookMeta; -import com.google.common.collect.ImmutableMap; - public class CraftEventFactory { public static final DamageSource MELTING = CraftDamageSource.copyOf(DamageSource.BURN); public static final DamageSource POISON = CraftDamageSource.copyOf(DamageSource.MAGIC); @@ -570,7 +569,14 @@ public class CraftEventFactory { if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) { return false; } - EntityDamageEvent event = handleEntityDamageEvent(entity, source, new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, (double) damage)), null); + + final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class); + final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class); + + modifiers.put(DamageModifier.BASE, damage); + functions.put(DamageModifier.BASE, ZERO); + + final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions); if (event == null) { return false; } |