From 10c47eff7e90970dd1ef6fbbc0aaf9bd8784e0d5 Mon Sep 17 00:00:00 2001 From: Redecouverte Date: Mon, 21 Feb 2011 23:30:20 +0100 Subject: [PATCH] fixed entity damage events for latest bukkit --- .../bukkit/WorldGuardEntityListener.java | 17 +++++++++++++++-- .../worldguard/bukkit/WorldGuardPlugin.java | 3 --- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java b/src/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java index 426adcc2..1d8fb749 100644 --- a/src/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java +++ b/src/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java @@ -49,7 +49,7 @@ public WorldGuardEntityListener(WorldGuardPlugin plugin) { this.plugin = plugin; } - @Override + public void onEntityDamageByBlock(EntityDamageByBlockEvent event) { Entity defender = event.getEntity(); DamageCause type = event.getCause(); @@ -74,7 +74,7 @@ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) { } } - @Override + public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { Entity attacker = event.getDamager(); Entity defender = event.getEntity(); @@ -156,7 +156,20 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) { } + @Override public void onEntityDamage(EntityDamageEvent event) { + + if (event instanceof EntityDamageByProjectileEvent) { + this.onEntityDamageByProjectile((EntityDamageByProjectileEvent) event); + return; + } else if (event instanceof EntityDamageByEntityEvent) { + this.onEntityDamageByEntity((EntityDamageByEntityEvent) event); + return; + } else if (event instanceof EntityDamageByBlockEvent) { + this.onEntityDamageByBlock((EntityDamageByBlockEvent) event); + return; + } + Entity defender = event.getEntity(); DamageCause type = event.getCause(); diff --git a/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java b/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java index b3ba599c..7d2452f1 100644 --- a/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java +++ b/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java @@ -202,9 +202,6 @@ private void registerEvents() { registerEvent(Event.Type.REDSTONE_CHANGE, blockListener, Priority.High); registerEvent(Event.Type.ENTITY_DAMAGED, entityListener, Priority.High); - registerEvent(Event.Type.ENTITY_DAMAGEDBY_PROJECTILE, entityListener, Priority.High); - registerEvent(Event.Type.ENTITY_DAMAGEDBY_BLOCK, entityListener, Priority.High); - registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.High); registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.High); registerEvent(Event.Type.PLAYER_ITEM, playerListener, Priority.High);