Skip to content

Instantly share code, notes, and snippets.

@macalinao
Forked from anonymous/gist:3108834
Created July 14, 2012 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macalinao/3108863 to your computer and use it in GitHub Desktop.
Save macalinao/3108863 to your computer and use it in GitHub Desktop.
String group = RoyalCommands.permission.getPrimaryGroup(p);
if (group == null)
group = "";
ConfigurationSection groups = plugin.homeLimits
.getConfigurationSection("groups");
ConfigurationSection players = plugin.homeLimits
.getConfigurationSection("players");
Integer limit;
if (players != null && players.contains(p.getName()))
limit = players.getInt(p.getName());
else if (groups != null && groups.contains(group))
limit = groups.getInt(group);
else
limit = null;
// limit = (players != null && players.contains(p.getName())) ?
// players.getInt(p.getName()) : (groups != null &&
// groups.contains(group)) ? groups.getInt(group) : null;
// This should work, but IntelliJ says it could throw an NPE, so I'm
// playing it safe ^
ConfigurationSection home = pconf.getConfigurationSection("home");
int curHomes = (home == null) ? 0 : home.getValues(false).keySet()
.size();
if (limit != null && pconf.get("home." + name) != null) {
if (limit == 0) {
RUtils.dispNoPerms(cs, ChatColor.RED
+ "Your home limit is set to " + ChatColor.GRAY + "0"
+ ChatColor.RED + "!");
cs.sendMessage(ChatColor.RED + "You can't set any homes!");
return true;
} else if (curHomes >= limit && limit > -1) {
RUtils.dispNoPerms(cs, ChatColor.RED
+ "You've reached your max number of homes! ("
+ ChatColor.GRAY + limit + ChatColor.RED + ")");
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment