Close #25
- 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:
parent
d6caffb2e2
commit
12758b5a03
|
|
@ -954,12 +954,14 @@ public class EntityEventHandler implements Listener
|
||||||
PlayerData playerData = null;
|
PlayerData playerData = null;
|
||||||
|
|
||||||
//if not a player or an explosive, allow
|
//if not a player or an explosive, allow
|
||||||
|
//RoboMWM: Or a lingering potion, or a witch
|
||||||
if(attacker == null
|
if(attacker == null
|
||||||
&& damageSource != null
|
&& damageSource != null
|
||||||
&& damageSource.getType() != EntityType.CREEPER
|
&& damageSource.getType() != EntityType.CREEPER
|
||||||
&& damageSource.getType() != EntityType.WITHER
|
&& damageSource.getType() != EntityType.WITHER
|
||||||
&& damageSource.getType() != EntityType.ENDER_CRYSTAL
|
&& damageSource.getType() != EntityType.ENDER_CRYSTAL
|
||||||
&& damageSource.getType() != EntityType.AREA_EFFECT_CLOUD
|
&& damageSource.getType() != EntityType.AREA_EFFECT_CLOUD
|
||||||
|
&& damageSource.getType() != EntityType.WITCH
|
||||||
&& !(damageSource instanceof Projectile)
|
&& !(damageSource instanceof Projectile)
|
||||||
&& !(damageSource instanceof Explosive)
|
&& !(damageSource instanceof Explosive)
|
||||||
&& !(damageSource instanceof ExplosiveMinecart))
|
&& !(damageSource instanceof ExplosiveMinecart))
|
||||||
|
|
@ -1187,30 +1189,32 @@ public class EntityEventHandler implements Listener
|
||||||
|
|
||||||
//ignore potions not thrown by players
|
//ignore potions not thrown by players
|
||||||
ProjectileSource projectileSource = potion.getShooter();
|
ProjectileSource projectileSource = potion.getShooter();
|
||||||
if(projectileSource == null || !(projectileSource instanceof Player)) return;
|
if(projectileSource == null) return;
|
||||||
Player thrower = (Player)projectileSource;
|
Player thrower = null;
|
||||||
|
if ((projectileSource instanceof Player))
|
||||||
|
thrower = (Player)projectileSource;
|
||||||
|
|
||||||
Collection<PotionEffect> effects = potion.getEffects();
|
Collection<PotionEffect> effects = potion.getEffects();
|
||||||
for(PotionEffect effect : effects)
|
for(PotionEffect effect : effects)
|
||||||
{
|
{
|
||||||
PotionEffectType effectType = effect.getType();
|
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"))
|
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.getType() == EntityType.VILLAGER || effected instanceof Animals)
|
||||||
if(effected instanceof Animals)
|
|
||||||
{
|
{
|
||||||
Claim claim = this.dataStore.getClaimAt(effected.getLocation(), false, cachedClaim);
|
Claim claim = this.dataStore.getClaimAt(effected.getLocation(), false, cachedClaim);
|
||||||
if(claim != null)
|
if(claim != null)
|
||||||
{
|
{
|
||||||
cachedClaim = claim;
|
cachedClaim = claim;
|
||||||
if(claim.allowContainers(thrower) != null)
|
if(thrower == null || claim.allowContainers(thrower) != null)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setIntensity(effected, 0);
|
||||||
GriefPrevention.sendMessage(thrower, TextMode.Err, Messages.NoDamageClaimedEntity, claim.getOwnerName());
|
instance.sendMessage(thrower, TextMode.Err, Messages.NoDamageClaimedEntity, claim.getOwnerName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1218,6 +1222,9 @@ public class EntityEventHandler implements Listener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Otherwise, ignore potions not thrown by players
|
||||||
|
if (thrower == null) return;
|
||||||
|
|
||||||
//otherwise, no restrictions for positive effects
|
//otherwise, no restrictions for positive effects
|
||||||
if(positiveEffects.contains(effectType)) continue;
|
if(positiveEffects.contains(effectType)) continue;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user