geforkt von Mirrors/FastAsyncWorldEdit
Moved PermissionsResolverServerListener into PermissionsResolverManager and got rid of some unnecessary methods.
Dieser Commit ist enthalten in:
Ursprung
cd2f56918d
Commit
deea1f7655
@ -24,6 +24,9 @@ import com.sk89q.util.yaml.YAMLFormat;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
@ -76,7 +79,6 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
|
||||
private Server server;
|
||||
private PermissionsResolver permissionResolver;
|
||||
private PermissionsResolverServerListener listener;
|
||||
private YAMLProcessor config;
|
||||
private Logger logger = Logger.getLogger(getClass().getCanonicalName());
|
||||
private List<Class<? extends PermissionsResolver>> enabledResolvers = new ArrayList<Class<? extends PermissionsResolver>>();
|
||||
@ -93,7 +95,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
|
||||
protected PermissionsResolverManager(Plugin plugin) {
|
||||
this.server = plugin.getServer();
|
||||
this.listener = new PermissionsResolverServerListener(this, plugin);
|
||||
(new ServerListener()).register(plugin); // Register the events
|
||||
|
||||
loadConfig(new File("wepif.yml"));
|
||||
findResolver();
|
||||
@ -168,6 +170,10 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
return permissionResolver.getGroups(player);
|
||||
}
|
||||
|
||||
public String getDetectionMessage() {
|
||||
return "Using WEPIF for permissions";
|
||||
}
|
||||
|
||||
private boolean loadConfig(File file) {
|
||||
boolean isUpdated = false;
|
||||
if (!file.exists()) {
|
||||
@ -253,20 +259,39 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
return isUpdated;
|
||||
}
|
||||
|
||||
boolean hasServerListener() {
|
||||
return listener != null;
|
||||
}
|
||||
|
||||
void setServerListener(PermissionsResolverServerListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public static class MissingPluginException extends Exception {
|
||||
private static final long serialVersionUID = 7044832912491608706L;
|
||||
}
|
||||
|
||||
public String getDetectionMessage() {
|
||||
return "Using WEPIF for permissions";
|
||||
class ServerListener extends org.bukkit.event.server.ServerListener {
|
||||
|
||||
@Override
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
Plugin plugin = event.getPlugin();
|
||||
String name = plugin.getDescription().getName();
|
||||
if (plugin instanceof PermissionsProvider) {
|
||||
setPluginPermissionsResolver(plugin);
|
||||
} else if ("Permissions".equals(name) || "PermissionsEx".equals(name)) {
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
String name = event.getPlugin().getDescription().getName();
|
||||
|
||||
if (event.getPlugin() instanceof PermissionsProvider
|
||||
|| "Permissions".equals(name) || "PermissionsEx".equals(name)) {
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
void register(Plugin plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvent(Event.Type.PLUGIN_ENABLE,
|
||||
this, Event.Priority.Normal, plugin);
|
||||
plugin.getServer().getPluginManager().registerEvent(Event.Type.PLUGIN_DISABLE,
|
||||
this, Event.Priority.Normal, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,80 +0,0 @@
|
||||
// $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.wepif;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class PermissionsResolverServerListener extends ServerListener {
|
||||
private PermissionsResolverManager manager;
|
||||
|
||||
public PermissionsResolverServerListener(PermissionsResolverManager manager, Plugin plugin) {
|
||||
this.manager = manager;
|
||||
if (!manager.hasServerListener()) {
|
||||
register(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a plugin is enabled
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@Override
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
Plugin plugin = event.getPlugin();
|
||||
String name = plugin.getDescription().getName();
|
||||
if (plugin instanceof PermissionsProvider) {
|
||||
manager.setPluginPermissionsResolver(plugin);
|
||||
} else if ("Permissions".equals(name) || "PermissionsEx".equals(name)) {
|
||||
manager.findResolver();
|
||||
manager.load();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a plugin is disabled
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@Override
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
Plugin plugin = event.getPlugin();
|
||||
String name = plugin.getDescription().getName();
|
||||
|
||||
if (plugin instanceof PermissionsProvider || "Permissions".equals(name) || "PermissionsEx".equals(name)) {
|
||||
manager.findResolver();
|
||||
manager.load();
|
||||
}
|
||||
}
|
||||
|
||||
public void register(Plugin plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvent(Event.Type.PLUGIN_ENABLE,
|
||||
this, Priority.Normal, plugin);
|
||||
plugin.getServer().getPluginManager().registerEvent(Event.Type.PLUGIN_DISABLE,
|
||||
this, Priority.Normal, plugin);
|
||||
manager.setServerListener(this);
|
||||
}
|
||||
|
||||
}
|
@ -4,7 +4,7 @@ package com.sk89q.wepif;
|
||||
* @author zml2008
|
||||
*/
|
||||
public class WEPIFRuntimeException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 5092745960439109699L;
|
||||
|
||||
public WEPIFRuntimeException(String message) {
|
||||
super(message);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren