Reverted Scoreboard to a sync state

This commit is contained in:
Fabrizio La Rosa 2020-07-12 14:02:15 +02:00
parent 4400ac4297
commit 2b99f411c3

View File

@ -39,10 +39,11 @@ public class ScoreboardManager {
this.plugin = plugin; this.plugin = plugin;
this.playerDataManager = plugin.getPlayerDataManager(); this.playerDataManager = plugin.getPlayerDataManager();
Bukkit.getScheduler().runTask(plugin, () -> reloadScoreboards(true)); Bukkit.getScheduler().runTask(plugin, () -> reloadScoreboards(true));
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, this::updateScoreboards, 20L, 40L); Bukkit.getScheduler().runTaskTimer(plugin, this::updateScoreboards, 20L, 40L);
} }
private synchronized void updateScoreboards() { private synchronized void updateScoreboards() {
Bukkit.getScheduler().runTask(plugin, () -> {
final org.bukkit.scoreboard.Scoreboard primary = Bukkit.getScoreboardManager().getMainScoreboard(); final org.bukkit.scoreboard.Scoreboard primary = Bukkit.getScoreboardManager().getMainScoreboard();
final Set<Objective> objectives = primary.getObjectives(); final Set<Objective> objectives = primary.getObjectives();
final Set<Team> teams = primary.getTeams(); final Set<Team> teams = primary.getTeams();
@ -76,6 +77,7 @@ public class ScoreboardManager {
} }
} }
Bukkit.getScheduler().runTask(plugin, () -> {
/* /*
* Update the objective/team names. * Update the objective/team names.
*/ */
@ -95,6 +97,7 @@ public class ScoreboardManager {
} }
} }
Bukkit.getScheduler().runTask(plugin, () -> {
/* /*
* Update or add any missing information to the player's scoreboard. * Update or add any missing information to the player's scoreboard.
*/ */
@ -145,6 +148,9 @@ public class ScoreboardManager {
} }
} }
} }
});
});
});
} }
public synchronized void reloadScoreboards(boolean createNew) { public synchronized void reloadScoreboards(boolean createNew) {