From 5ab5ef67244e1102f21362403e39dac6733dd4b1 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Tue, 8 Mar 2011 06:42:48 -0600 Subject: [PATCH] check for special block destruction cases which previously were incorrectly allowed in other faction's territory: torch, redstone torch (on & off), repeater (on & off), redstonewire, sapling Paintings still can't be prevented from destruction, sadly --- .../factions/listeners/FactionsBlockListener.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/com/bukkit/mcteam/factions/listeners/FactionsBlockListener.java b/src/com/bukkit/mcteam/factions/listeners/FactionsBlockListener.java index 1396f803..441e6799 100644 --- a/src/com/bukkit/mcteam/factions/listeners/FactionsBlockListener.java +++ b/src/com/bukkit/mcteam/factions/listeners/FactionsBlockListener.java @@ -1,5 +1,7 @@ package com.bukkit.mcteam.factions.listeners; +import java.util.*; + import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockDamageLevel; @@ -28,13 +30,19 @@ public class FactionsBlockListener extends BlockListener { event.setCancelled(true); } } + + //special cases, check for destruction of: torch, redstone torch (on & off), repeater (on & off), redstonewire, sapling + private static Set specialBlocks = new HashSet(Arrays.asList( + new Integer[] {50, 75, 76, 93, 94, 55, 6} + )); @Override public void onBlockDamage(BlockDamageEvent event) { if (event.isCancelled()) { return; // Alright. lets listen to that. } - if (event.getDamageLevel() == BlockDamageLevel.STOPPED && ! this.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock(), "destroy")) { + boolean badBlock = event.getDamageLevel() == BlockDamageLevel.STOPPED || specialBlocks.contains(new Integer(event.getBlock().getTypeId())); + if (badBlock && ! this.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock(), "destroy")) { event.setCancelled(true); } }