/** * Check whether a player belongs to a group * * @param playerName * @param group * @param world * @return */ public boolean inGroup(String playerName, World world, String group) { try { if (pex != null) { PermissionUser user = PermissionsEx.getUser(playerName); if (user != null) { return user.inGroup(group); } return false; } else if (pbukkit != null) { List<Group> groups = pbukkit.getGroups(playerName); for (Group g : groups) { if (g.getName().equalsIgnoreCase(group)) { return true; } } return false; } else if (permission != null) { return permission.playerInGroup(world, playerName, group); } else if (handler != null) { if (handler.getGroup(world.getName(), playerName).equalsIgnoreCase(group)) { return true; } return false; } } catch (Exception ex) { // no group support } return false; }
@Override public boolean inGroup(final Player base, final String group) { final List<Group> groups = getPBGroups(base); for (Group group1 : groups) { if (group1.getName().equalsIgnoreCase(group)) { return true; } } return false; }
@Override public List<String> getGroups(final Player base) { final List<Group> groups = getPBGroups(base); if (groups.size() == 1) { return Collections.singletonList(groups.get(0).getName()); } final List<String> groupNames = new ArrayList<String>(groups.size()); for (Group group : groups) { groupNames.add(group.getName()); } return groupNames; }
public String getPlayerGroup(String player, String world) { PermissionManager pmanager = Residence.getPermissionManager(); List<Group> groups = newperms.getGroups(player); for (Group group : groups) { String name = group.getName().toLowerCase(); if (pmanager.hasGroup(name)) { return name; } } if (groups.size() > 0) { return groups.get(0).getName().toLowerCase(); } return null; }
/** * Get a player's groups * * @param worldName * @param playerName * @return */ public List<String> getGroups(String worldName, String playerName) { List<String> groups = new LinkedList<String>(); try { if (pex != null) { PermissionUser user = PermissionsEx.getUser(playerName); if (user != null) { PermissionGroup[] pexGroups = user.getGroups(); for (PermissionGroup g : pexGroups) { groups.add(g.getName()); } } } else if (pbukkit != null) { List<Group> gs = pbukkit.getGroups(playerName); for (Group group : gs) { groups.add(group.getName().toLowerCase()); } return groups; } else if (permission != null) { World world = plugin.getServer().getWorld(worldName); if (world != null) { String[] groupList = permission.getPlayerGroups(world, playerName); for (String g : groupList) { groups.add(g); } } } else if (handler != null) { @SuppressWarnings("deprecation") String group = handler.getGroup(worldName, playerName); if (group != null) { groups.add(group.toLowerCase()); } } } catch (Exception ex) { // no group support } return groups; }