Fix groups using two group signs

This commit is contained in:
Daniel Saukel 2020-10-30 17:10:31 +01:00
parent a603441bbe
commit 51a120bb67
2 changed files with 14 additions and 1 deletions

View File

@ -136,11 +136,12 @@ public class GroupSign extends JoinSign {
DGroup playerGroup = (DGroup) plugin.getPlayerGroup(player);
if (playerGroup != null) {
if (playerGroup.getLeader().equals(player)) {
if (group != null || maxElements < playerGroup.getMembers().size()) {
if (playerGroup.getGroupSign() != null || group != null || maxElements < playerGroup.getMembers().size()) {
MessageUtil.sendMessage(player, DMessage.ERROR_LEAVE_GROUP.getMessage());
return;
} else {
group = playerGroup;
group.setGroupSign(this);
group.setDungeon(dungeon);
update();
return;
@ -165,8 +166,10 @@ public class GroupSign extends JoinSign {
if (groupName != null) {
group = new DGroup(plugin, groupName, player, dungeon);
group.setGroupSign(this);
} else {
group = new DGroup(plugin, player, dungeon);
group.setGroupSign(this);
}
update();

View File

@ -43,6 +43,7 @@ import de.erethon.dungeonsxl.config.DMessage;
import de.erethon.dungeonsxl.dungeon.DDungeon;
import de.erethon.dungeonsxl.dungeon.DGame;
import de.erethon.dungeonsxl.dungeon.DungeonConfig;
import de.erethon.dungeonsxl.global.GroupSign;
import de.erethon.dungeonsxl.world.DGameWorld;
import de.erethon.dungeonsxl.world.DResourceWorld;
import java.util.ArrayList;
@ -69,6 +70,7 @@ public class DGroup implements PlayerGroup {
private int id;
private String name;
private GroupSign groupSign;
private Player captain;
private PlayerCollection players = new PlayerCollection();
private PlayerCollection invitedPlayers = new PlayerCollection();
@ -177,6 +179,14 @@ public class DGroup implements PlayerGroup {
this.name = name;
}
public GroupSign getGroupSign() {
return groupSign;
}
public void setGroupSign(GroupSign groupSign) {
this.groupSign = groupSign;
}
@Override
public Player getLeader() {
return captain;