SteamWar/MissileWars
Archiviert
13
0

Merge pull request 'Add PlayTime to FightScoreboard' (#31) from PlayTime into master

Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
YoyoNow 2021-01-30 14:54:57 +01:00
Commit 6dd085c425
2 geänderte Dateien mit 21 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -24,6 +24,8 @@ import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;
/**
@ -35,6 +37,9 @@ class FightScoreboard {
private static final Scoreboard scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
private static final Objective objective;
private static final SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
private static long startTime = 0;
static{
if(scoreboard.getObjective("AAA") == null)
@ -48,8 +53,16 @@ class FightScoreboard {
objective.unregister();
scoreboard.registerNewObjective("AAA", "BBB", "MissleWars");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName("§eSpieler");
objective.setDisplayName("§eMissileWars");
objective.getScore("§eSpielzeit").setScore(5);
if (startTime == 0) {
objective.getScore("§7??:??:??").setScore(4);
} else {
objective.getScore("§7" + format.format(new Date(System.currentTimeMillis() - startTime))).setScore(4);
}
objective.getScore("").setScore(3);
objective.getScore("§eSpieler").setScore(2);
MissileWars.getBlueTeam().teamScoreboard(objective);
MissileWars.getRedTeam().teamScoreboard(objective);
@ -61,4 +74,8 @@ class FightScoreboard {
return scoreboard;
}
static void startTime() {
startTime = System.currentTimeMillis();
}
}

Datei anzeigen

@ -38,6 +38,9 @@ public abstract class StateDependent {
public abstract void disable();
static void setupState(FightState state){
if (state == FightState.FIGHTING) {
FightScoreboard.startTime();
}
for(StateDependent listener : listeners){
if(listener.running && !listener.active.contains(state)){
listener.disable();