Archiviert
13
0

Add Game Countdown
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Chaoscaot 2023-08-19 18:31:39 +02:00
Ursprung 98147fe721
Commit 2184434d95
Signiert von: Chaoscaot
GPG-Schlüssel-ID: BDF8FADD7D5EDB7A
4 geänderte Dateien mit 66 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -30,5 +30,6 @@ SERVER_RESET=
KEY_NAME=§eKey KEY_NAME=§eKey
KEY_FOUND=§a{0} §7found a key§8! KEY_FOUND=§a{0} §7found a key§8!
GAME_TIE=§aThe game ended in a tie§8! GAME_TIE=§aThe game ended in a tie§8!
GAME_TIME=§a{0}:{1}
COMMAND_START=§aThe game will start soon§8! COMMAND_START=§aThe game will start soon§8!

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.towerrun;
import de.steamwar.message.Message; import de.steamwar.message.Message;
import de.steamwar.towerrun.commands.StartCommand; import de.steamwar.towerrun.commands.StartCommand;
import de.steamwar.towerrun.countdowns.EndCountdown; import de.steamwar.towerrun.countdowns.EndCountdown;
import de.steamwar.towerrun.countdowns.GameCountdown;
import de.steamwar.towerrun.countdowns.LobbyCountdown; import de.steamwar.towerrun.countdowns.LobbyCountdown;
import de.steamwar.towerrun.listener.GlobalListener; import de.steamwar.towerrun.listener.GlobalListener;
import de.steamwar.towerrun.listener.IngameListener; import de.steamwar.towerrun.listener.IngameListener;
@ -62,5 +63,6 @@ public class TowerRun extends JavaPlugin {
final LobbyCountdown lobbyCountdown = new LobbyCountdown(); final LobbyCountdown lobbyCountdown = new LobbyCountdown();
new EndCountdown(lobbyCountdown); new EndCountdown(lobbyCountdown);
new StartCommand(lobbyCountdown); new StartCommand(lobbyCountdown);
new GameCountdown();
} }
} }

Datei anzeigen

@ -36,6 +36,7 @@ public class Config {
public static final int MIN_PLAYERS; public static final int MIN_PLAYERS;
public static final int LOBBY_TIMER; public static final int LOBBY_TIMER;
public static final Set<Material> DESTROYABLE_BLOCKS; public static final Set<Material> DESTROYABLE_BLOCKS;
public static final int GAME_TIMER;
static { static {
File configFile = new File(TowerRun.getInstance().getDataFolder(), "config.yml"); File configFile = new File(TowerRun.getInstance().getDataFolder(), "config.yml");
@ -48,6 +49,7 @@ public class Config {
MIN_PLAYERS = config.getInt("minPlayers"); MIN_PLAYERS = config.getInt("minPlayers");
LOBBY_TIMER = config.getInt("lobbyTimer"); LOBBY_TIMER = config.getInt("lobbyTimer");
GAME_TIMER = config.getInt("gameTimer", 20 * 60);
DESTROYABLE_BLOCKS = EnumSet.copyOf(config.getStringList("destroyable").stream().map(Material::valueOf).collect(Collectors.toSet())); DESTROYABLE_BLOCKS = EnumSet.copyOf(config.getStringList("destroyable").stream().map(Material::valueOf).collect(Collectors.toSet()));
} }

Datei anzeigen

@ -0,0 +1,61 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.towerrun.countdowns;
import de.steamwar.towerrun.TowerRun;
import de.steamwar.towerrun.config.Config;
import de.steamwar.towerrun.game.TowerRunGame;
import de.steamwar.towerrun.state.GameStates;
import java.util.EnumSet;
public class GameCountdown extends Countdown {
public GameCountdown() {
super(EnumSet.of(GameStates.INGAME));
}
@Override
int defaultTime() {
return Config.GAME_TIMER;
}
@Override
void timerEnd() {
if (TowerRunGame.PLAYERS_ESCAPED.isEmpty()) {
TowerRunGame.tie();
} else {
TowerRunGame.win(TowerRunGame.PLAYERS_ESCAPED.get(TowerRunGame.PLAYERS_ESCAPED.size() - 1));
}
}
@Override
boolean timerShouldCancel() {
return false;
}
@Override
void run() {
int timeMinutes = Math.floorDiv(time, 60);
int timeSeconds = time % 60;
TowerRun.getMessage().broadcastActionbar("GAME_TIME", timeMinutes, timeSeconds);
}
}