mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-12-28 03:48:17 +01:00
added basic zPerms support through commands. fixed leftover codebits in
bPerms/PBukkit implementations. zPerms is currently not enabled yet.
This commit is contained in:
parent
730865102d
commit
062c0ee12b
@ -16,7 +16,6 @@ import org.bukkit.plugin.PluginManager;
|
||||
import com.platymuus.bukkit.permissions.Group;
|
||||
import com.platymuus.bukkit.permissions.PermissionsPlugin;
|
||||
|
||||
import net.D3GN.MiracleM4n.mChat.mChatAPI;
|
||||
import net.milkbowl.vault.Vault;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
@ -25,7 +24,6 @@ public class Permission_PermissionsBukkit extends Permission {
|
||||
private final String name = "PermissionsBukkit";
|
||||
private PluginManager pluginManager = null;
|
||||
private PermissionsPlugin perms = null;
|
||||
private mChatAPI mChat = null;
|
||||
private PermissionServerListener permissionServerListener = null;
|
||||
private ConsoleCommandSender ccs;
|
||||
|
||||
@ -47,14 +45,6 @@ public class Permission_PermissionsBukkit extends Permission {
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
|
||||
if (mChat == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("mChat");
|
||||
if (chat != null) {
|
||||
mChat = net.D3GN.MiracleM4n.mChat.mChat.API;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "mChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PermissionServerListener extends ServerListener {
|
||||
@ -75,13 +65,6 @@ public class Permission_PermissionsBukkit extends Permission {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mChat == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("mChat");
|
||||
if (chat != null) {
|
||||
mChat = net.D3GN.MiracleM4n.mChat.mChat.API;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "mChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
@ -91,12 +74,6 @@ public class Permission_PermissionsBukkit extends Permission {
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
if (mChat != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("mChat")) {
|
||||
mChat = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), "mChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,7 +163,7 @@ public class Permission_PermissionsBukkit extends Permission {
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
if (world != null) {
|
||||
throw new UnsupportedOperationException(getName() + " does not support world based groups.");
|
||||
return false;
|
||||
}
|
||||
return plugin.getServer().dispatchCommand(ccs, "permissions player addgroup " + player + " " + group);
|
||||
}
|
||||
@ -194,7 +171,7 @@ public class Permission_PermissionsBukkit extends Permission {
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
if (world != null) {
|
||||
throw new UnsupportedOperationException(getName() + " does not support world based groups.");
|
||||
return false;
|
||||
}
|
||||
return plugin.getServer().dispatchCommand(ccs, "permissions player removegroup " + player + " " + group);
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import de.bananaco.permissions.Permissions;
|
||||
import de.bananaco.permissions.interfaces.PermissionSet;
|
||||
@ -20,230 +19,226 @@ import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
public class Permission_bPermissions extends Permission {
|
||||
|
||||
private String name = "bPermissions";
|
||||
private PluginManager pluginManager = null;
|
||||
private WorldPermissionsManager perms;
|
||||
private PermissionServerListener permissionServerListener = null;
|
||||
private String name = "bPermissions";
|
||||
private WorldPermissionsManager perms;
|
||||
private PermissionServerListener permissionServerListener = null;
|
||||
|
||||
public Permission_bPermissions(Vault plugin) {
|
||||
this.plugin = plugin;
|
||||
pluginManager = this.plugin.getServer().getPluginManager();
|
||||
public Permission_bPermissions(Vault plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
permissionServerListener = new PermissionServerListener();
|
||||
permissionServerListener = new PermissionServerListener();
|
||||
|
||||
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
|
||||
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
|
||||
this.plugin.getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
|
||||
this.plugin.getServer().getPluginManager().registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (perms == null) {
|
||||
Plugin p = plugin.getServer().getPluginManager().getPlugin("bPermissions");
|
||||
if (p != null) {
|
||||
perms = Permissions.getWorldPermissionsManager();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Load Plugin in case it was loaded before
|
||||
if (perms == null) {
|
||||
Plugin p = plugin.getServer().getPluginManager().getPlugin("bPermissions");
|
||||
if (p != null) {
|
||||
perms = Permissions.getWorldPermissionsManager();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PermissionServerListener extends ServerListener {
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (perms == null) {
|
||||
Plugin p = event.getPlugin();
|
||||
if(p.getDescription().getName().equals("bPermissions")) {
|
||||
if (p.isEnabled()) {
|
||||
perms = Permissions.getWorldPermissionsManager();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private class PermissionServerListener extends ServerListener {
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (perms == null) {
|
||||
Plugin p = event.getPlugin();
|
||||
if(p.getDescription().getName().equals("bPermissions") && p.isEnabled()) {
|
||||
perms = Permissions.getWorldPermissionsManager();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (perms != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("bPermissions")) {
|
||||
perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (perms != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("bPermissions")) {
|
||||
perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.perms != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
return HasPermission.has(player, world, permission);
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.perms != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
set.addPlayerNode(permission, player);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
set.removePlayerNode(permission, player);
|
||||
return true;
|
||||
}
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
// use superclass implementation of playerAddTransient() and playerRemoveTransient()
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
if (set.getGroupNodes(group) == null)
|
||||
return false;
|
||||
|
||||
return set.getGroupNodes(group).contains(permission);
|
||||
}
|
||||
return HasPermission.has(player, world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
if (set.getGroupNodes(group) == null)
|
||||
return false;
|
||||
|
||||
set.addNode(permission, group);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
if (set.getGroupNodes(group) == null)
|
||||
return false;
|
||||
|
||||
set.removeNode(permission, group);
|
||||
return true;
|
||||
}
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
if (set.getGroups(player) == null)
|
||||
return false;
|
||||
|
||||
return set.getGroups(player).contains(group);
|
||||
}
|
||||
set.addPlayerNode(permission, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
if (set.getGroupNodes(group) == null)
|
||||
return false;
|
||||
|
||||
set.addGroup(player, group);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
set.removeGroup(player, group);
|
||||
return true;
|
||||
}
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
if (world == null)
|
||||
return null;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return null;
|
||||
|
||||
List<String> groups = set.getGroups(player);
|
||||
return groups == null ? null : groups.toArray(new String[0]);
|
||||
}
|
||||
set.removePlayerNode(permission, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
if (world == null)
|
||||
return null;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return null;
|
||||
|
||||
List<String> groups = set.getGroups(player);
|
||||
if (groups == null || groups.isEmpty())
|
||||
return null;
|
||||
else
|
||||
return groups.get(0);
|
||||
}
|
||||
// use superclass implementation of playerAddTransient() and playerRemoveTransient()
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
throw new UnsupportedOperationException("bPermissions does not support server-wide groups");
|
||||
}
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
if (set.getGroupNodes(group) == null)
|
||||
return false;
|
||||
|
||||
return set.getGroupNodes(group).contains(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
if (set.getGroupNodes(group) == null)
|
||||
return false;
|
||||
|
||||
set.addNode(permission, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
if (set.getGroupNodes(group) == null)
|
||||
return false;
|
||||
|
||||
set.removeNode(permission, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
if (set.getGroups(player) == null)
|
||||
return false;
|
||||
|
||||
return set.getGroups(player).contains(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
if (set.getGroupNodes(group) == null)
|
||||
return false;
|
||||
|
||||
set.addGroup(player, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return false;
|
||||
|
||||
set.removeGroup(player, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
if (world == null)
|
||||
return null;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return null;
|
||||
|
||||
List<String> groups = set.getGroups(player);
|
||||
return groups == null ? null : groups.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
if (world == null)
|
||||
return null;
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null)
|
||||
return null;
|
||||
|
||||
List<String> groups = set.getGroups(player);
|
||||
if (groups == null || groups.isEmpty())
|
||||
return null;
|
||||
else
|
||||
return groups.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
throw new UnsupportedOperationException("bPermissions does not support server-wide groups");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,176 @@
|
||||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsPlugin;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
public class Permission_zPermissions extends Permission {
|
||||
|
||||
private static final String name = "zPermissions";
|
||||
private ZPermissionsPlugin perms;
|
||||
private final Plugin plugin;
|
||||
private PermissionServerListener permissionServerListener = null;
|
||||
private ConsoleCommandSender ccs;
|
||||
|
||||
public Permission_zPermissions(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
ccs = Bukkit.getServer().getConsoleSender();
|
||||
permissionServerListener = new PermissionServerListener();
|
||||
|
||||
this.plugin.getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
|
||||
this.plugin.getServer().getPluginManager().registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (perms == null) {
|
||||
Plugin p = plugin.getServer().getPluginManager().getPlugin("zPermissions");
|
||||
if (p != null) {
|
||||
perms = (ZPermissionsPlugin) p;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PermissionServerListener extends ServerListener {
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (perms == null) {
|
||||
Plugin p = event.getPlugin();
|
||||
if(p.getDescription().getName().equals("zPermissions") && p.isEnabled()) {
|
||||
perms = (ZPermissionsPlugin) p;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (perms != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("zPermissions")) {
|
||||
perms = null;
|
||||
perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (perms == null) {
|
||||
return false;
|
||||
} else {
|
||||
return perms.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
Player p = Bukkit.getServer().getPlayer(player);
|
||||
if (p == null)
|
||||
throw new UnsupportedOperationException(getName() + " does not support offline player resolution.");
|
||||
else
|
||||
return playerHas(p, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
if (world != null)
|
||||
return false;
|
||||
return plugin.getServer().dispatchCommand(ccs, "permissions player set " + player + " " + permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
if (world != null)
|
||||
return false;
|
||||
return plugin.getServer().dispatchCommand(ccs, "permissions player unset " + player + " " + permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
if (world != null)
|
||||
return false;
|
||||
return plugin.getServer().dispatchCommand(ccs, "permissions group set " + group + " " + permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
if (world != null)
|
||||
return false;
|
||||
return plugin.getServer().dispatchCommand(ccs, "permissions group unset " + group + " " + permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
Player p = Bukkit.getServer().getPlayer(player);
|
||||
if (p == null)
|
||||
throw new UnsupportedOperationException(getName() + " does not support offline player resolution.");
|
||||
|
||||
return p.hasPermission("group." + group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
if (world != null)
|
||||
return false;
|
||||
return plugin.getServer().dispatchCommand(ccs, "permissions group add " + player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
if (world != null)
|
||||
return false;
|
||||
return plugin.getServer().dispatchCommand(ccs, "permissions group remove " + player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
Player p = Bukkit.getServer().getPlayer(player);
|
||||
if (p == null)
|
||||
throw new UnsupportedOperationException(getName() + " does not support offline player resolution.");
|
||||
|
||||
List<String> groups = new ArrayList<String>();
|
||||
for (PermissionAttachmentInfo pai : p.getEffectivePermissions()) {
|
||||
if (!pai.getPermission().startsWith("group.") || !pai.getValue())
|
||||
continue;
|
||||
groups.add(pai.getPermission().substring(6));
|
||||
}
|
||||
return groups.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
throw new UnsupportedOperationException(getName() + " does not support primary group resolution.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
throw new UnsupportedOperationException(getName() + " does not support group resolution.");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user