diff options
author | snowleo <schneeleo@gmail.com> | 2011-07-18 01:05:42 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-07-18 01:05:42 +0200 |
commit | 6733d177df8e332cb806129db6c1f59adfbcd810 (patch) | |
tree | 55045baf7af0434eb33505ad002201e6292ec3a4 | |
parent | 424781c4a7ce41f5d432ebe3f557eb10d80d05a6 (diff) | |
download | Essentials-6733d177df8e332cb806129db6c1f59adfbcd810.tar Essentials-6733d177df8e332cb806129db6c1f59adfbcd810.tar.gz Essentials-6733d177df8e332cb806129db6c1f59adfbcd810.tar.lz Essentials-6733d177df8e332cb806129db6c1f59adfbcd810.tar.xz Essentials-6733d177df8e332cb806129db6c1f59adfbcd810.zip |
Piston push blacklist
4 files changed, 41 insertions, 3 deletions
diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 90f8372cb..1d6e7ef81 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -305,7 +305,7 @@ protect: on-placement: 10,11,46 on-use: # 46: TNT - on-break: 46 + on-break: # Users cannot PLACE these types of blocks/items. # < 255 designates a BLOCK @@ -317,7 +317,9 @@ protect: #prevent people from breaking blocks #break: 20,50 break: - + + # Which blocks should not be pushed by pistons + piston: # General physics/behavior modifications prevent: diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java index 18acd9be3..53843843f 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java @@ -45,6 +45,8 @@ public class EssentialsProtect extends JavaPlugin implements IConf, IProtect pm.registerEvent(Type.BLOCK_IGNITE, blockListener, Priority.Highest, this); pm.registerEvent(Type.BLOCK_BURN, blockListener, Priority.Highest, this); pm.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Highest, this); + pm.registerEvent(Type.BLOCK_PISTON_EXTEND, blockListener, Priority.Highest, this); + pm.registerEvent(Type.BLOCK_PISTON_RETRACT, blockListener, Priority.Highest, this); final EssentialsProtectEntityListener entityListener = new EssentialsProtectEntityListener(this); pm.registerEvent(Type.ENTITY_EXPLODE, entityListener, Priority.Highest, this); diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java index 1b9736a5a..5d0a62d72 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java @@ -14,6 +14,8 @@ import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockListener; +import org.bukkit.event.block.BlockPistonExtendEvent; +import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPlaceEvent; @@ -319,4 +321,35 @@ public class EssentialsProtectBlockListener extends BlockListener } } } + + @Override + public void onBlockPistonExtend(BlockPistonExtendEvent event) + { + if (event.isCancelled()) + { + return; + } + for (Block block : event.getBlocks()) + { + if (prot.checkProtectionItems(ProtectConfig.blacklist_piston, block.getTypeId())) + { + event.setCancelled(true); + return; + } + } + } + + @Override + public void onBlockPistonRetract(BlockPistonRetractEvent event) + { + if (event.isCancelled() || !event.isSticky()) + { + return; + } + if (prot.checkProtectionItems(ProtectConfig.blacklist_piston, event.getRetractLocation().getBlock().getTypeId())) + { + event.setCancelled(true); + return; + } + } } diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java b/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java index 75824c368..950da0ebf 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java @@ -45,7 +45,8 @@ public enum ProtectConfig alert_on_break("protect.alert.on-break"), blacklist_placement("protect.blacklist.placement"), blacklist_usage("protect.blacklist.usage"), - blacklist_break("protect.blacklist.break"); + blacklist_break("protect.blacklist.break"), + blacklist_piston("protect.blacklist.piston"); private final String configName; private final String defValueString; private final boolean defValueBoolean; |