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