If the group leader leaves, the group is notified of who becomes the leader #74

This commit is contained in:
Ziggy
2020-07-03 20:57:10 +02:00
parent 07e0936114
commit 43bc02ca9e
2 changed files with 10 additions and 3 deletions

View File

@@ -100,9 +100,6 @@ public class GroupObject extends SWGObject {
}
public void removeMember(CreatureObject creature) {
if (leader.equals(creature) && size() >= 2) {
setLeader(groupMembers.get(1));
}
removeGroupMembers(creature);
calculateLevel();
}

View File

@@ -417,6 +417,16 @@ public class GroupService extends Service {
sendSystemMessage(creature.getOwner(), "removed");
group.removeMember(creature);
updateChatRoom(creature.getOwner(), group, UpdateType.LEAVE);
// If the leader has left, promote another group member to leader and notify the group of this
if (creature.getObjectId() == group.getLeaderId()) {
CreatureObject newLeader = group.getGroupMemberObjects().iterator().next(); // Pick a new leader
group.setLeader(newLeader);
sendGroupSystemMessage(group, "new_leader", "TU", newLeader.getObjectName());
}
}
private void updateChatRoom(Player player, GroupObject group, UpdateType updateType) {