Make harmful potions obey the pvp-enabled setting.

This commit is contained in:
garbagemule 2012-03-03 11:47:53 +01:00
parent fba31d26a4
commit 2adf1678cc
4 changed files with 30 additions and 1 deletions

Binary file not shown.

View File

@ -1,7 +1,7 @@
name: MobArena
author: garbagemule
main: com.garbagemule.MobArena.MobArena
version: 0.94.4.55
version: 0.94.4.56
softdepend: [Spout,MultiVerse,XcraftGate,Towny,Heroes,MagicSpells,Vault]
commands:
ma:

View File

@ -18,6 +18,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Slime;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.entity.Wolf;
import org.bukkit.event.Event.Result;
import org.bukkit.event.block.Action;
@ -40,6 +41,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTeleportEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
import org.bukkit.event.entity.PlayerDeathEvent;
@ -59,6 +61,8 @@ import org.bukkit.material.Attachable;
import org.bukkit.material.Bed;
import org.bukkit.material.Door;
import org.bukkit.material.Redstone;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.garbagemule.MobArena.MAUtils;
import com.garbagemule.MobArena.MobArena;
@ -544,6 +548,24 @@ public class ArenaListener
event.setCancelled(true);
}
}
public void onPotionSplash(PotionSplashEvent event) {
ThrownPotion potion = event.getPotion();
if (!region.contains(potion.getLocation()) || pvpEnabled) {
return;
}
// If a potion has harmful effects, remove all players.
for (PotionEffect effect : potion.getEffects()) {
PotionEffectType type = effect.getType();
if (type.equals(PotionEffectType.HARM) || type.equals(PotionEffectType.POISON)) {
for (Player p : arena.getPlayersInArena()) {
event.setIntensity(p, 0D);
}
break;
}
}
}
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
if (arena.getRegion().contains(event.getBlock().getLocation()))

View File

@ -172,6 +172,13 @@ public class MAGlobalListener implements Listener
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void potionSplash(PotionSplashEvent event) {
for (Arena arena : am.getArenas()) {
arena.getEventListener().onPotionSplash(event);
}
}
///////////////////////////////////////////////////////////////////////////