-
-
Save macalinao/3108836 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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