mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-15 00:43:33 +00:00
99 lines
3.4 KiB
Java
99 lines
3.4 KiB
Java
|
// $Id$
|
||
|
/*
|
||
|
* WorldEdit
|
||
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation, either version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
package com.sk89q.bukkit.migration;
|
||
|
|
||
|
import java.lang.reflect.*;
|
||
|
import org.bukkit.Server;
|
||
|
import org.bukkit.entity.Player;
|
||
|
import org.bukkit.event.Event;
|
||
|
import org.bukkit.event.player.PlayerChatEvent;
|
||
|
import org.bukkit.plugin.Plugin;
|
||
|
import org.bukkit.plugin.PluginManager;
|
||
|
import com.bukkit.authorblues.GroupUsers.GroupUsers;
|
||
|
import com.bukkit.authorblues.GroupUsers.GroupUsersPlayerListener;
|
||
|
|
||
|
public class GroupUsersPemissionsResolver implements PermissionsResolver {
|
||
|
private Server server;
|
||
|
private GroupUsersPlayerListener listener;
|
||
|
|
||
|
public void load() {
|
||
|
|
||
|
}
|
||
|
|
||
|
public GroupUsersPemissionsResolver(Server server)
|
||
|
throws PluginAccessException, MissingPluginException {
|
||
|
this.server = server;
|
||
|
PluginManager manager = server.getPluginManager();
|
||
|
|
||
|
Plugin plugin = manager.getPlugin("GroupUsers");
|
||
|
if (plugin == null) {
|
||
|
throw new MissingPluginException();
|
||
|
}
|
||
|
|
||
|
GroupUsers groupUsers = (GroupUsers)plugin;
|
||
|
try {
|
||
|
Field field = groupUsers.getClass().getDeclaredField("playerListener");
|
||
|
field.setAccessible(true);
|
||
|
listener = (GroupUsersPlayerListener)field.get(groupUsers);
|
||
|
} catch (SecurityException e) {
|
||
|
throw new PluginAccessException();
|
||
|
} catch (NoSuchFieldException e) {
|
||
|
throw new PluginAccessException();
|
||
|
} catch (IllegalArgumentException e) {
|
||
|
throw new PluginAccessException();
|
||
|
} catch (IllegalAccessException e) {
|
||
|
throw new PluginAccessException();
|
||
|
} catch (ClassCastException e) {
|
||
|
throw new PluginAccessException();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public boolean hasPermission(String name, String permission) {
|
||
|
try {
|
||
|
Player player = server.getPlayer(name);
|
||
|
if (player == null) {
|
||
|
return false;
|
||
|
}
|
||
|
PlayerChatEvent event = new PlayerChatEvent(Event.Type.PLAYER_CHAT, player, permission);
|
||
|
listener.onPlayerCommand(event);
|
||
|
return !event.isCancelled();
|
||
|
} catch (Throwable t) {
|
||
|
t.printStackTrace();
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public boolean inGroup(String player, String group) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public String[] getGroups(String player) {
|
||
|
return new String[0];
|
||
|
}
|
||
|
|
||
|
public static class PluginAccessException extends Exception {
|
||
|
private static final long serialVersionUID = 7044832912491608706L;
|
||
|
}
|
||
|
|
||
|
public static class MissingPluginException extends Exception {
|
||
|
private static final long serialVersionUID = 7044832912491608706L;
|
||
|
}
|
||
|
}
|