Handle empty stage list in Round and adjust state transitions in RoundService
This commit is contained in:
parent
62c9661c82
commit
a137ef4cc6
|
|
@ -119,6 +119,12 @@ public class Round {
|
||||||
|
|
||||||
private void scheduleNextStage(int index) {
|
private void scheduleNextStage(int index) {
|
||||||
List<GameStage> gameStageList = Config.ROUND.STAGES;
|
List<GameStage> gameStageList = Config.ROUND.STAGES;
|
||||||
|
if (gameStageList.isEmpty()) {
|
||||||
|
nextStage(); // Transition to SAFE_PHASE
|
||||||
|
nextStage(); // Transition to KILL_PHASE
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (gameStageList.size() <= index) {
|
if (gameStageList.size() <= index) {
|
||||||
nextStage();
|
nextStage();
|
||||||
return;
|
return;
|
||||||
|
|
@ -128,10 +134,15 @@ public class Round {
|
||||||
Duration duration = gameStage.getDuration();
|
Duration duration = gameStage.getDuration();
|
||||||
|
|
||||||
startCountdown(duration, () -> {
|
startCountdown(duration, () -> {
|
||||||
GameStageHandler.handleStageChange(gameStage.getWorldBorderSize());
|
|
||||||
if (gameStageList.size() <= index + 1) {
|
if (gameStageList.size() <= index + 1) {
|
||||||
|
nextStage();
|
||||||
|
GameStageHandler.handleStageChange(gameStage.getWorldBorderSize());
|
||||||
startCountdown(Duration.ofMinutes(5), this::nextStage);
|
startCountdown(Duration.ofMinutes(5), this::nextStage);
|
||||||
} else {
|
} else {
|
||||||
|
if (index == 0 && roundState.equals(ROUND_STATE.SAFE_PHASE)) {
|
||||||
|
nextStage();
|
||||||
|
}
|
||||||
|
GameStageHandler.handleStageChange(gameStage.getWorldBorderSize());
|
||||||
scheduleNextStage(index + 1);
|
scheduleNextStage(index + 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ public class RoundService implements RoundListener {
|
||||||
if (roundState.equals(ROUND_STATE.FINALE)) {
|
if (roundState.equals(ROUND_STATE.FINALE)) {
|
||||||
WorldBorderUtil.setSize(60);
|
WorldBorderUtil.setSize(60);
|
||||||
}
|
}
|
||||||
if (!roundState.equals(ROUND_STATE.ENDED)) {
|
if (!roundState.equals(ROUND_STATE.ENDED) && !roundState.equals(ROUND_STATE.PLAYER_REGISTRATION)) {
|
||||||
Bukkit.broadcast(MiniMessage.miniMessage().deserialize(Messages.GAME.NEXT_STATE, Placeholder.parsed("round", roundState.getHumanReadableName())));
|
Bukkit.broadcast(MiniMessage.miniMessage().deserialize(Messages.GAME.NEXT_STATE, Placeholder.parsed("round", roundState.getHumanReadableName())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user