Don't start game for group if other groups can't start
This commit is contained in:
parent
a767254645
commit
724d0a5ed9
|
@ -300,14 +300,19 @@ public class DGame implements Game {
|
|||
public boolean start() {
|
||||
getWorld().setWeather(getRules());
|
||||
|
||||
int i = 0;
|
||||
for (PlayerGroup group : groups) {
|
||||
if (group == null) {
|
||||
continue;
|
||||
}
|
||||
if (!((DGroup) group).startGame(this, i++)) {
|
||||
if (!((DGroup) group).checkStartGame(this)) {
|
||||
plugin.log("Could not start game for group " + group);
|
||||
return false; // TODO: State of groups that are OK has already been changed
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int i = 0;
|
||||
for (PlayerGroup group : groups) {
|
||||
if (group != null) {
|
||||
((DGroup) group).startGame(this, i++);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -556,11 +556,7 @@ public class DGroup implements PlayerGroup {
|
|||
plugin.getGroupAdapters().forEach(a -> a.deleteCorrespondingGroup(this));
|
||||
}
|
||||
|
||||
public boolean startGame(Game game, int index) {
|
||||
if (color == null) {
|
||||
color = plugin.getMainConfig().getGroupColorPriority(index);
|
||||
}
|
||||
|
||||
public boolean checkStartGame(Game game) {
|
||||
for (Player player : getMembers().getOnlinePlayers()) {
|
||||
GamePlayer gamePlayer = plugin.getPlayerCache().getGamePlayer(player);
|
||||
if (gamePlayer == null) {
|
||||
|
@ -574,10 +570,13 @@ public class DGroup implements PlayerGroup {
|
|||
|
||||
GroupStartFloorEvent event = new GroupStartFloorEvent(this, getGameWorld());
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
return !event.isCancelled();
|
||||
}
|
||||
|
||||
public void startGame(Game game, int index) {
|
||||
if (color == null) {
|
||||
color = plugin.getMainConfig().getGroupColorPriority(index);
|
||||
}
|
||||
plugin.getGlobalProtectionCache().updateGroupSigns(this);
|
||||
|
||||
GameRuleContainer rules = getDungeon().getRules();
|
||||
|
@ -595,8 +594,6 @@ public class DGroup implements PlayerGroup {
|
|||
}
|
||||
((DGamePlayer) player).startGame();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void winGame() {
|
||||
|
|
Loading…
Reference in New Issue