Fixed addNormal method, updated it's JavaDocs

This commit is contained in:
Tim Visée 2015-11-21 20:50:12 +01:00
parent 7902cd87bb
commit 89b5444d69

View File

@ -178,27 +178,30 @@ public class Utils {
} }
/** /**
* Method addNormal. * TODO: This method requires better explanation.
* @param player Player *
* @param group String * Set the normal group of a player.
*
* @return boolean */ * @param player The player.
* @param group The normal group.
* @return True on success, false on failure.
*/
public static boolean addNormal(Player player, String group) { public static boolean addNormal(Player player, String group) {
if (!useGroupSystem()) { if(!Settings.isPermissionCheckEnabled)
return false; return false;
}
if (plugin.vaultGroupManagement == null) // Get the permissions manager, and make sure it's valid
return false; PermissionsManager permsMan = plugin.getPermissionsManager();
try { if(permsMan == null)
if (plugin.vaultGroupManagement.playerRemoveGroup(player, Settings.getUnloggedinGroup) && plugin.vaultGroupManagement.playerAddGroup(player, group)) { ConsoleLogger.showError("Failed to access permissions manager instance, shutting down.");
return true; assert permsMan != null;
}
} catch (UnsupportedOperationException e) { // Remove old groups
ConsoleLogger.showError("Your permission system (" + plugin.vaultGroupManagement.getName() + ") do not support Group system with that config... unhook!"); permsMan.removeGroups(player, Arrays.asList(Settings.unRegisteredGroup, Settings.getRegisteredGroup, Settings.getUnloggedinGroup));
plugin.vaultGroupManagement = null;
return false; // Add the normal group, return the result
} return permsMan.addGroup(player, group);
return false;
} }
// TODO: Move to a Manager // TODO: Move to a Manager