From f7f455a56ab49dd7f2488fe2802dac27f5d2b651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Vis=C3=A9e?= Date: Sat, 21 Nov 2015 15:24:53 +0100 Subject: [PATCH] Created setGroups method in permissions manager --- .../authme/permission/PermissionsManager.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java index 15d86a664..1edda2eab 100644 --- a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java +++ b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java @@ -610,6 +610,7 @@ public class PermissionsManager { /** * Set the permission group of a player, if supported. + * This clears the current groups of the player. * * @param player The player * @param groupName The name of the group. @@ -675,6 +676,41 @@ public class PermissionsManager { } } + /** + * Set the permission groups of a player, if supported. + * This clears the current groups of the player. + * + * @param player The player + * @param groupNames The name of the groups to set. + * + * @return True if succeed, false otherwise. + * False is also returned if this feature isn't supported for the current permissions system. + */ + @SuppressWarnings({"unchecked", "rawtypes", "deprecation"}) + public boolean setGroups(Player player, List groupNames) { + // If no permissions system is used or if there's no group supplied, return false + if(!isEnabled() || groupNames.size() <= 0) + return false; + + // Set the main group + if(!setGroup(player, groupNames.get(0))) + return false; + + // Add the rest of the groups + boolean result = true; + for(int i = 1; i < groupNames.size(); i++) { + // Get the group name + String groupName = groupNames.get(0); + + // Add this group + if(!addGroup(player, groupName)) + result = false; + } + + // Return the result + return result; + } + public enum PermissionsSystemType { NONE("None"), PERMISSIONS_EX("PermissionsEx"),