From db74b467b573366c021a8ad121094259cd7138ce Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Tue, 23 Jul 2013 17:42:27 +0200 Subject: [PATCH] Made the permissionDeniedFormats lookups recursive. --- src/com/massivecraft/mcore/MCoreConf.java | 11 +++++++++-- src/com/massivecraft/mcore/util/MUtil.java | 7 +++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/com/massivecraft/mcore/MCoreConf.java b/src/com/massivecraft/mcore/MCoreConf.java index 2bd272c4..2c62d85f 100644 --- a/src/com/massivecraft/mcore/MCoreConf.java +++ b/src/com/massivecraft/mcore/MCoreConf.java @@ -40,7 +40,10 @@ public class MCoreConf extends Entity private Map permissionDeniedFormats = MUtil.map( "some.awesome.permission.node", "You must be awesome to %s.", - "some.derp.permission.node", "Only derp people can %s.\nAsk a moderator to become derp." + "some.derp.permission.node.1", "derp", + "some.derp.permission.node.2", "derp", + "some.derp.permission.node.3", "derp", + "derp", "Only derp people can %s.\nAsk a moderator to become derp." ); public Map getPermissionDeniedFormats() { return this.permissionDeniedFormats == null ? new LinkedHashMap() : new LinkedHashMap(this.permissionDeniedFormats); } public void setPermissionDeniedFormats(Map permissionDeniedFormats) { this.permissionDeniedFormats = permissionDeniedFormats == null ? new LinkedHashMap() : new LinkedHashMap(permissionDeniedFormats); this.changed(); } @@ -74,7 +77,11 @@ public class MCoreConf extends Entity public String getPermissionDeniedFormat(String permissionName) { - return this.getPermissionDeniedFormats().get(permissionName); + Map map = this.getPermissionDeniedFormats(); + String ret = map.get(permissionName); + if (ret == null) return null; + ret = MUtil.recurseResolveMap(ret, map); + return ret; } public int getTpdelay(Permissible permissible) diff --git a/src/com/massivecraft/mcore/util/MUtil.java b/src/com/massivecraft/mcore/util/MUtil.java index 443ab60a..29694351 100644 --- a/src/com/massivecraft/mcore/util/MUtil.java +++ b/src/com/massivecraft/mcore/util/MUtil.java @@ -145,6 +145,13 @@ public class MUtil return ret; } + public static T recurseResolveMap(T input, Map map) + { + T output = map.get(input); + if (output == null) return input; + return recurseResolveMap(output, map); + } + // -------------------------------------------- // // LOCATIONS COMPARISON // -------------------------------------------- //