player.sendPrivateText(targetPlayer.getName() + " has a closed mind, and is seeking solitude from all but close friends");
return;
}
// check if the target player is already in a group
Group group = SingletonRepository.getGroupManager().getGroup(targetPlayer.getName());
if (group != null) {
player.sendPrivateText(NotificationType.ERROR, targetPlayer.getName() + " is already in a group.");
return;
}
// get group, create it, if it does not exist
SingletonRepository.getGroupManager().createGroup(player.getName());
group = SingletonRepository.getGroupManager().getGroup(player.getName());
// check leader
if (!group.hasLeader(player.getName())) {
player.sendPrivateText(NotificationType.ERROR, "Only the group leader may invite people.");
return;
}
// check if there is space left in the group
if (group.isFull()) {
player.sendPrivateText(NotificationType.ERROR, "Your group is already full.");
return;
}
// invite
group.invite(player, targetPlayer);
player.sendPrivateText("You have invited " + targetPlayer.getName() + " to join your group.");
}