toLower all group/permission strings for PermBukkit implementation.

This commit is contained in:
Sleaker 2012-04-12 21:20:49 -07:00
parent 550f774d3d
commit 7fcc556774

View File

@ -100,14 +100,16 @@ public class Permission_PermissionsBukkit extends Permission {
@Override
public boolean playerHas(String world, String player, String permission) {
if (plugin.getServer().getPlayer(player) != null)
return plugin.getServer().getPlayer(player).hasPermission(permission);
else
if (Bukkit.getPlayer(player) != null) {
return Bukkit.getPlayer(player).hasPermission(permission);
} else {
return false;
}
}
@Override
public boolean playerAdd(String world, String player, String permission) {
permission = permission.toLowerCase();
if (world != null) {
permission = world + ":" + permission;
}
@ -116,6 +118,7 @@ public class Permission_PermissionsBukkit extends Permission {
@Override
public boolean playerRemove(String world, String player, String permission) {
permission = permission.toLowerCase();
if (world != null) {
permission = world + ":" + permission;
}
@ -126,20 +129,26 @@ public class Permission_PermissionsBukkit extends Permission {
@Override
public boolean groupHas(String world, String group, String permission) {
group = group.toLowerCase();
permission = permission.toLowerCase();
if (world != null && !world.isEmpty()) {
return perms.getGroup(group).getInfo().getWorldPermissions(world).get(permission) == null ? false : perms.getGroup(group).getInfo().getWorldPermissions(world).get(permission);
}
if (perms.getGroup(group) == null)
if (perms.getGroup(group) == null) {
return false;
else if (perms.getGroup(group).getInfo() == null)
} else if (perms.getGroup(group).getInfo() == null) {
return false;
else if (perms.getGroup(group).getInfo().getPermissions() == null)
} else if (perms.getGroup(group).getInfo().getPermissions() == null) {
return false;
}
return perms.getGroup(group).getInfo().getPermissions().get(permission);
}
@Override
public boolean groupAdd(String world, String group, String permission) {
group = group.toLowerCase();
permission = permission.toLowerCase();
if (world != null) {
permission = world + ":" + permission;
}
@ -148,6 +157,8 @@ public class Permission_PermissionsBukkit extends Permission {
@Override
public boolean groupRemove(String world, String group, String permission) {
group = group.toLowerCase();
permission = permission.toLowerCase();
if (world != null) {
permission = world + ":" + permission;
}
@ -156,6 +167,7 @@ public class Permission_PermissionsBukkit extends Permission {
@Override
public boolean playerInGroup(String world, String player, String group) {
group = group.toLowerCase();
if (world != null) {
for (Group g : perms.getPlayerInfo(player).getGroups()) {
if (g.getName().equals(group)) {
@ -173,6 +185,7 @@ public class Permission_PermissionsBukkit extends Permission {
@Override
public boolean playerAddGroup(String world, String player, String group) {
group = group.toLowerCase();
if (world != null) {
return false;
}
@ -181,6 +194,7 @@ public class Permission_PermissionsBukkit extends Permission {
@Override
public boolean playerRemoveGroup(String world, String player, String group) {
group = group.toLowerCase();
if (world != null) {
return false;
}
@ -209,9 +223,9 @@ public class Permission_PermissionsBukkit extends Permission {
@Override
public String getPrimaryGroup(String world, String player) {
if (perms.getPlayerInfo(player) == null)
if (perms.getPlayerInfo(player) == null) {
return null;
else if (perms.getPlayerInfo(player).getGroups() != null && !perms.getPlayerInfo(player).getGroups().isEmpty() ) {
} else if (perms.getPlayerInfo(player).getGroups() != null && !perms.getPlayerInfo(player).getGroups().isEmpty() ) {
return perms.getPlayerInfo(player).getGroups().get(0).getName();
}
return null;