Add support for superperms/PermissionsBukkit/whatever-you-wanna-call-it

This commit is contained in:
Mike Primm 2011-08-23 08:21:03 +08:00 committed by mikeprimm
parent 3b7fcc67ad
commit c37680b62c
4 changed files with 38 additions and 0 deletions

View File

@ -58,6 +58,7 @@ import org.dynmap.debug.Debug;
import org.dynmap.debug.Debugger;
import org.dynmap.hdmap.HDBlockModels;
import org.dynmap.hdmap.TexturePack;
import org.dynmap.permissions.BukkitPermissions;
import org.dynmap.permissions.NijikokunPermissions;
import org.dynmap.permissions.OpPermissions;
import org.dynmap.permissions.PermissionProvider;
@ -199,6 +200,8 @@ public class DynmapPlugin extends JavaPlugin {
events = new Events();
permissions = NijikokunPermissions.create(getServer(), "dynmap");
if (permissions == null)
permissions = BukkitPermissions.create("dynmap");
if (permissions == null)
permissions = new OpPermissions(new String[] { "fullrender", "cancelrender", "radiusrender", "resetstats", "reload" });

View File

@ -0,0 +1,31 @@
package org.dynmap.permissions;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.dynmap.Log;
public class BukkitPermissions implements PermissionProvider {
String name;
public static BukkitPermissions create(String name) {
try {
Class.forName("org.bukkit.permissions.PermissibleBase"); /* See if class exists */
} catch (ClassNotFoundException cnfx) {
return null;
}
Log.info("Using Bukkit Permissions (superperms) for access control");
return new BukkitPermissions(name);
}
public BukkitPermissions(String name) {
this.name = name;
}
@Override
public boolean has(CommandSender sender, String permission) {
Player player = sender instanceof Player ? (Player) sender : null;
return player != null
? player.hasPermission(name + "." + permission) || player.hasPermission(name + ".*")
: true;
}
}

View File

@ -4,6 +4,7 @@ import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.dynmap.Log;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
@ -17,6 +18,7 @@ public class NijikokunPermissions implements PermissionProvider {
if (permissionsPlugin == null)
return null;
server.getPluginManager().enablePlugin(permissionsPlugin);
Log.info("Using Permissions " + permissionsPlugin.getDescription().getVersion() + " for access control");
return new NijikokunPermissions(permissionsPlugin, name);
}

View File

@ -4,6 +4,7 @@ import java.util.HashSet;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.dynmap.Log;
public class OpPermissions implements PermissionProvider {
public HashSet<String> opCommands = new HashSet<String>();
@ -12,6 +13,7 @@ public class OpPermissions implements PermissionProvider {
for (String opCommand : opCommands) {
this.opCommands.add(opCommand);
}
Log.info("Using ops.txt for access control");
}
@Override