From 42dee2e10125ab560b16a85a07c10f49829518b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Vis=C3=A9e?= Date: Sat, 21 Nov 2015 14:44:43 +0100 Subject: [PATCH] Created addGroup method in permissions manager --- .../authme/permission/PermissionsManager.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java index 45f4e8cd3..cacf74d22 100644 --- a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java +++ b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java @@ -442,6 +442,63 @@ public class PermissionsManager { } } + /** + * Add the permission group of a player, if supported. + * + * @param player The player + * @param groupName The name of the group. + * + * @return True if succeed, false otherwise. + */ + @SuppressWarnings({"unchecked", "rawtypes", "deprecation"}) + public boolean addGroup(Player player, String groupName) { + if(!isEnabled()) + // No permissions system is used, return false + return false; + + // Set the group the proper way + switch(this.permsType) { + case PERMISSIONS_EX: + // Permissions Ex + PermissionUser user = PermissionsEx.getUser(player); + user.addGroup(groupName); + return true; + + case PERMISSIONS_BUKKIT: + // Permissions Bukkit + // Permissions Bukkit doesn't support groups, return false + return false; + + case B_PERMISSIONS: + // bPermissions + ApiLayer.addGroup(player.getWorld().getName(), CalculableType.USER, player.getName(), groupName); + return true; + + case ESSENTIALS_GROUP_MANAGER: + // Essentials Group Manager + // Add the group to the user using a command + return Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuadd " + player.getName() + " " + groupName); + + case Z_PERMISSIONS: + // zPermissions + // Add the group to the user using a command + return Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "permissions player " + player.getName() + " addgroup " + groupName); + + case VAULT: + // Vault + vaultPerms.playerAddGroup(player, groupName); + return true; + + case NONE: + // Not hooked into any permissions system, return false + return false; + + default: + // Something went wrong, return false + return false; + } + } + /** * Set the permission group of a player, if supported. *