diff --git a/README.md b/README.md index f9917d4..479adb1 100644 --- a/README.md +++ b/README.md @@ -83,15 +83,34 @@ Whenever a permission requires a blockID you can optionally include `BlockState` ### Conflicts When creating your permission nodes you may run into situations where you have conflicting permissions. For instance, you may not be able to place a block even though you have the place permission because you don't have the corresponding use permission for the block as an item, in this case pay attention to the message ProtectionPerms gives you when you try to execute an action, it should point you toward the permission node you need. :wink: -### Inverting Permissions -As of ProtectionPerms v1.2.0 a config file will be generated at `~/config/ProtectionPerms.conf`, the default configuration is shown below: +## Inverting Permissions +ProtectionPerms runs in "whitelist" mode, where players cannot perform any actions that have not been granted to them. You can change this behavior by changing the mode in the config file at `~/config/ProtectionPerms.conf`. + +**Whitelist mode prevents players from performing any action unless the according permission node is granted to them.** + +**Blacklist mode allows players to perform all actions, unless the according permission node is granted.** + +### Default Config ``` -# Whether permissions nodes should be inverted -# If inverted granting a permission will DENY an action -invert=false +# ProtectionPerms + +# The mode the plugin runs in. +# Whitelist mode prevents players from performing any action unless the according permission node is granted to them. +# Blacklist mode allows players to perform all actions, unless the according permission node is granted. +# Values: whitelist or blacklist +# Default: whitelist +mode = whitelist ``` +## Migrating to v1.4.0 +ProtectionPerms v1.4.0 changed the configuration file, and it must be migrated. The easiest way to do this is to delete the current configuration file. + +See (above)[#default-config] for the default configuration file for v1.4.0. + +If you set `invert=true` in the current config, change the mode to `blacklist` in the new config. (`mode = blacklist`) + +If you never made any changes to the old config file, just delete the old config file. ProtectionPerms will generate a new one for you. -If `invert` is set to `true`, the functionality of the permisison nodes will be reversed such that granting a permission node will **deny** the player from completing the action it describes. +If you have any questions, feel free to open an issue. ## Support Me I will **never** charge money for the use of my plugins, however they do require a significant amount of work to maintain and update. If you'd like to show your support and buy me a cup of tea sometime (I don't drink that horrid coffee stuff :P) you can do so [here](https://www.paypal.me/zerthick) diff --git a/build.gradle b/build.gradle index 818922d..d895ad2 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ plugins { } group 'io.github.zerthick' -version '1.3.0' +version '1.4.0' repositories { mavenCentral() diff --git a/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java b/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java index 48c17ec..d890e12 100644 --- a/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java +++ b/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java @@ -61,7 +61,7 @@ public Logger getLogger() { public PluginContainer getInstance() { return instance; } - + @Listener public void onServerInit(GameInitializationEvent event) { @@ -75,18 +75,27 @@ public void onServerInit(GameInitializationEvent event) { defaultConfigAsset.copyToFile(defaultConfig); configLoader.save(configLoader.load()); } catch (IOException e) { - logger.warn("Error loading default config! Error: " + e.getMessage()); + logger.error("Error loading default config! Error: " + e.getMessage()); } } - //Load invert try { - CommentedConfigurationNode linksNode = configLoader.load().getNode("invert"); - boolean invert = linksNode.getBoolean(false); - PermHandler.getInstance().init(invert); - + CommentedConfigurationNode modeNode = configLoader.load().getNode("mode"); + if (modeNode.isVirtual()) { + logger.warn("Config corrupt! Using defaults (whitelist mode)\nDelete " + instance.getId() + ".conf to fix"); + } + String mode = modeNode.getString("whitelist"); + if (mode.equals("whitelist")) { + PermHandler.getInstance().init(false); + } else if (mode.equals("blacklist")){ + PermHandler.getInstance().init(true); + } else { + //Valid mode not found + PermHandler.getInstance().init(false); + logger.warn("Mode \"" + mode + "\" is not a vallid mode (whitelist OR blacklist)! Using whitelist mode."); + } } catch (IOException e) { - logger.warn("Error loading config! Error: " + e.getMessage()); + logger.error("Error loading config! Error: " + e.getMessage()); } DebugLogger.getInstance().setLogger(logger); diff --git a/src/main/resources/assets/protectionperms/DefaultConfig.conf b/src/main/resources/assets/protectionperms/DefaultConfig.conf index 94a70b7..02b59aa 100644 --- a/src/main/resources/assets/protectionperms/DefaultConfig.conf +++ b/src/main/resources/assets/protectionperms/DefaultConfig.conf @@ -1,3 +1,8 @@ -# Whether permissions nodes should be inverted -# If inverted granting a permission will DENY an action -invert = false +# ProtectionPerms + +# The mode the plugin runs in. +# Whitelist mode prevents players from performing any action unless the according permission node is granted to them. +# Blacklist mode allows players to perform all actions, unless the according permission node is granted. +# Values: whitelist or blacklist +# Default: whitelist +mode = whitelist \ No newline at end of file