Add direct support for PeX, bPerms, PermBukkit

This commit is contained in:
Mike Primm 2012-03-23 22:02:13 -05:00
parent 67e0bd2f2c
commit faa1948225
8 changed files with 139 additions and 1 deletions

BIN
PermissionsBukkit.jar Normal file

Binary file not shown.

BIN
PermissionsEx.jar Normal file

Binary file not shown.

BIN
bpermissions.jar Normal file

Binary file not shown.

21
pom.xml
View File

@ -158,5 +158,26 @@
<version>dev-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ru.tehkode</groupId>
<artifactId>PermissionsEx</artifactId>
<version>1.19.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/PermissionsEx.jar</systemPath>
</dependency>
<dependency>
<groupId>de.bananaco</groupId>
<artifactId>bPermissions</artifactId>
<version>2.9.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/bpermissions.jar</systemPath>
</dependency>
<dependency>
<groupId>com.platymuus.bukkit.permissions</groupId>
<artifactId>PermissionsBukkit</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>${project.basedir}/PermissionsBukkit.jar</systemPath>
</dependency>
</dependencies>
</project>

View File

@ -63,7 +63,10 @@ import org.dynmap.PlayerList;
import org.dynmap.bukkit.permissions.BukkitPermissions;
import org.dynmap.bukkit.permissions.NijikokunPermissions;
import org.dynmap.bukkit.permissions.OpPermissions;
import org.dynmap.bukkit.permissions.PEXPermissions;
import org.dynmap.bukkit.permissions.PermBukkitPermissions;
import org.dynmap.bukkit.permissions.PermissionProvider;
import org.dynmap.bukkit.permissions.bPermPermissions;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.DynmapCommandSender;
import org.dynmap.common.DynmapPlayer;
@ -417,6 +420,12 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
/* Set up player login/quit event handler */
registerPlayerLoginListener();
permissions = PEXPermissions.create(getServer(), "dynmap");
if (permissions == null)
permissions = bPermPermissions.create(getServer(), "dynmap");
if (permissions == null)
permissions = PermBukkitPermissions.create(getServer(), "dynmap");
if (permissions == null)
permissions = NijikokunPermissions.create(getServer(), "dynmap");
if (permissions == null)
permissions = BukkitPermissions.create("dynmap");

View File

@ -0,0 +1,37 @@
package org.dynmap.bukkit.permissions;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.dynmap.Log;
import ru.tehkode.permissions.PermissionManager;
import ru.tehkode.permissions.bukkit.PermissionsEx;
public class PEXPermissions implements PermissionProvider {
String name;
PermissionManager pm;
public static PEXPermissions create(Server server, String name) {
Plugin permissionsPlugin = server.getPluginManager().getPlugin("PermissionsEx");
if (permissionsPlugin == null)
return null;
server.getPluginManager().enablePlugin(permissionsPlugin);
if(PermissionsEx.isAvailable() == false)
return null;
Log.info("Using PermissionsEx " + permissionsPlugin.getDescription().getVersion() + " for access control");
return new PEXPermissions(name);
}
public PEXPermissions(String name) {
this.name = name;
pm = PermissionsEx.getPermissionManager();
}
@Override
public boolean has(CommandSender sender, String permission) {
Player player = sender instanceof Player ? (Player) sender : null;
return (player != null) ? pm.has(player, name + "." + permission) : true;
}
}

View File

@ -0,0 +1,36 @@
package org.dynmap.bukkit.permissions;
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.platymuus.bukkit.permissions.PermissionsPlugin;
public class PermBukkitPermissions implements PermissionProvider {
String name;
PermissionsPlugin plugin;
public static PermBukkitPermissions create(Server server, String name) {
Plugin permissionsPlugin = server.getPluginManager().getPlugin("PermissionsBukkit");
if (permissionsPlugin == null)
return null;
server.getPluginManager().enablePlugin(permissionsPlugin);
Log.info("Using PermissionsBukkit " + permissionsPlugin.getDescription().getVersion() + " for access control");
return new PermBukkitPermissions(permissionsPlugin, name);
}
public PermBukkitPermissions(Plugin permissionsPlugin, String name) {
this.name = name;
plugin = (PermissionsPlugin) permissionsPlugin;
}
@Override
public boolean has(CommandSender sender, String permission) {
Player player = sender instanceof Player ? (Player) sender : null;
return (player != null) ? plugin.getPlayerInfo(player.getName()).getPermissions().containsKey(name + "." + permission) : true;
}
}

View File

@ -0,0 +1,35 @@
package org.dynmap.bukkit.permissions;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.dynmap.Log;
import ru.tehkode.permissions.bukkit.PermissionsEx;
import de.bananaco.bpermissions.api.ApiLayer;
import de.bananaco.bpermissions.api.util.CalculableType;
public class bPermPermissions implements PermissionProvider {
String name;
public static bPermPermissions create(Server server, String name) {
Plugin permissionsPlugin = server.getPluginManager().getPlugin("bPermissions");
if (permissionsPlugin == null)
return null;
server.getPluginManager().enablePlugin(permissionsPlugin);
Log.info("Using bPermissions " + permissionsPlugin.getDescription().getVersion() + " for access control");
return new bPermPermissions(name);
}
public bPermPermissions(String name) {
this.name = name;
}
@Override
public boolean has(CommandSender sender, String permission) {
Player player = sender instanceof Player ? (Player) sender : null;
return (player != null) ? ApiLayer.hasPermission(player.getWorld().getName(), CalculableType.USER, player.getName(), name + "." + permission) : true;
}
}