diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index be4a5a52e..cc1518b34 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -4,6 +4,7 @@ import java.net.InetAddress; import java.util.List; import net.minecraft.server.ChunkCoordinates; +import net.minecraft.server.Entity; import net.minecraft.server.EntityBlaze; import net.minecraft.server.EntityCaveSpider; import net.minecraft.server.EntityChicken; @@ -56,6 +57,7 @@ import org.bukkit.event.Event.Type; import org.bukkit.event.block.*; import org.bukkit.event.entity.*; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.*; import org.bukkit.event.server.ServerListPingEvent; @@ -353,4 +355,19 @@ public class CraftEventFactory { craftServer.getPluginManager().callEvent(event); return event; } + + /** + * EntityDamage(ByEntityEvent) + */ + public static EntityDamageEvent callEntityDamageEvent(Entity damager, EntityLiving damagee, DamageCause cause, int damage) { + EntityDamageEvent event; + if (damager != null) { + event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, damage); + } else { + event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, damage); + } + Bukkit.getPluginManager().callEvent(event); + + return event; + } }