From c7b9897738994109df5e7241e62e81742097ef80 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Mon, 26 Jan 2015 16:40:08 -0800 Subject: [PATCH] Jump potions on animals require container trust. Otherwise griefers use it to steal animals over fences with bait. --- .../GriefPrevention/EntityEventHandler.java | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java index 32f176a..d81f955 100644 --- a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java @@ -32,6 +32,7 @@ import org.bukkit.OfflinePlayer; import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.block.Block; +import org.bukkit.entity.Animals; import org.bukkit.entity.Creature; import org.bukkit.entity.Creeper; import org.bukkit.entity.Enderman; @@ -878,9 +879,32 @@ class EntityEventHandler implements Listener Collection effects = potion.getEffects(); for(PotionEffect effect : effects) { - //no restrictions for positive effects PotionEffectType effectType = effect.getType(); - if(positiveEffects.contains(effectType)) continue; + + //restrict jump potions on claimed animals (griefers could use this to steal animals over fences) + if(effectType == PotionEffectType.JUMP) + { + for(LivingEntity effected : event.getAffectedEntities()) + { + Claim cachedClaim = null; + if(effected instanceof Animals) + { + Claim claim = this.dataStore.getClaimAt(effected.getLocation(), false, cachedClaim); + if(claim != null) + { + cachedClaim = claim; + if(claim.allowContainers(thrower) != null) + { + event.setCancelled(true); + return; + } + } + } + } + } + + //otherwise, no restrictions for positive effects + if(positiveEffects.contains(effectType)) continue; for(LivingEntity effected : event.getAffectedEntities()) {