From 09557e378b07d414223aa43a590f5255fbfc1702 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sat, 1 Feb 2014 00:33:28 +0100 Subject: [PATCH] Update to the new ProjectileSource API --- pom.xml | 2 +- .../java/com/gmail/nossr50/listeners/EntityListener.java | 7 ++++++- .../java/com/gmail/nossr50/util/skills/CombatUtils.java | 7 ++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 191f73a69..c9f83c20a 100755 --- a/pom.xml +++ b/pom.xml @@ -121,7 +121,7 @@ org.bukkit bukkit - 1.6.4-R2.0 + LATEST jar compile diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index f6278bc83..24d985c28 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -35,6 +35,7 @@ import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import org.bukkit.projectiles.ProjectileSource; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.AdvancedConfig; @@ -169,7 +170,11 @@ public class EntityListener implements Listener { } if (attacker instanceof Projectile) { - attacker = ((Projectile) attacker).getShooter(); + ProjectileSource projectileSource = ((Projectile) attacker).getShooter(); + + if (projectileSource instanceof LivingEntity) { + attacker = (LivingEntity) projectileSource; + } } else if (attacker instanceof Tameable) { AnimalTamer animalTamer = ((Tameable) attacker).getOwner(); diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 554a4492b..3f003ca94 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -16,6 +16,7 @@ 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.projectiles.ProjectileSource; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; @@ -262,10 +263,10 @@ public final class CombatUtils { } else if (entityType == EntityType.ARROW) { Arrow arrow = (Arrow) damager; - LivingEntity shooter = arrow.getShooter(); + ProjectileSource projectileSource = arrow.getShooter(); - if (shooter != null && shooter instanceof Player && SkillType.ARCHERY.shouldProcess(target)) { - Player player = (Player) shooter; + if (projectileSource != null && projectileSource instanceof Player && SkillType.ARCHERY.shouldProcess(target)) { + Player player = (Player) projectileSource; if (!Misc.isNPCEntity(player) && SkillType.ARCHERY.getPermissions(player)) { processArcheryCombat(target, player, event, arrow);