Merge pull request #179 from Tahkeh/1.6.x-fix

Protecting Beacon and Anvil use by default and protecting Hanging entities from explosions
This commit is contained in:
Brett Flannigan 2012-11-06 07:54:44 -08:00
commit 5ad6886d46
2 changed files with 61 additions and 0 deletions

View File

@ -309,6 +309,8 @@ public class Conf
territoryProtectedMaterials.add(Material.ENCHANTMENT_TABLE);
territoryProtectedMaterials.add(Material.CAULDRON);
territoryProtectedMaterials.add(Material.SOIL);
territoryProtectedMaterials.add(Material.BEACON);
territoryProtectedMaterials.add(Material.ANVIL);
territoryDenyUseageMaterials.add(Material.FIREBALL);
territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL);
@ -330,6 +332,8 @@ public class Conf
territoryProtectedMaterialsWhenOffline.add(Material.ENCHANTMENT_TABLE);
territoryProtectedMaterialsWhenOffline.add(Material.CAULDRON);
territoryProtectedMaterialsWhenOffline.add(Material.SOIL);
territoryProtectedMaterialsWhenOffline.add(Material.BEACON);
territoryProtectedMaterialsWhenOffline.add(Material.ANVIL);
territoryDenyUseageMaterialsWhenOffline.add(Material.FIREBALL);
territoryDenyUseageMaterialsWhenOffline.add(Material.FLINT_AND_STEEL);

View File

@ -34,6 +34,7 @@ import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@ -487,6 +488,62 @@ public class FactionsEntityListener implements Listener
public void onPaintingBreak(HangingBreakEvent event)
{
if (event.isCancelled()) return;
if (event.getCause() == RemoveCause.EXPLOSION)
{
Location loc = event.getEntity().getLocation();
Faction faction = Board.getFactionAt(new FLocation(loc));
if (faction.noExplosionsInTerritory())
{
// faction is peaceful and has explosions set to disabled
event.setCancelled(true);
return;
}
boolean online = faction.hasPlayersOnline();
if
(
(faction.isNone() && Conf.wildernessBlockCreepers && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()))
||
(faction.isNormal() && (online ? Conf.territoryBlockCreepers : Conf.territoryBlockCreepersWhenOffline))
||
(faction.isWarZone() && Conf.warZoneBlockCreepers)
||
faction.isSafeZone()
)
{
// creeper which needs prevention
event.setCancelled(true);
}
else if
(
(faction.isNone() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()))
||
(faction.isNormal() && (online ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline))
||
(faction.isWarZone() && Conf.warZoneBlockFireballs)
||
faction.isSafeZone()
)
{
// ghast fireball which needs prevention
event.setCancelled(true);
}
else if
(
(faction.isNone() && Conf.wildernessBlockTNT && ! Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()))
||
(faction.isNormal() && ( online ? Conf.territoryBlockTNT : Conf.territoryBlockTNTWhenOffline ))
||
(faction.isWarZone() && Conf.warZoneBlockTNT)
||
(faction.isSafeZone() && Conf.safeZoneBlockTNT)
)
{
// TNT which needs prevention
event.setCancelled(true);
}
}
if (! (event instanceof HangingBreakByEntityEvent))
{