Skip to content

Commit

Permalink
Merge pull request #20 from williamhatcher/rename-invert
Browse files Browse the repository at this point in the history
Renamed Invert to Mode
  • Loading branch information
Zerthick authored Jan 20, 2018
2 parents cd13586 + 8c50df8 commit 5cd2c3d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 18 deletions.
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {
}

group 'io.github.zerthick'
version '1.3.0'
version '1.4.0'

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public Logger getLogger() {
public PluginContainer getInstance() {
return instance;
}


@Listener
public void onServerInit(GameInitializationEvent event) {
Expand All @@ -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);
Expand Down
11 changes: 8 additions & 3 deletions src/main/resources/assets/protectionperms/DefaultConfig.conf
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5cd2c3d

Please sign in to comment.