From d95d5f21d1951eaf9448c29eedf1de1384f02a1e Mon Sep 17 00:00:00 2001 From: Tyler Blair Date: Wed, 21 Mar 2012 18:51:48 -0300 Subject: [PATCH] Fix a possible NPE case -- getPlayerInfo () in PBukkit can return null when the user is not defined. --- .../plugins/Permission_PermissionsBukkit.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/net/milkbowl/vault/permission/plugins/Permission_PermissionsBukkit.java b/src/net/milkbowl/vault/permission/plugins/Permission_PermissionsBukkit.java index 9c57793..ca53ca1 100644 --- a/src/net/milkbowl/vault/permission/plugins/Permission_PermissionsBukkit.java +++ b/src/net/milkbowl/vault/permission/plugins/Permission_PermissionsBukkit.java @@ -30,6 +30,7 @@ import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.plugin.Plugin; import com.platymuus.bukkit.permissions.Group; +import com.platymuus.bukkit.permissions.PermissionInfo; import com.platymuus.bukkit.permissions.PermissionsPlugin; public class Permission_PermissionsBukkit extends Permission { @@ -189,7 +190,8 @@ public class Permission_PermissionsBukkit extends Permission { @Override public String[] getPlayerGroups(String world, String player) { List groupList = new ArrayList(); - if (world != null && perms.getPlayerInfo(player) != null) { + PermissionInfo info = perms.getPlayerInfo(player); + if (world != null && info != null) { for (Group group : perms.getPlayerInfo(player).getGroups()) { if (group.getInfo().getWorlds().contains(world)) { groupList.add(group.getName()); @@ -197,8 +199,10 @@ public class Permission_PermissionsBukkit extends Permission { } return groupList.toArray(new String[0]); } - for (Group group : perms.getPlayerInfo(player).getGroups()) { - groupList.add(group.getName()); + if (info != null) { + for (Group group : info.getGroups()) { + groupList.add(group.getName()); + } } return groupList.toArray(new String[0]); }