mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-27 04:35:12 +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>
|
</exclusions>
|
||||||
</dependency>
|
</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 -->
|
<!-- zPermissions plugin -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.tyrannyofheaven.bukkit</groupId>
|
<groupId>org.tyrannyofheaven.bukkit</groupId>
|
||||||
|
@ -115,7 +115,7 @@ public class PermissionsManager implements Reloadable {
|
|||||||
case B_PERMISSIONS:
|
case B_PERMISSIONS:
|
||||||
return new BPermissionsHandler();
|
return new BPermissionsHandler();
|
||||||
case PERMISSIONS_BUKKIT:
|
case PERMISSIONS_BUKKIT:
|
||||||
return new PermissionsBukkitHandler();
|
return new PermissionsBukkitHandler(pluginManager);
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Unhandled permission type '" + type + "'");
|
throw new IllegalStateException("Unhandled permission type '" + type + "'");
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,29 @@
|
|||||||
package fr.xephi.authme.permission.handlers;
|
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.PermissionNode;
|
||||||
import fr.xephi.authme.permission.PermissionsSystemType;
|
import fr.xephi.authme.permission.PermissionsSystemType;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PermissionsBukkitHandler implements PermissionHandler {
|
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
|
@Override
|
||||||
public boolean addToGroup(Player player, String group) {
|
public boolean addToGroup(Player player, String group) {
|
||||||
return Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "permissions player addgroup " + player.getName() + " " + group);
|
return Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "permissions player addgroup " + player.getName() + " " + group);
|
||||||
@ -44,8 +58,11 @@ public class PermissionsBukkitHandler implements PermissionHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getGroups(Player player) {
|
public List<String> getGroups(Player player) {
|
||||||
// FIXME Gnat008 20160601: Add support for this
|
List<String> groups = new ArrayList<String>();
|
||||||
return new ArrayList<>();
|
for (Group group : permissionsBukkitInstance.getGroups(player.getUniqueId())) {
|
||||||
|
groups.add(group.getName());
|
||||||
|
}
|
||||||
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,8 +71,9 @@ public class PermissionsBukkitHandler implements PermissionHandler {
|
|||||||
List<String> groups = getGroups(player);
|
List<String> groups = getGroups(player);
|
||||||
|
|
||||||
// Make sure there is any group available, or return null
|
// Make sure there is any group available, or return null
|
||||||
if (groups.isEmpty())
|
if (groups.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Return the first group
|
// Return the first group
|
||||||
return groups.get(0);
|
return groups.get(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user