diff --git a/pom.xml b/pom.xml index 52c17b68b..1b30189c7 100644 --- a/pom.xml +++ b/pom.xml @@ -617,6 +617,20 @@ + + + com.platymuus + bukkit-permissions + 2.5 + provided + + + org.bukkit + bukkit + + + + org.tyrannyofheaven.bukkit diff --git a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java index 29406be6c..7ce0b3e5a 100644 --- a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java +++ b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java @@ -115,7 +115,7 @@ public class PermissionsManager implements Reloadable { case B_PERMISSIONS: return new BPermissionsHandler(); case PERMISSIONS_BUKKIT: - return new PermissionsBukkitHandler(); + return new PermissionsBukkitHandler(pluginManager); default: throw new IllegalStateException("Unhandled permission type '" + type + "'"); } diff --git a/src/main/java/fr/xephi/authme/permission/handlers/PermissionsBukkitHandler.java b/src/main/java/fr/xephi/authme/permission/handlers/PermissionsBukkitHandler.java index e8e8a21e5..c215b8d17 100644 --- a/src/main/java/fr/xephi/authme/permission/handlers/PermissionsBukkitHandler.java +++ b/src/main/java/fr/xephi/authme/permission/handlers/PermissionsBukkitHandler.java @@ -1,15 +1,29 @@ package fr.xephi.authme.permission.handlers; +import com.platymuus.bukkit.permissions.Group; +import com.platymuus.bukkit.permissions.PermissionsPlugin; import fr.xephi.authme.permission.PermissionNode; import fr.xephi.authme.permission.PermissionsSystemType; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginManager; import java.util.ArrayList; import java.util.List; public class PermissionsBukkitHandler implements PermissionHandler { + private PermissionsPlugin permissionsBukkitInstance; + + public PermissionsBukkitHandler(PluginManager pluginManager) throws PermissionHandlerException { + Plugin plugin = pluginManager.getPlugin("PermissionsBukkit"); + if (plugin == null) { + throw new PermissionHandlerException("Could not get instance of PermissionsBukkit"); + } + permissionsBukkitInstance = (PermissionsPlugin) plugin; + } + @Override public boolean addToGroup(Player player, String group) { return Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "permissions player addgroup " + player.getName() + " " + group); @@ -44,8 +58,11 @@ public class PermissionsBukkitHandler implements PermissionHandler { @Override public List getGroups(Player player) { - // FIXME Gnat008 20160601: Add support for this - return new ArrayList<>(); + List groups = new ArrayList(); + for (Group group : permissionsBukkitInstance.getGroups(player.getUniqueId())) { + groups.add(group.getName()); + } + return groups; } @Override @@ -54,8 +71,9 @@ public class PermissionsBukkitHandler implements PermissionHandler { List groups = getGroups(player); // Make sure there is any group available, or return null - if (groups.isEmpty()) + if (groups.isEmpty()) { return null; + } // Return the first group return groups.get(0);