Added Nijiperms bridge detection, allowing DinnerPerms to no longer conflict with everything else by default.

Dieser Commit ist enthalten in:
zml2008 2011-08-07 01:00:48 -07:00
Ursprung 0040ba9867
Commit cea080e7c7
4 geänderte Dateien mit 31 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -15,12 +15,11 @@ public class DinnerPermsResolver implements PermissionsResolver {
public DinnerPermsResolver(Server server) {
this.server = server;
}
@Override
public void load() {
// Permissions are already loaded
}
@Override
public boolean hasPermission(String name, String permission) {
Player player = server.getPlayer(name);
if (player == null)
@ -41,12 +40,10 @@ public class DinnerPermsResolver implements PermissionsResolver {
return false;
}
@Override
public boolean hasPermission(String worldName, String name, String permission) {
return hasPermission(name, permission); // no per-world ability to check permissions in dinnerperms
}
@Override
public boolean inGroup(String name, String group) {
Player player = server.getPlayer(name);
if (player == null)
@ -54,7 +51,6 @@ public class DinnerPermsResolver implements PermissionsResolver {
return player.hasPermission(GROUP_PREFIX + group);
}
@Override
public String[] getGroups(String name) {
Player player = server.getPlayer(name);
if (player == null)

Datei anzeigen

@ -19,7 +19,9 @@
package com.sk89q.bukkit.migration;
import com.sun.xml.internal.fastinfoset.algorithm.BooleanEncodingAlgorithm;
import org.bukkit.Server;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@ -33,7 +35,7 @@ public class NijiPermissionsResolver implements PermissionsResolver {
}
public NijiPermissionsResolver(Server server)
public NijiPermissionsResolver(Server server, boolean ignoreBridges)
throws PluginAccessException, MissingPluginException {
this.server = server;
PluginManager manager = server.getPluginManager();
@ -42,6 +44,8 @@ public class NijiPermissionsResolver implements PermissionsResolver {
if (plugin == null) {
throw new MissingPluginException();
}
if (!checkRealNijiPerms(plugin, ignoreBridges))
throw new MissingPluginException();
try {
api = (Permissions)plugin;
@ -126,4 +130,15 @@ public class NijiPermissionsResolver implements PermissionsResolver {
public static class MissingPluginException extends Exception {
private static final long serialVersionUID = 7044832912491608706L;
}
public static boolean checkRealNijiPerms(Plugin plugin, boolean ignoreBridges) {
if (!ignoreBridges)
return true;
PluginCommand permsCommand = plugin.getServer().getPluginCommand("permissions");
if (permsCommand == null)
return false;
if (!permsCommand.getPlugin().getDescription().getName().equals("Permissions"))
return false;
return true;
}
}

Datei anzeigen

@ -56,6 +56,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
private Configuration permsConfig;
private String name;
private Logger logger;
protected boolean ignoreNijiPermsBridges;
public PermissionsResolverManager(Configuration config, Server server, String name, Logger logger) {
this.server = server;
@ -65,9 +66,9 @@ public class PermissionsResolverManager implements PermissionsResolver {
findResolver();
}
public void findResolver() {
if (tryDinnerPerms()) return;
if (tryPluginPermissionsResolver()) return;
if (tryNijiPermissions()) return;
if (tryDinnerPerms()) return;
if (tryFlatFilePermissions()) return;
perms = new ConfigurationPermissionsResolver(permsConfig);
@ -76,7 +77,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
private boolean tryNijiPermissions() {
try {
perms = new NijiPermissionsResolver(server);
perms = new NijiPermissionsResolver(server, ignoreNijiPermsBridges);
logger.info(name + ": Permissions plugin detected! Using Permissions plugin for permissions.");
return true;
} catch (Throwable e) {
@ -164,6 +165,11 @@ public class PermissionsResolverManager implements PermissionsResolver {
permsConfig.setProperty("dinnerperms", permsConfig.getBoolean("dinner-perms", true));
isUpdated = true;
}
if (!keys.contains("ignore-nijiperms-bridges")) {
permsConfig.setProperty("ignore-nijiperms-bridges", true);
isUpdated = true;
}
ignoreNijiPermsBridges = permsConfig.getBoolean("ignore-nijiperms-bridges", true);
if (keys.contains("dinner-perms")) {
permsConfig.removeProperty("dinner-perms");
isUpdated = true;

Datei anzeigen

@ -26,6 +26,8 @@ import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import java.util.Map;
public class PermissionsResolverServerListener extends ServerListener {
private PermissionsResolverManager manager;
@ -42,10 +44,10 @@ public class PermissionsResolverServerListener extends ServerListener {
public void onPluginEnable(PluginEnableEvent event) {
Plugin plugin = event.getPlugin();
String name = plugin.getDescription().getName();
if (plugin instanceof PermissionsProvider) {
manager.setPluginPermissionsResolver(plugin);
} else if (name.equalsIgnoreCase("GroupUsers") || name.equalsIgnoreCase("Permissions")) {
} else if (name.equalsIgnoreCase("Permissions") &&
NijiPermissionsResolver.checkRealNijiPerms(plugin, manager.ignoreNijiPermsBridges)) {
manager.findResolver();
manager.load();
}
@ -62,8 +64,8 @@ public class PermissionsResolverServerListener extends ServerListener {
String name = plugin.getDescription().getName();
if (plugin instanceof PermissionsProvider
|| name.equalsIgnoreCase("GroupUsers")
|| name.equalsIgnoreCase("Permissions")) {
|| (name.equalsIgnoreCase("Permissions") &&
NijiPermissionsResolver.checkRealNijiPerms(plugin, manager.ignoreNijiPermsBridges))) {
manager.findResolver();
manager.load();
}