SteamWar/FightSystem
Archiviert
13
1

Scoreboard Improvement

Dieser Commit ist enthalten in:
Chaoscaot 2020-10-11 10:22:07 +02:00
Ursprung 1acd3878f5
Commit e575d7a493

Datei anzeigen

@ -28,31 +28,33 @@ import de.steamwar.fightsystem.winconditions.*;
import de.steamwar.scoreboard.SWScoreboard;
import de.steamwar.scoreboard.ScoreboardCallback;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scoreboard.Scoreboard;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Set;
public class FightScoreboard {
private FightScoreboard(){}
public class FightScoreboard implements Listener {
private static final Set<FightState> fullScoreboard = EnumSet.of(FightState.RUNNING, FightState.SPECTATE);
private static int index = 0;
private static ScoreBoardObjective objective;
public static void init(){
Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), () -> {
Bukkit.getOnlinePlayers().forEach(player -> SWScoreboard.removeScoreboard(player));
Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), () -> nextIndexDisplay(), 0, 200);
}
FightTeam fightTeam = getIndexDisplay();
ScoreBoardObjective objective;
if(fightTeam != null)
objective = teamScoreboard(fightTeam);
else
objective = generalScoreboard();
public static Scoreboard getScoreboard() {
return Bukkit.getScoreboardManager().getMainScoreboard();
}
Bukkit.getOnlinePlayers().forEach(player -> SWScoreboard.createScoreboard(player, new ScoreboardCallback() {
@EventHandler()
public void onPlayerJoin(PlayerJoinEvent event) {
SWScoreboard.createScoreboard(event.getPlayer(), new ScoreboardCallback() {
@Override
public HashMap<String, Integer> getData() {
return objective.getScores();
@ -62,12 +64,12 @@ public class FightScoreboard {
public String getTitle() {
return objective.getTitle();
}
}));
}, 0, 200);
});
}
public static Scoreboard getScoreboard() {
return Bukkit.getScoreboardManager().getMainScoreboard();
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
SWScoreboard.removeScoreboard(event.getPlayer());
}
private static ScoreBoardObjective teamScoreboard(FightTeam fightTeam){
@ -123,6 +125,11 @@ public class FightScoreboard {
if(index > 2)
return;
index = 0;
FightTeam team = getIndexDisplay();
if(team != null)
objective = teamScoreboard(team);
else
objective = generalScoreboard();
}
private static class ScoreBoardObjective {