use of com.gmail.stefvanschiedev.buildinggame.api.events.ArenaStopEvent in project buildinggame by stefvanschie.
the class Arena method stop.
/**
* Stops the arena and resets it so it's open for new players. If you want to stop the arena while it's still
* running use {@link #forceStop()}.
*
* @since 2.1.0
*/
public void stop() {
YamlConfiguration config = SettingsManager.getInstance().getConfig();
YamlConfiguration messages = SettingsManager.getInstance().getMessages();
// call event
ArenaStopEvent event = new ArenaStopEvent(this);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return;
getUsedPlots().stream().flatMap(plot -> plot.getAllGamePlayers().stream()).forEach(gamePlayer -> gamePlayer.connect(MainSpawnManager.getInstance().getServer(), MainSpawnManager.getInstance().getMainSpawn()));
// update bossbar
getBossBar().setTitle(MessageManager.translate(messages.getString("global.bossbar-header").replace("%subject%", "?")));
getBossBar().setVisible(false);
getBossBar().getPlayers().forEach(player -> getBossBar().removePlayer(player));
getUsedPlots().stream().flatMap(plot -> plot.getAllGamePlayers().stream()).forEach(gamePlayer -> {
Player player = gamePlayer.getPlayer();
gamePlayer.restore();
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
// show all players again
if (config.getBoolean("tab-list.adjust"))
Bukkit.getOnlinePlayers().forEach(pl -> player.showPlayer(Main.getInstance(), pl));
// reset scoreboard
getUsedPlots().stream().flatMap(p -> p.getGamePlayers().stream()).forEach(gp -> gp.getPlayer().setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()));
});
getPlots().forEach(plot -> plot.getAllGamePlayers().clear());
this.matches = 0;
SignManager.getInstance().updateJoinSigns(this);
}
Aggregations