mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-23 02:35:11 +01:00
FixMe from Gnat008 : Add PermissionsBukkit groups support
This commit is contained in:
parent
de579044f2
commit
de97c60b5d
14
pom.xml
14
pom.xml
@ -617,6 +617,20 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- PermissionsBukkit plugin -->
|
||||
<dependency>
|
||||
<groupId>com.platymuus</groupId>
|
||||
<artifactId>bukkit-permissions</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- zPermissions plugin -->
|
||||
<dependency>
|
||||
<groupId>org.tyrannyofheaven.bukkit</groupId>
|
||||
|
@ -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 + "'");
|
||||
}
|
||||
|
@ -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<String> getGroups(Player player) {
|
||||
// FIXME Gnat008 20160601: Add support for this
|
||||
return new ArrayList<>();
|
||||
List<String> groups = new ArrayList<String>();
|
||||
for (Group group : permissionsBukkitInstance.getGroups(player.getUniqueId())) {
|
||||
groups.add(group.getName());
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,8 +71,9 @@ public class PermissionsBukkitHandler implements PermissionHandler {
|
||||
List<String> 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);
|
||||
|
Loading…
Reference in New Issue
Block a user