use of com.gmail.stefvanschiedev.buildinggame.managers.scoreboards.MainScoreboardManager in project buildinggame by stefvanschie.
the class MainScoreboardWorldChange method onWorldChange.
/**
* Handles the main scoreboard for players switching worlds
*
* @param e an event representing a player who switched between worlds
* @see PlayerChangedWorldEvent
* @since 3.1.1
*/
@EventHandler
public void onWorldChange(PlayerChangedWorldEvent e) {
YamlConfiguration config = SettingsManager.getInstance().getConfig();
var player = e.getPlayer();
MainScoreboardManager manager = MainScoreboardManager.getInstance();
if (!config.getBoolean("scoreboards.main.enable"))
return;
if (config.getStringList("scoreboards.main.worlds.enable").contains(player.getWorld().getName()))
// show scoreboard and other stuff
manager.register(player);
else if (config.getStringList("scoreboards.main.worlds.enable").contains(e.getFrom().getName())) {
// show scoreboard and other stuff
manager.remove(player);
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
}
}
Aggregations