Adds a new configuration option to remove permission signs without a physical sign on startup
This commit is contained in:
parent
b89b993220
commit
ee4f4355f5
@ -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
|
||||
- removePermissionSignIfMissing - If enabled, permission signs that have lost their physical sign will be removed during
|
||||
startup. This prevents permission signs from staying in a broken state until the sign is replaced.
|
||||
- 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
|
||||
|
@ -45,6 +45,7 @@ public final class PermissionSigns extends JavaPlugin {
|
||||
private static boolean perWorldPermissions;
|
||||
private static boolean enableExtensiveSignProtection;
|
||||
private static boolean enableIndirectSignProtection;
|
||||
private static boolean removePermissionSignIfMissing;
|
||||
|
||||
/**
|
||||
* Instantiates the permission signs class
|
||||
@ -141,6 +142,15 @@ public final class PermissionSigns extends JavaPlugin {
|
||||
return enableIndirectSignProtection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether to remove permissions signs if their physical signs are missing
|
||||
*
|
||||
* @return <p>Whether tor remove permission signs if their signs are missing</p>
|
||||
*/
|
||||
public static boolean removePermissionSignIfMissing() {
|
||||
return removePermissionSignIfMissing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
super.reloadConfig();
|
||||
@ -183,6 +193,7 @@ public final class PermissionSigns extends JavaPlugin {
|
||||
perWorldPermissions = config.getBoolean("perWorldPermissions", false);
|
||||
enableExtensiveSignProtection = config.getBoolean("enableExtensiveSignProtection", false);
|
||||
enableIndirectSignProtection = config.getBoolean("enableIndirectSignProtection", true);
|
||||
removePermissionSignIfMissing = config.getBoolean("removePermissionSignIfMissing", true);
|
||||
saveConfig();
|
||||
return language;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public final class SignManager {
|
||||
private static final File signsFile = new File(PermissionSigns.getInstance().getDataFolder(), "data.yml");
|
||||
|
||||
private SignManager() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,11 +114,15 @@ public final class SignManager {
|
||||
*/
|
||||
private static void redrawSigns() {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(PermissionSigns.getInstance(), () -> {
|
||||
List<Location> invalidPermissionSigns = new ArrayList<>();
|
||||
for (Location key : managedSigns.keySet()) {
|
||||
PermissionSign permissionSign = managedSigns.get(key);
|
||||
Block signBlock = key.getBlock();
|
||||
BlockState state = signBlock.getState();
|
||||
if (!(state instanceof Sign sign)) {
|
||||
if (PermissionSigns.removePermissionSignIfMissing()) {
|
||||
invalidPermissionSigns.add(permissionSign.getSignLocation());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
String[] newLines = permissionSign.getSignLines();
|
||||
@ -130,6 +134,9 @@ public final class SignManager {
|
||||
}
|
||||
sign.update();
|
||||
}
|
||||
for (Location signLocation : invalidPermissionSigns) {
|
||||
SignManager.removeSign(signLocation);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,18 @@
|
||||
# The language to use for the plugin (en, nb-no)
|
||||
language: en
|
||||
|
||||
# Whether to only give permissions for a single world, instead of granting permissions for all worlds
|
||||
# Whether to only give permissions for a single world, instead of granting permissions for all worlds.
|
||||
perWorldPermissions: false
|
||||
|
||||
# Whether to remove permission signs during loading if the physical sign is missing. This prevents permission signs from
|
||||
# existing in a strange state until a new sign is placed in the permission sign's defined location.
|
||||
removePermissionSignIfMissing: true
|
||||
|
||||
# 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
|
||||
# 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