feat: killer/survivor win conditions with title announcements, fix forcestart reset bug

This commit is contained in:
loki5512344 2026-06-03 21:15:31 +02:00
parent 78fc8bfb55
commit d59b965407
4 changed files with 95 additions and 24 deletions

View file

@ -13,18 +13,19 @@ public class LobbyPhase implements Phase {
private int countdown;
private int secondsLeft;
private boolean started;
private boolean forced;
public LobbyPhase(GameConfig config) {
this.config = config;
this.secondsLeft = config.getLobbyCountdown();
this.countdown = 0;
this.started = false;
this.forced = false;
}
@Override
public void enter(GameSession session) {
Bukkit.broadcast(Component.text("[DBD] Лобби открыто! Используйте /dbd join", NamedTextColor.GREEN));
// Teleport already-in-session players to lobby (e.g. on restart)
var lobbyManager = session.getPlugin().getLobbyManager();
for (var player : session.getPlayers().values()) {
var bukkitPlayer = player.getPlayer();
@ -36,14 +37,17 @@ public class LobbyPhase implements Phase {
@Override
public void tick(GameSession session) {
if (forced) {
started = true;
return;
}
int playerCount = session.getPlayerCount();
int minPlayers = config.getMinPlayers();
if (playerCount < minPlayers) {
secondsLeft = config.getLobbyCountdown();
countdown = 0;
started = false;
// Show waiting message in action bar to all players in lobby
sendActionBarToAll(session,
Component.text("⏳ Ожидание игроков: " + playerCount + "/" + minPlayers, NamedTextColor.YELLOW));
return;
@ -55,13 +59,11 @@ public class LobbyPhase implements Phase {
secondsLeft--;
}
// Action bar: показываем каждый тик (обновляется плавно)
String bar = buildCountdownBar(secondsLeft, config.getLobbyCountdown());
sendActionBarToAll(session,
Component.text("▶ Старт через: " + secondsLeft + "с " + bar +
" (" + playerCount + "/" + minPlayers + ")", NamedTextColor.GREEN));
// Chat-announce на ключевых отметках
if (countdown == 0 && (secondsLeft <= 5 || secondsLeft == 10 || secondsLeft == 30)) {
Bukkit.broadcast(Component.text(
"[DBD] До начала: " + secondsLeft + " сек.", NamedTextColor.YELLOW));
@ -89,7 +91,6 @@ public class LobbyPhase implements Phase {
@Override
public void exit(GameSession session) {
// Clear action bar for all
for (BasePlayer bp : session.getPlayers().values()) {
Player p = bp.getPlayer();
if (p != null && p.isOnline()) p.sendActionBar(Component.empty());
@ -113,11 +114,10 @@ public class LobbyPhase implements Phase {
}
public void forceStart() {
secondsLeft = 0;
started = true;
this.forced = true;
}
public int getSecondsLeft() {
return secondsLeft;
}
}
}