Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-24 18:10:08 +01:00
Added PermissionsProvider interface that can also handle permissions.
Dieser Commit ist enthalten in:
Ursprung
7a8aa9838e
Commit
488f841d69
26
src/com/sk89q/bukkit/migration/PermissionsProvider.java
Normale Datei
26
src/com/sk89q/bukkit/migration/PermissionsProvider.java
Normale Datei
@ -0,0 +1,26 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 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;
|
||||
|
||||
public interface PermissionsProvider {
|
||||
public boolean hasPermission(String name, String permission);
|
||||
public boolean inGroup(String player, String group);
|
||||
public String[] getGroups(String player);
|
||||
}
|
@ -21,6 +21,7 @@ package com.sk89q.bukkit.migration;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
public class PermissionsResolverManager implements PermissionsResolver {
|
||||
@ -40,6 +41,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
}
|
||||
|
||||
public void findResolver() {
|
||||
if (tryPluginPermissionsResolver()) return;
|
||||
if (tryGroupsUsers()) return;
|
||||
if (tryNijiPermissions()) return;
|
||||
if (tryFlatFilePermissions()) return;
|
||||
@ -78,6 +80,31 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean tryPluginPermissionsResolver() {
|
||||
for (Plugin plugin : server.getPluginManager().getPlugins()) {
|
||||
if (plugin instanceof PermissionsProvider) {
|
||||
perms = new PluginPermissionsResolver(
|
||||
(PermissionsProvider) plugin);
|
||||
logger.info(name + ": Using plugin '"
|
||||
+ plugin.getDescription().getName() + " for permissions.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setPluginPermissionsResolver(Plugin plugin) {
|
||||
if (!(plugin instanceof PermissionsProvider)) {
|
||||
return;
|
||||
}
|
||||
|
||||
perms = new PluginPermissionsResolver(
|
||||
(PermissionsProvider) plugin);
|
||||
logger.info(name + ": Using plugin '"
|
||||
+ plugin.getDescription().getName() + " for permissions.");
|
||||
}
|
||||
|
||||
public void load() {
|
||||
perms.load();
|
||||
}
|
||||
|
@ -39,9 +39,12 @@ public class PermissionsResolverServerListener extends ServerListener {
|
||||
*/
|
||||
@Override
|
||||
public void onPluginEnabled(PluginEvent event) {
|
||||
String name = event.getPlugin().getDescription().getName();
|
||||
Plugin plugin = event.getPlugin();
|
||||
String name = plugin.getDescription().getName();
|
||||
|
||||
if (name.equalsIgnoreCase("GroupUsers") || name.equalsIgnoreCase("Permissions")) {
|
||||
if (plugin instanceof PermissionsProvider) {
|
||||
manager.setPluginPermissionsResolver(plugin);
|
||||
} else if (name.equalsIgnoreCase("GroupUsers") || name.equalsIgnoreCase("Permissions")) {
|
||||
manager.findResolver();
|
||||
}
|
||||
}
|
||||
@ -53,9 +56,12 @@ public class PermissionsResolverServerListener extends ServerListener {
|
||||
*/
|
||||
@Override
|
||||
public void onPluginDisabled(PluginEvent event) {
|
||||
String name = event.getPlugin().getDescription().getName();
|
||||
Plugin plugin = event.getPlugin();
|
||||
String name = plugin.getDescription().getName();
|
||||
|
||||
if (name.equalsIgnoreCase("GroupUsers") || name.equalsIgnoreCase("Permissions")) {
|
||||
if (plugin instanceof PermissionsProvider
|
||||
|| name.equalsIgnoreCase("GroupUsers")
|
||||
|| name.equalsIgnoreCase("Permissions")) {
|
||||
manager.findResolver();
|
||||
}
|
||||
}
|
||||
|
49
src/com/sk89q/bukkit/migration/PluginPermissionsResolver.java
Normale Datei
49
src/com/sk89q/bukkit/migration/PluginPermissionsResolver.java
Normale Datei
@ -0,0 +1,49 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 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;
|
||||
|
||||
public class PluginPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
protected PermissionsProvider resolver;
|
||||
|
||||
public PluginPermissionsResolver(PermissionsProvider resolver) {
|
||||
this.resolver = resolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String name, String permission) {
|
||||
return resolver.hasPermission(name, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(String player, String group) {
|
||||
return resolver.inGroup(player, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups(String player) {
|
||||
return resolver.getGroups(player);
|
||||
}
|
||||
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren