diff --git a/README.md b/README.md index 7ab4b52..c02c85a 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ permanently by another cause, when they expire. - language - The language used for the plugin (en, nb-no) - perWorldPermissions - Sets permissions for the current world instead of setting them globally +- enableIndirectSignProtection - Protects permission signs against indirect sources such as pistons and explosions. Only + disable this if your permission signs are protected by another plugin. - enableExtensiveSignProtection - Whether to protect signs on "unstable" blocks such as sand or anvils. Does not protect signs on "lag pyramids" or similar, but protects signs on top of, or attached to a pillar of sand. diff --git a/src/main/java/net/knarcraft/permissionsigns/PermissionSigns.java b/src/main/java/net/knarcraft/permissionsigns/PermissionSigns.java index 0bef189..c3b1c45 100644 --- a/src/main/java/net/knarcraft/permissionsigns/PermissionSigns.java +++ b/src/main/java/net/knarcraft/permissionsigns/PermissionSigns.java @@ -44,6 +44,7 @@ public final class PermissionSigns extends JavaPlugin { private static PermissionSigns instance; private static boolean perWorldPermissions; private static boolean enableExtensiveSignProtection; + private static boolean enableIndirectSignProtection; /** * Instantiates the permission signs class @@ -131,6 +132,15 @@ public final class PermissionSigns extends JavaPlugin { return enableExtensiveSignProtection; } + /** + * Gets whether permission sign explosion and piston protection is enabled + * + * @return
Whether permission sign explosion and piston protection is enabled
+ */ + public static boolean indirectProtectionEnabled() { + return enableIndirectSignProtection; + } + @Override public void reloadConfig() { super.reloadConfig(); @@ -172,6 +182,7 @@ public final class PermissionSigns extends JavaPlugin { String language = config.getString("language", "en"); perWorldPermissions = config.getBoolean("perWorldPermissions", false); enableExtensiveSignProtection = config.getBoolean("enableExtensiveSignProtection", false); + enableIndirectSignProtection = config.getBoolean("enableIndirectSignProtection", true); saveConfig(); return language; } diff --git a/src/main/java/net/knarcraft/permissionsigns/listener/BlockListener.java b/src/main/java/net/knarcraft/permissionsigns/listener/BlockListener.java index 4e0a7de..bf1748e 100644 --- a/src/main/java/net/knarcraft/permissionsigns/listener/BlockListener.java +++ b/src/main/java/net/knarcraft/permissionsigns/listener/BlockListener.java @@ -1,5 +1,6 @@ package net.knarcraft.permissionsigns.listener; +import net.knarcraft.permissionsigns.PermissionSigns; import net.knarcraft.permissionsigns.formatting.StringFormatter; import net.knarcraft.permissionsigns.formatting.TranslatableMessage; import net.knarcraft.permissionsigns.manager.SignManager; @@ -15,7 +16,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockExplodeEvent; -import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.entity.EntityExplodeEvent; @@ -30,14 +30,6 @@ import static net.knarcraft.permissionsigns.PermissionSigns.extensiveSignProtect */ public class BlockListener implements Listener { - @EventHandler - public void onBlockPhysics(BlockPhysicsEvent event) { - //Block any physics events from destroying signs - if (SignManager.getSign(event.getBlock().getLocation()) != null) { - event.setCancelled(true); - } - } - @EventHandler public void onPistonExtend(BlockPistonExtendEvent event) { preventDestruction(event.getBlocks(), event); @@ -107,6 +99,10 @@ public class BlockListener implements Listener { * @param eventThe event to cancel if a permission sign is found
*/ private void preventDestruction(List