Made the permissionDeniedFormats lookups recursive.

This commit is contained in:
Olof Larsson 2013-07-23 17:42:27 +02:00
parent 5677076165
commit db74b467b5
2 changed files with 16 additions and 2 deletions

View File

@ -40,7 +40,10 @@ public class MCoreConf extends Entity<MCoreConf>
private Map<String, String> permissionDeniedFormats = MUtil.map(
"some.awesome.permission.node", "<b>You must be awesome to %s<b>.",
"some.derp.permission.node", "<b>Only derp people can %s<b>.\n<i>Ask a moderator to become derp."
"some.derp.permission.node.1", "derp",
"some.derp.permission.node.2", "derp",
"some.derp.permission.node.3", "derp",
"derp", "<b>Only derp people can %s<b>.\n<i>Ask a moderator to become derp."
);
public Map<String, String> getPermissionDeniedFormats() { return this.permissionDeniedFormats == null ? new LinkedHashMap<String, String>() : new LinkedHashMap<String, String>(this.permissionDeniedFormats); }
public void setPermissionDeniedFormats(Map<String, String> permissionDeniedFormats) { this.permissionDeniedFormats = permissionDeniedFormats == null ? new LinkedHashMap<String, String>() : new LinkedHashMap<String, String>(permissionDeniedFormats); this.changed(); }
@ -74,7 +77,11 @@ public class MCoreConf extends Entity<MCoreConf>
public String getPermissionDeniedFormat(String permissionName)
{
return this.getPermissionDeniedFormats().get(permissionName);
Map<String, String> 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)

View File

@ -145,6 +145,13 @@ public class MUtil
return ret;
}
public static <T> T recurseResolveMap(T input, Map<T, T> map)
{
T output = map.get(input);
if (output == null) return input;
return recurseResolveMap(output, map);
}
// -------------------------------------------- //
// LOCATIONS COMPARISON
// -------------------------------------------- //