SteamWar/FightSystem
Archiviert
13
1

Changed Fight Scoreboard to SWScoreboard #194

Manuell gemergt
Lixfel hat 7 Commits von scoreboard-reimplement nach master 2020-11-17 09:29:41 +01:00 zusammengeführt
Nur Änderungen aus Commit 2bc9bded5c werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -45,7 +45,7 @@ public class FightScoreboard implements Listener {
private static ScoreBoardObjective objective; private static ScoreBoardObjective objective;
public static void init(){ public static void init(){
Review

Fände es besser, direkt titel und scores zu speichern (siehe unten)

Fände es besser, direkt titel und scores zu speichern (siehe unten)
Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), () -> nextIndexDisplay(), 0, 200); Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), FightScoreboard::nextIndexDisplay, 0, 200);
} }
Review

Listener sollen im Ordner Listener sein, in diesem Fall solltest du wsl. einfach im ConnectionListener im JonListener einen Aufruf hierher machen.

Listener sollen im Ordner Listener sein, in diesem Fall solltest du wsl. einfach im ConnectionListener im JonListener einen Aufruf hierher machen.
public static Scoreboard getScoreboard() { public static Scoreboard getScoreboard() {
@ -73,7 +73,7 @@ public class FightScoreboard implements Listener {
} }
private static ScoreBoardObjective teamScoreboard(FightTeam fightTeam){ private static ScoreBoardObjective teamScoreboard(FightTeam fightTeam){
ScoreBoardObjective objective = new ScoreBoardObjective(fightTeam.getColoredName()); final ScoreBoardObjective objective = new ScoreBoardObjective(fightTeam.getColoredName());
fightTeam.getPlayers().forEach(fp -> { fightTeam.getPlayers().forEach(fp -> {
if(fp.isLiving()) if(fp.isLiving())
objective.addScore(fightTeam.getPrefix() + fp.getPlayer().getName(), (int) Math.ceil(fp.getPlayer().getHealth())); objective.addScore(fightTeam.getPrefix() + fp.getPlayer().getName(), (int) Math.ceil(fp.getPlayer().getHealth()));
@ -82,7 +82,7 @@ public class FightScoreboard implements Listener {
} }
private static ScoreBoardObjective generalScoreboard(){ private static ScoreBoardObjective generalScoreboard(){
ScoreBoardObjective objective = new ScoreBoardObjective("§6Kampf"); final ScoreBoardObjective objective = new ScoreBoardObjective("§6Kampf");
if (Config.Timeout || Config.Points || Config.HeartRatioTimeout) { if (Config.Timeout || Config.Points || Config.HeartRatioTimeout) {
int fightTime = FightSystem.getFightTime(); int fightTime = FightSystem.getFightTime();
if (fightTime >= 60) if (fightTime >= 60)
@ -123,9 +123,8 @@ public class FightScoreboard implements Listener {
private static void nextIndexDisplay() { private static void nextIndexDisplay() {
index++; index++;
if(index > 2) if(index > 2)
return;
index = 0; index = 0;
FightTeam team = getIndexDisplay(); final FightTeam team = getIndexDisplay();
if(team != null) if(team != null)
objective = teamScoreboard(team); objective = teamScoreboard(team);
else else
@ -135,7 +134,7 @@ public class FightScoreboard implements Listener {
private static class ScoreBoardObjective { private static class ScoreBoardObjective {
Review

Die Funktion nextIndexDisplay sollte sich mit der Funktion getIndexDisplay zusammenführen lassen.

Die Funktion nextIndexDisplay sollte sich mit der Funktion getIndexDisplay zusammenführen lassen.
private final String title; private final String title;
private HashMap<String, Integer> scores = new HashMap<>(); private final HashMap<String, Integer> scores = new HashMap<>();
public ScoreBoardObjective(String title) { public ScoreBoardObjective(String title) {
this.title = title; this.title = title;