Fix scoreboard flickering

This commit is contained in:
Fabrizio La Rosa 2020-08-05 22:19:09 +02:00
parent 7837c490cd
commit 1e74d196e9
2 changed files with 5 additions and 5 deletions

View File

@ -45,9 +45,8 @@ public class ScoreboardCommand extends SubCommand {
} else {
playerData.setScoreboard(true);
scoreboardManager.removeDisabledPlayer(player);
Bukkit.getScheduler().runTask(plugin, () -> {
scoreboardManager.updatePlayerScoreboardType(player);
});
Bukkit.getScheduler().runTask(plugin, () ->
scoreboardManager.updatePlayerScoreboardType(player));
messageManager.sendMessage(player, configLoad.getString("Command.Scoreboard.Enabled.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F);

View File

@ -98,10 +98,9 @@ public class ScoreboardManager extends Manager {
public void setPlayerScoreboard(Player player, ScoreboardType type) {
for(Driver driver : drivers) {
driver.unregisterHolder(player);
if(driver.getBoardType().equals(type)) {
driver.registerHolder(new Holder(plugin, driver, player));
} else {
driver.unregisterHolder(player);
}
}
}
@ -110,10 +109,12 @@ public class ScoreboardManager extends Manager {
for(Driver driver : drivers) {
driver.unregisterHolder(player);
}
player.setScoreboard(emptyScoreboard);
}
public void addDisabledPlayer(Player player) {
disabledPlayers.add(player);
Bukkit.getScheduler().runTask(plugin, () -> this.unregisterPlayer(player));
}
public void removeDisabledPlayer(Player player) {