Add PlayTime to FightScoreboard #31
@ -24,6 +24,8 @@ import org.bukkit.scoreboard.DisplaySlot;
|
|||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,6 +37,9 @@ class FightScoreboard {
|
|||||||
|
|
||||||
private static final Scoreboard scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
|
private static final Scoreboard scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
|
||||||
private static final Objective objective;
|
private static final Objective objective;
|
||||||
|
private static final SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
|
||||||
|
|
||||||
|
private static long startTime = 0;
|
||||||
|
|
||||||
static{
|
static{
|
||||||
if(scoreboard.getObjective("AAA") == null)
|
if(scoreboard.getObjective("AAA") == null)
|
||||||
@ -48,8 +53,16 @@ class FightScoreboard {
|
|||||||
objective.unregister();
|
objective.unregister();
|
||||||
scoreboard.registerNewObjective("AAA", "BBB", "MissleWars");
|
scoreboard.registerNewObjective("AAA", "BBB", "MissleWars");
|
||||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
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.getBlueTeam().teamScoreboard(objective);
|
||||||
MissileWars.getRedTeam().teamScoreboard(objective);
|
MissileWars.getRedTeam().teamScoreboard(objective);
|
||||||
|
|
||||||
@ -61,4 +74,8 @@ class FightScoreboard {
|
|||||||
return scoreboard;
|
return scoreboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void startTime() {
|
||||||
|
startTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,9 @@ public abstract class StateDependent {
|
|||||||
public abstract void disable();
|
public abstract void disable();
|
||||||
|
|
||||||
static void setupState(FightState state){
|
static void setupState(FightState state){
|
||||||
|
if (state == FightState.FIGHTING) {
|
||||||
|
FightScoreboard.startTime();
|
||||||
|
}
|
||||||
for(StateDependent listener : listeners){
|
for(StateDependent listener : listeners){
|
||||||
if(listener.running && !listener.active.contains(state)){
|
if(listener.running && !listener.active.contains(state)){
|
||||||
listener.disable();
|
listener.disable();
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren