public List<MUCOccupant> getOccupantsByNickname(String nickname) throws UserNotFoundException {
        if (nickname == null) {
            throw new UserNotFoundException();
        }

        final List<MUCOccupant> filteredOccupants = occupants.stream()
            .filter(occupant -> occupant.getNickname().equalsIgnoreCase(nickname))
            .collect(Collectors.toList());

        if (filteredOccupants.isEmpty()) {
            throw new UserNotFoundException("Unable to find occupant with nickname '" + nickname + "' in room '" + name + "'");
        }
        return filteredOccupants;
    }
Obtain the roles of a given user by nickname. A user can be connected to a room more than once.

@param nickname The nickname of the user you'd like to obtain (cannot be {@code null})
@return The user's role in the room
@throws UserNotFoundException If there is no user with the given nickname
xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoom.java