Merge pull request 'Continouus updating scoreboard' (#248) from continouusScoreboard into master
Reviewed-on: #248 Reviewed-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Commit
d2674e2140
@ -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;
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren