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;
}
@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

View File

@ -40,7 +40,7 @@ public class BukkitPermissions implements PermissionProvider {
if (p != null) {
hasperms = new HashSet<String>();
for(String perm : perms) {
if (p.hasPermission(perm)) {
if (p.hasPermission(name + "." + perm)) {
hasperms.add(perm);
}
}
@ -48,4 +48,12 @@ public class BukkitPermissions implements PermissionProvider {
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;
PermissionHandler permissions;
Plugin plugin;
String defworld;
public static NijikokunPermissions create(Server server, String name) {
Plugin permissionsPlugin = server.getPluginManager().getPlugin("Permissions");
@ -31,6 +32,7 @@ public class NijikokunPermissions implements PermissionProvider {
public NijikokunPermissions(Plugin permissionsPlugin, String name) {
this.name = name;
plugin = permissionsPlugin;
defworld = Bukkit.getServer().getWorlds().get(0).getName();
}
@Override
@ -45,16 +47,18 @@ public class NijikokunPermissions implements PermissionProvider {
@Override
public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
HashSet<String> hasperms = null;
Player plyr = Bukkit.getPlayerExact(player);
if(plyr != null) {
hasperms = new HashSet<String>();
for (String pp : perms) {
if (permissions.has(plyr, pp)) {
hasperms.add(pp);
}
HashSet<String> hasperms = new HashSet<String>();
for (String pp : perms) {
if (permissions.has(defworld, player, name + "." + pp)) {
hasperms.add(pp);
}
}
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) {
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);
if(pu != null) {
for (String pp : perms) {
if (pu.has(pp)) {
if (pu.has(name + "." + pp)) {
hasperms.add(pp);
}
}
}
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();
HashSet<String> hasperms = new HashSet<String>();
for (String pp : perms) {
Boolean pb = prm.get(pp);
Boolean pb = prm.get(name + "." + pp);
if ((pb != null) && pb.booleanValue()) {
hasperms.add(pp);
}
}
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);
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
public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
Permission[] p = ApiLayer.getPermissions(defworld, CalculableType.USER, player);
HashSet<String> hasperms = new HashSet<String>();
for (int i = 0; i < p.length; i++) {
if (p[i].isTrue() && perms.contains(p[i].name())) {
hasperms.add(p[i].name());
for (String pp : perms) {
if(ApiLayer.hasPermission(defworld, CalculableType.USER, player, name + "." + pp)) {
hasperms.add(pp);
}
}
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:
description: Allows /dmap lightinglist
default: op
dynmap.webchat:
description: Allows web chat (if login required for webchat)
default: true