From c8cd3a56342542f2ca4ba0938f95b60f9c291747 Mon Sep 17 00:00:00 2001 From: William 'psyFi' Hatcher Date: Thu, 11 Jan 2018 12:32:26 -0600 Subject: [PATCH 1/7] Renamed Invert to Mode --- .../protectionperms/ProtectionPerms.java | 17 +++++++++++------ .../assets/protectionperms/DefaultConfig.conf | 11 ++++++++--- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java b/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java index 0863870..7dfec26 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) { @@ -78,13 +78,18 @@ public void onServerInit(GameInitializationEvent event) { logger.warn("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); + } } catch (IOException e) { logger.warn("Error loading config! Error: " + e.getMessage()); } 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 From db38dabfddb55e81c8ac34bbf4fc661512a9d23b Mon Sep 17 00:00:00 2001 From: William 'psyFi' Hatcher Date: Sat, 20 Jan 2018 11:56:01 -0600 Subject: [PATCH 2/7] Changed logger.warn to logger.error --- .../io/github/zerthick/protectionperms/ProtectionPerms.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java b/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java index 7dfec26..fe34190 100644 --- a/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java +++ b/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java @@ -75,7 +75,7 @@ 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 @@ -91,7 +91,7 @@ public void onServerInit(GameInitializationEvent event) { PermHandler.getInstance().init(true); } } catch (IOException e) { - logger.warn("Error loading config! Error: " + e.getMessage()); + logger.error("Error loading config! Error: " + e.getMessage()); } DebugLogger.getInstance().setLogger(logger); From dec53901188338b16d09ed1e522257532b0f0b72 Mon Sep 17 00:00:00 2001 From: William 'psyFi' Hatcher Date: Sat, 20 Jan 2018 12:02:55 -0600 Subject: [PATCH 3/7] Added else block to mode detection The plugin will log a warning if `mode` is not `whitelist` or `blacklist` in the config. Note: I edited this directly on GitHub because I uninstalled my Java IDE. Please check it. --- .../io/github/zerthick/protectionperms/ProtectionPerms.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java b/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java index fe34190..1c9afee 100644 --- a/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java +++ b/src/main/java/io/github/zerthick/protectionperms/ProtectionPerms.java @@ -89,6 +89,10 @@ public void onServerInit(GameInitializationEvent event) { 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.error("Error loading config! Error: " + e.getMessage()); From 73af046f27c8ec650b5e807080ff197542c075db Mon Sep 17 00:00:00 2001 From: William 'psyFi' Hatcher Date: Sat, 20 Jan 2018 12:05:50 -0600 Subject: [PATCH 4/7] Bumped version to 1.4.0 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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() From f60f523072dac8bd1221d10f4f2c8727fa6bc51b Mon Sep 17 00:00:00 2001 From: William 'psyFi' Hatcher Date: Sat, 20 Jan 2018 12:26:12 -0600 Subject: [PATCH 5/7] Update README.md --- README.md | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f9917d4..c29e01f 100644 --- a/README.md +++ b/README.md @@ -83,15 +83,27 @@ 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: -``` -# Whether permissions nodes should be inverted -# If inverted granting a permission will DENY an action -invert=false +## 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 ``` +# ProtectionPerms -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. +# 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 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) From d36f18e372ecfc73f96f6131b81047a9d1481fce Mon Sep 17 00:00:00 2001 From: William 'psyFi' Hatcher Date: Sat, 20 Jan 2018 12:28:50 -0600 Subject: [PATCH 6/7] Added whitespace to fix formatting. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index c29e01f..18e688f 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,13 @@ 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 you have any questions, feel free to open an issue. ## Support Me From 8c50df802973770602bb9586a85819070def1d96 Mon Sep 17 00:00:00 2001 From: William 'psyFi' Hatcher Date: Sat, 20 Jan 2018 12:30:44 -0600 Subject: [PATCH 7/7] Added whitespace to fix formatting. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 18e688f..479adb1 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,11 @@ When creating your permission nodes you may run into situations where you have c ## 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 ``` # ProtectionPerms