Redo async scoreboards

This commit is contained in:
Fabrizio La Rosa 2020-07-12 19:36:13 +02:00
parent 74eae7037a
commit 80cc409899

View File

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