mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-09-12 06:08:07 +02: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.debug.Debugger;
|
||||||
import org.dynmap.hdmap.HDBlockModels;
|
import org.dynmap.hdmap.HDBlockModels;
|
||||||
import org.dynmap.hdmap.TexturePack;
|
import org.dynmap.hdmap.TexturePack;
|
||||||
|
import org.dynmap.permissions.BukkitPermissions;
|
||||||
import org.dynmap.permissions.NijikokunPermissions;
|
import org.dynmap.permissions.NijikokunPermissions;
|
||||||
import org.dynmap.permissions.OpPermissions;
|
import org.dynmap.permissions.OpPermissions;
|
||||||
import org.dynmap.permissions.PermissionProvider;
|
import org.dynmap.permissions.PermissionProvider;
|
||||||
@ -199,6 +200,8 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
events = new Events();
|
events = new Events();
|
||||||
|
|
||||||
permissions = NijikokunPermissions.create(getServer(), "dynmap");
|
permissions = NijikokunPermissions.create(getServer(), "dynmap");
|
||||||
|
if (permissions == null)
|
||||||
|
permissions = BukkitPermissions.create("dynmap");
|
||||||
if (permissions == null)
|
if (permissions == null)
|
||||||
permissions = new OpPermissions(new String[] { "fullrender", "cancelrender", "radiusrender", "resetstats", "reload" });
|
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.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.dynmap.Log;
|
||||||
|
|
||||||
import com.nijiko.permissions.PermissionHandler;
|
import com.nijiko.permissions.PermissionHandler;
|
||||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||||
@ -17,6 +18,7 @@ public class NijikokunPermissions implements PermissionProvider {
|
|||||||
if (permissionsPlugin == null)
|
if (permissionsPlugin == null)
|
||||||
return null;
|
return null;
|
||||||
server.getPluginManager().enablePlugin(permissionsPlugin);
|
server.getPluginManager().enablePlugin(permissionsPlugin);
|
||||||
|
Log.info("Using Permissions " + permissionsPlugin.getDescription().getVersion() + " for access control");
|
||||||
return new NijikokunPermissions(permissionsPlugin, name);
|
return new NijikokunPermissions(permissionsPlugin, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import java.util.HashSet;
|
|||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.dynmap.Log;
|
||||||
|
|
||||||
public class OpPermissions implements PermissionProvider {
|
public class OpPermissions implements PermissionProvider {
|
||||||
public HashSet<String> opCommands = new HashSet<String>();
|
public HashSet<String> opCommands = new HashSet<String>();
|
||||||
@ -12,6 +13,7 @@ public class OpPermissions implements PermissionProvider {
|
|||||||
for (String opCommand : opCommands) {
|
for (String opCommand : opCommands) {
|
||||||
this.opCommands.add(opCommand);
|
this.opCommands.add(opCommand);
|
||||||
}
|
}
|
||||||
|
Log.info("Using ops.txt for access control");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user