Do not create empty scoreboards async

This commit is contained in:
Fabrizio La Rosa 2020-08-05 16:20:02 +02:00
parent fc48700c32
commit 5542ff42dc
2 changed files with 9 additions and 1 deletions

View File

@ -39,7 +39,7 @@ class Holder {
this.player.setScoreboard(board.board);
} else {
this.player.setScoreboard(plugin.getServer().getScoreboardManager().getNewScoreboard());
this.player.setScoreboard(scoreboardManager.getEmptyScoreboard());
}
}
}

View File

@ -9,8 +9,10 @@ import com.songoda.skyblock.playerdata.PlayerData;
import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.visit.Visit;
import io.netty.util.internal.ConcurrentSet;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Scoreboard;
import java.io.File;
import java.util.ArrayList;
@ -19,6 +21,7 @@ import java.util.Set;
public class ScoreboardManager extends Manager {
private final Scoreboard emptyScoreboard;
private final List<Driver> drivers;
private final Set<Player> disabledPlayers;
@ -26,6 +29,7 @@ public class ScoreboardManager extends Manager {
super(plugin);
this.drivers = new ArrayList<>();
this.disabledPlayers = new ConcurrentSet<>();
this.emptyScoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
for(ScoreboardType type : ScoreboardType.values()) {
newDriver(type);
@ -139,4 +143,8 @@ public class ScoreboardManager extends Manager {
driver.cancel();
drivers.clear();
}
public Scoreboard getEmptyScoreboard() {
return emptyScoreboard;
}
}