mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-24 19:25:15 +01:00
Add support for superperms/PermissionsBukkit/whatever-you-wanna-call-it
This commit is contained in:
parent
3b7fcc67ad
commit
c37680b62c
@ -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" });
|
||||
|
||||
|
31
src/main/java/org/dynmap/permissions/BukkitPermissions.java
Normal file
31
src/main/java/org/dynmap/permissions/BukkitPermissions.java
Normal 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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user