SteamWar/FightSystem
Archiviert
13
1

Continouus updating scoreboard #248

Manuell gemergt
Lixfel hat 1 Commits von continouusScoreboard nach master 2021-04-03 15:24:44 +02:00 zusammengeführt
Nur Änderungen aus Commit d8aefba51b werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -41,11 +41,12 @@ import org.bukkit.scoreboard.Scoreboard;
import java.util.*;
public class FightScoreboard implements Listener {
public class FightScoreboard implements Listener, ScoreboardCallback {
private static final Set<FightState> fullScoreboard = EnumSet.of(FightState.RUNNING, FightState.SPECTATE);
private int index = 0;
private String title = "";
private final HashMap<String, Integer> scores = new HashMap<>();
@ -55,22 +56,12 @@ public class FightScoreboard implements Listener {
public FightScoreboard(){
new StateDependentListener(ArenaMode.All, FightState.All, this);
new StateDependentTask(ArenaMode.All, FightState.All, this::nextIndexDisplay, 0, 200);
new StateDependentTask(ArenaMode.All, FightState.All, this::updateScoreboard, 0, 20);
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
SWScoreboard.createScoreboard(event.getPlayer(), new ScoreboardCallback() {
@Override
public HashMap<String, Integer> getData() {
return scores;
}
@Override
public String getTitle() {
return title;
}
});
SWScoreboard.createScoreboard(event.getPlayer(), this);
}
@EventHandler
@ -114,20 +105,17 @@ public class FightScoreboard implements Listener {
}
}
private void nextIndexDisplay() {
index++;
if(index > 2)
index = 0;
FightTeam team = null;
if(index == 1)
team = Fight.getRedTeam();
if(index == 2)
team = Fight.getBlueTeam();
scores.clear();
if(team != null)
teamScoreboard(team);
else
private void updateScoreboard() {
switch((index++ / 10) % 3){
case 0:
generalScoreboard();
break;
case 1:
teamScoreboard(Fight.getBlueTeam());
break;
case 2:
teamScoreboard(Fight.getRedTeam());
}
}
private void setTitle(String t) {
@ -139,4 +127,14 @@ public class FightScoreboard implements Listener {
scores.put(string, i);
RecordSystem.scoreboardData(string, i);
}
@Override
public String getTitle() {
return title;
}
@Override
public HashMap<String, Integer> getData() {
return scores;
}
}