Add dynmap.webchat permission - option to restrict webchat rights

This commit is contained in:
Mike Primm 2012-03-25 14:29:49 -05:00
parent 8f9d2c01c2
commit 3ed44ee905
9 changed files with 64 additions and 16 deletions

View File

@ -290,6 +290,13 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
} }
return rslt; return rslt;
} }
@Override
public boolean checkPlayerPermission(String player, String perm) {
OfflinePlayer p = getServer().getOfflinePlayer(player);
if(p.isBanned())
return false;
return permissions.hasOfflinePermission(player, perm);
}
} }
/** /**
* Player access abstraction class * Player access abstraction class

View File

@ -40,7 +40,7 @@ public class BukkitPermissions implements PermissionProvider {
if (p != null) { if (p != null) {
hasperms = new HashSet<String>(); hasperms = new HashSet<String>();
for(String perm : perms) { for(String perm : perms) {
if (p.hasPermission(perm)) { if (p.hasPermission(name + "." + perm)) {
hasperms.add(perm); hasperms.add(perm);
} }
} }
@ -48,4 +48,12 @@ public class BukkitPermissions implements PermissionProvider {
return hasperms; return hasperms;
} }
@Override
public boolean hasOfflinePermission(String player, String perm) {
Player p = Bukkit.getPlayerExact(name);
if (p != null)
return p.hasPermission(name + "." + perm);
else
return false;
}
} }

View File

@ -17,6 +17,7 @@ public class NijikokunPermissions implements PermissionProvider {
String name; String name;
PermissionHandler permissions; PermissionHandler permissions;
Plugin plugin; Plugin plugin;
String defworld;
public static NijikokunPermissions create(Server server, String name) { public static NijikokunPermissions create(Server server, String name) {
Plugin permissionsPlugin = server.getPluginManager().getPlugin("Permissions"); Plugin permissionsPlugin = server.getPluginManager().getPlugin("Permissions");
@ -31,6 +32,7 @@ public class NijikokunPermissions implements PermissionProvider {
public NijikokunPermissions(Plugin permissionsPlugin, String name) { public NijikokunPermissions(Plugin permissionsPlugin, String name) {
this.name = name; this.name = name;
plugin = permissionsPlugin; plugin = permissionsPlugin;
defworld = Bukkit.getServer().getWorlds().get(0).getName();
} }
@Override @Override
@ -45,16 +47,18 @@ public class NijikokunPermissions implements PermissionProvider {
@Override @Override
public Set<String> hasOfflinePermissions(String player, Set<String> perms) { public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
HashSet<String> hasperms = null; HashSet<String> hasperms = new HashSet<String>();
Player plyr = Bukkit.getPlayerExact(player); for (String pp : perms) {
if(plyr != null) { if (permissions.has(defworld, player, name + "." + pp)) {
hasperms = new HashSet<String>(); hasperms.add(pp);
for (String pp : perms) {
if (permissions.has(plyr, pp)) {
hasperms.add(pp);
}
} }
} }
return hasperms; return hasperms;
} }
@Override
public boolean hasOfflinePermission(String player, String perm) {
return permissions.has(defworld, player, name + "." + perm);
}
} }

View File

@ -29,4 +29,8 @@ public class OpPermissions implements PermissionProvider {
public Set<String> hasOfflinePermissions(String player, Set<String> perms) { public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
return null; return null;
} }
@Override
public boolean hasOfflinePermission(String player, String perm) {
return false;
}
} }

View File

@ -45,11 +45,19 @@ public class PEXPermissions implements PermissionProvider {
PermissionUser pu = pm.getUser(player); PermissionUser pu = pm.getUser(player);
if(pu != null) { if(pu != null) {
for (String pp : perms) { for (String pp : perms) {
if (pu.has(pp)) { if (pu.has(name + "." + pp)) {
hasperms.add(pp); hasperms.add(pp);
} }
} }
} }
return hasperms; return hasperms;
} }
@Override
public boolean hasOfflinePermission(String player, String perm) {
PermissionUser pu = pm.getUser(player);
if(pu != null) {
return pu.has(name + "." + perm);
}
return false;
}
} }

View File

@ -47,11 +47,19 @@ public class PermBukkitPermissions implements PermissionProvider {
Map<String, Boolean> prm = plugin.getPlayerInfo(player).getPermissions(); Map<String, Boolean> prm = plugin.getPlayerInfo(player).getPermissions();
HashSet<String> hasperms = new HashSet<String>(); HashSet<String> hasperms = new HashSet<String>();
for (String pp : perms) { for (String pp : perms) {
Boolean pb = prm.get(pp); Boolean pb = prm.get(name + "." + pp);
if ((pb != null) && pb.booleanValue()) { if ((pb != null) && pb.booleanValue()) {
hasperms.add(pp); hasperms.add(pp);
} }
} }
return hasperms; return hasperms;
} }
@Override
public boolean hasOfflinePermission(String player, String perm) {
Boolean b = plugin.getPlayerInfo(player).getPermissions().get(name + "." + perm);
if (b != null)
return b;
else
return false;
}
} }

View File

@ -8,4 +8,7 @@ public interface PermissionProvider {
boolean has(CommandSender sender, String permission); boolean has(CommandSender sender, String permission);
Set<String> hasOfflinePermissions(String player, Set<String> perms); Set<String> hasOfflinePermissions(String player, Set<String> perms);
boolean hasOfflinePermission(String player, String perm);
} }

View File

@ -42,14 +42,18 @@ public class bPermPermissions implements PermissionProvider {
@Override @Override
public Set<String> hasOfflinePermissions(String player, Set<String> perms) { public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
Permission[] p = ApiLayer.getPermissions(defworld, CalculableType.USER, player);
HashSet<String> hasperms = new HashSet<String>(); HashSet<String> hasperms = new HashSet<String>();
for (int i = 0; i < p.length; i++) { for (String pp : perms) {
if (p[i].isTrue() && perms.contains(p[i].name())) { if(ApiLayer.hasPermission(defworld, CalculableType.USER, player, name + "." + pp)) {
hasperms.add(p[i].name()); hasperms.add(pp);
} }
} }
return hasperms; return hasperms;
} }
@Override
public boolean hasOfflinePermission(String player, String perm) {
return ApiLayer.hasPermission(defworld, CalculableType.USER, player, name + "." + perm);
}
} }

View File

@ -317,4 +317,6 @@ permissions:
dynmap.dmap.lightinglist: dynmap.dmap.lightinglist:
description: Allows /dmap lightinglist description: Allows /dmap lightinglist
default: op default: op
dynmap.webchat:
description: Allows web chat (if login required for webchat)
default: true