Compare commits

..

No commits in common. "e9e7c1cc806eee0158257b21cefc5ad5abf5d770" and "3906bd747b221e9c30ed3a4b5cb3d25d895b8004" have entirely different histories.

4 changed files with 6 additions and 11 deletions

View File

@ -20,7 +20,7 @@ public class StartRound extends SubCommand {
@Override @Override
public boolean onCommand(CommandSender commandSender, String[] args) { public boolean onCommand(CommandSender commandSender, String[] args) {
ROUND_STATE roundState = roundService.getRoundState(); ROUND_STATE roundState = roundService.getRoundState();
if (roundState == ROUND_STATE.PLAYER_REGISTRATION || roundState == ROUND_STATE.ENDED) { if (roundState == ROUND_STATE.PLAYER_REGISTRATION) {
round.startRound(); round.startRound();
} else { } else {
commandSender.sendRichMessage(Messages.START_ROUND.CAN_NOT_START_ROUND, commandSender.sendRichMessage(Messages.START_ROUND.CAN_NOT_START_ROUND,

View File

@ -131,18 +131,13 @@ public class PlayerService implements RoundListener {
if (optionalPlayerState.isPresent()) { if (optionalPlayerState.isPresent()) {
PLAYER_STATE playerState = optionalPlayerState.get(); PLAYER_STATE playerState = optionalPlayerState.get();
return Optional.of(switch (playerState) { return Optional.of(switch (playerState) {
case DISCONNECTED, SPECTATING -> { case DISCONNECTED, SPECTATING -> PLAYER_STATE.SPECTATING;
if (roundState.equals(ROUND_STATE.ENDED)) {
yield PLAYER_STATE.REGISTERED;
}
yield PLAYER_STATE.SPECTATING;
}
case REGISTERED -> PLAYER_STATE.REGISTERED; case REGISTERED -> PLAYER_STATE.REGISTERED;
}); });
} }
return switch (roundState) { return switch (roundState) {
case PLAYER_REGISTRATION, COUNTDOWN, ENDED -> Optional.of(PLAYER_STATE.REGISTERED); case PLAYER_REGISTRATION, COUNTDOWN -> Optional.of(PLAYER_STATE.REGISTERED);
case KILL_PHASE, FINALE, SAFE_PHASE -> Optional.of(PLAYER_STATE.SPECTATING); case KILL_PHASE, FINALE, ENDED, SAFE_PHASE -> Optional.of(PLAYER_STATE.SPECTATING);
}; };
} }
} }

View File

@ -77,7 +77,7 @@ public class Round {
} }
public void startRound() { public void startRound() {
if (!roundState.equals(ROUND_STATE.PLAYER_REGISTRATION) && !roundState.equals(ROUND_STATE.ENDED)) { if (!roundState.equals(ROUND_STATE.PLAYER_REGISTRATION)) {
throw new IllegalStateException("Round can not be started before player registration."); throw new IllegalStateException("Round can not be started before player registration.");
} }
roundState = ROUND_STATE.COUNTDOWN; roundState = ROUND_STATE.COUNTDOWN;

View File

@ -137,7 +137,7 @@ public class RoundService implements RoundListener {
WorldBorderUtil.resetBorder(); WorldBorderUtil.resetBorder();
} }
if (roundState.equals(ROUND_STATE.FINALE)) { if (roundState.equals(ROUND_STATE.FINALE)) {
WorldBorderUtil.setSize(Config.ROUND.FINALE_BORDER_SIZE, 1); WorldBorderUtil.setSize(Config.ROUND.FINALE_BORDER_SIZE);
} }
if (!roundState.equals(ROUND_STATE.ENDED) && !roundState.equals(ROUND_STATE.PLAYER_REGISTRATION)) { 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())));