package gg.malloc.defense.ui; import org.bukkit.entity.Player; import org.bukkit.scoreboard.ScoreboardManager; import java.util.HashMap; import gg.malloc.defense.model.State; public class Sidebars { State m_state; ScoreboardManager m_scoreboards; HashMap m_sidebars = new HashMap<>(); public Sidebars(State state, ScoreboardManager scoreboards) { m_state = state; m_scoreboards = scoreboards; } public void addPlayer(Player player) { m_sidebars.put(player, new Sidebar(m_state, m_scoreboards.getNewScoreboard(), player)); player.setScoreboard(m_sidebars.get(player).getScoreboard()); } public void removePlayer(Player player) { m_sidebars.remove(player); player.setScoreboard(m_scoreboards.getMainScoreboard()); } public void update() { for(Player p : m_sidebars.keySet()) { m_sidebars.get(p).update(); } } }