Adds a configuration option to allow explosion/piston protection to be turned off
This commit is contained in:
parent
0283c917e7
commit
6cee659bd0
@ -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.
|
||||
|
||||
|
@ -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 <p>Whether permission sign explosion and piston protection is enabled</p>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
@ -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 event <p>The event to cancel if a permission sign is found</p>
|
||||
*/
|
||||
private void preventDestruction(List<Block> blocks, Cancellable event) {
|
||||
//Don't do anything if indirect protection is disabled
|
||||
if (!PermissionSigns.indirectProtectionEnabled()) {
|
||||
return;
|
||||
}
|
||||
for (Block block : blocks) {
|
||||
protectBlockIfPermissionSign(event, block, null);
|
||||
if (event.isCancelled()) {
|
||||
|
@ -4,6 +4,11 @@ language: en
|
||||
# Whether to only give permissions for a single world, instead of granting permissions for all worlds
|
||||
perWorldPermissions: false
|
||||
|
||||
# Whether to enable protection against indirect damage sources such as explosions and pistons. You can disable this to
|
||||
# save some resources if permission signs are only placed in a protected area. WARNING: Disabling this and placing
|
||||
# permission signs in an unprotected area allows unauthorized players to destroy (but not de-register) permission signs
|
||||
enableIndirectSignProtection: true
|
||||
|
||||
# Whether to protect permission signs on falling blocks (sand, gravel, anvil, drip-stone, signs) by preventing breakage
|
||||
# of the blocks that would cause a sign to be destroyed.
|
||||
# of the blocks that would cause a sign to be destroyed
|
||||
enableExtensiveSignProtection: false
|
Loading…
Reference in New Issue
Block a user