From 23bd87f8e2fe86a75cb57415b37fdb4cf6dd3f48 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Sun, 16 Nov 2014 15:38:30 -0800 Subject: [PATCH] Fixes: Fishing Rods and Snowballs Fixed animal theft with fishing rods, player harassment in pvp safe zones with snowballs. --- .../GriefPrevention/EntityEventHandler.java | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java index 1e125de..b9838b3 100644 --- a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java @@ -36,6 +36,7 @@ import org.bukkit.entity.Explosive; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Monster; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.Villager; @@ -357,28 +358,20 @@ class EntityEventHandler implements Listener //determine which player is attacking, if any Player attacker = null; - Arrow arrow = null; + Projectile arrow = null; Entity damageSource = subEvent.getDamager(); if(damageSource instanceof Player) { attacker = (Player)damageSource; } - else if(damageSource instanceof Arrow) + else if(damageSource instanceof Projectile) { - arrow = (Arrow)damageSource; + arrow = (Projectile)damageSource; if(arrow.getShooter() instanceof Player) { attacker = (Player)arrow.getShooter(); } } - else if(damageSource instanceof ThrownPotion) - { - ThrownPotion potion = (ThrownPotion)damageSource; - if(potion.getShooter() instanceof Player) - { - attacker = (Player)potion.getShooter(); - } - } //if the attacker is a player and defender is a player (pvp combat) if(attacker != null && event.getEntity() instanceof Player && GriefPrevention.instance.config_pvp_enabledWorlds.contains(attacker.getWorld())) @@ -569,7 +562,7 @@ class EntityEventHandler implements Listener public void onVehicleDamage (VehicleDamageEvent event) { //all of this is anti theft code - if(!GriefPrevention.instance.config_claims_preventTheft) return; + if(!GriefPrevention.instance.config_claims_preventTheft) return; //don't track in worlds where claims are not enabled if(!GriefPrevention.instance.claimsEnabledForWorld(event.getVehicle().getWorld())) return; @@ -577,26 +570,18 @@ class EntityEventHandler implements Listener //determine which player is attacking, if any Player attacker = null; Entity damageSource = event.getAttacker(); - if(damageSource instanceof Player) + if(damageSource.getType() == EntityType.PLAYER) { attacker = (Player)damageSource; } - else if(damageSource instanceof Arrow) + else if(damageSource instanceof Projectile) { - Arrow arrow = (Arrow)damageSource; - if(arrow.getShooter() instanceof Player) + Projectile arrow = (Projectile)damageSource; + if(arrow.getShooter() instanceof Player) { attacker = (Player)arrow.getShooter(); } } - else if(damageSource instanceof ThrownPotion) - { - ThrownPotion potion = (ThrownPotion)damageSource; - if(potion.getShooter() instanceof Player) - { - attacker = (Player)potion.getShooter(); - } - } //if not a player and not an explosion, always allow if(attacker == null && !(damageSource instanceof Explosive))