From bcf4eeab00631133ba2c52d904e8d39973e985a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Vis=C3=A9e?= Date: Sat, 21 Nov 2015 15:15:04 +0100 Subject: [PATCH] Created removeGroup method in permissions manager --- .../authme/permission/PermissionsManager.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java index 6830622a3..0dbfc52fc 100644 --- a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java +++ b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java @@ -525,6 +525,64 @@ public class PermissionsManager { return result; } + /** + * Remove 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. + * False is also returned if this feature isn't supported for the current permissions system. + */ + @SuppressWarnings({"unchecked", "rawtypes", "deprecation"}) + public boolean removeGroup(Player player, String groupName) { + // If no permissions system is used, return false + if(!isEnabled()) + return false; + + // Set the group the proper way + switch(this.permsType) { + case PERMISSIONS_EX: + // Permissions Ex + PermissionUser user = PermissionsEx.getUser(player); + user.removeGroup(groupName); + return true; + + case PERMISSIONS_BUKKIT: + // Permissions Bukkit + // Remove the group to the user using a command + return Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "permissions player removegroup " + player.getName() + " " + groupName); + + case B_PERMISSIONS: + // bPermissions + ApiLayer.removeGroup(player.getWorld().getName(), CalculableType.USER, player.getName(), groupName); + return true; + + case ESSENTIALS_GROUP_MANAGER: + // Essentials Group Manager + // Remove the group to the user using a command + return Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manudelsub " + player.getName() + " " + groupName); + + case Z_PERMISSIONS: + // zPermissions + // Remove the group to the user using a command + return Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "permissions player " + player.getName() + " removegroup " + groupName); + + case VAULT: + // Vault + vaultPerms.playerRemoveGroup(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. *