- Witches can no longer apply potions to claimed animals (as if they
were an untrusted player)
- Protect claimed villagers as well

- Don't cancel entire event when we're protecting a single animal.
This commit is contained in:
RoboMWM 2016-11-17 23:20:08 -08:00
parent d6caffb2e2
commit 12758b5a03

View File

@ -954,12 +954,14 @@ public class EntityEventHandler implements Listener
PlayerData playerData = null;
//if not a player or an explosive, allow
//RoboMWM: Or a lingering potion, or a witch
if(attacker == null
&& damageSource != null
&& damageSource.getType() != EntityType.CREEPER
&& damageSource.getType() != EntityType.WITHER
&& damageSource.getType() != EntityType.ENDER_CRYSTAL
&& damageSource.getType() != EntityType.AREA_EFFECT_CLOUD
&& damageSource.getType() != EntityType.WITCH
&& !(damageSource instanceof Projectile)
&& !(damageSource instanceof Explosive)
&& !(damageSource instanceof ExplosiveMinecart))
@ -1187,37 +1189,42 @@ public class EntityEventHandler implements Listener
//ignore potions not thrown by players
ProjectileSource projectileSource = potion.getShooter();
if(projectileSource == null || !(projectileSource instanceof Player)) return;
Player thrower = (Player)projectileSource;
if(projectileSource == null) return;
Player thrower = null;
if ((projectileSource instanceof Player))
thrower = (Player)projectileSource;
Collection<PotionEffect> effects = potion.getEffects();
for(PotionEffect effect : effects)
{
PotionEffectType effectType = effect.getType();
//restrict some potions on claimed animals (griefers could use this to kill or steal animals over fences)
//restrict some potions on claimed animals (griefers could use this to kill or steal animals over fences) //RoboMWM: include villagers
if(effectType.getName().equals("JUMP") || effectType.getName().equals("POISON"))
{
for(LivingEntity effected : event.getAffectedEntities())
Claim cachedClaim = null;
for(LivingEntity effected : event.getAffectedEntities())
{
Claim cachedClaim = null;
if(effected instanceof Animals)
if(effected.getType() == EntityType.VILLAGER || effected instanceof Animals)
{
Claim claim = this.dataStore.getClaimAt(effected.getLocation(), false, cachedClaim);
if(claim != null)
{
cachedClaim = claim;
if(claim.allowContainers(thrower) != null)
if(thrower == null || claim.allowContainers(thrower) != null)
{
event.setCancelled(true);
GriefPrevention.sendMessage(thrower, TextMode.Err, Messages.NoDamageClaimedEntity, claim.getOwnerName());
event.setIntensity(effected, 0);
instance.sendMessage(thrower, TextMode.Err, Messages.NoDamageClaimedEntity, claim.getOwnerName());
return;
}
}
}
}
}
//Otherwise, ignore potions not thrown by players
if (thrower == null) return;
//otherwise, no restrictions for positive effects
if(positiveEffects.contains(effectType)) continue;