Fixes: Fishing Rods and Snowballs

Fixed animal theft with fishing rods, player harassment in pvp safe
zones with snowballs.
This commit is contained in:
ryanhamshire 2014-11-16 15:38:30 -08:00
parent 5df24c1302
commit 23bd87f8e2

View File

@ -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))