Added config protection defaults for Beacon and Anvil. Added Hanging

protection for explosions.
This commit is contained in:
John Veres 2012-11-03 07:21:28 -04:00 committed by Christopher Paslawski
parent ee6c7c07d2
commit dce2e7d266
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.ENCHANTMENT_TABLE);
territoryProtectedMaterials.add(Material.CAULDRON); territoryProtectedMaterials.add(Material.CAULDRON);
territoryProtectedMaterials.add(Material.SOIL); territoryProtectedMaterials.add(Material.SOIL);
territoryProtectedMaterials.add(Material.BEACON);
territoryProtectedMaterials.add(Material.ANVIL);
territoryDenyUseageMaterials.add(Material.FIREBALL); territoryDenyUseageMaterials.add(Material.FIREBALL);
territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL); territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL);
@ -330,6 +332,8 @@ public class Conf
territoryProtectedMaterialsWhenOffline.add(Material.ENCHANTMENT_TABLE); territoryProtectedMaterialsWhenOffline.add(Material.ENCHANTMENT_TABLE);
territoryProtectedMaterialsWhenOffline.add(Material.CAULDRON); territoryProtectedMaterialsWhenOffline.add(Material.CAULDRON);
territoryProtectedMaterialsWhenOffline.add(Material.SOIL); territoryProtectedMaterialsWhenOffline.add(Material.SOIL);
territoryProtectedMaterialsWhenOffline.add(Material.BEACON);
territoryProtectedMaterialsWhenOffline.add(Material.ANVIL);
territoryDenyUseageMaterialsWhenOffline.add(Material.FIREBALL); territoryDenyUseageMaterialsWhenOffline.add(Material.FIREBALL);
territoryDenyUseageMaterialsWhenOffline.add(Material.FLINT_AND_STEEL); 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.entity.PotionSplashEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@ -487,6 +488,62 @@ public class FactionsEntityListener implements Listener
public void onPaintingBreak(HangingBreakEvent event) public void onPaintingBreak(HangingBreakEvent event)
{ {
if (event.isCancelled()) return; 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)) if (! (event instanceof HangingBreakByEntityEvent))
{ {