use of pl.themolka.arcade.cycle.ServerCycleEvent in project Arcade2 by ShootGame.
the class SimpleGameManager method cycle.
@Override
public void cycle(OfflineMap target) {
Instant now = Instant.now();
if (target == null) {
OfflineMap next = this.getQueue().takeNextMap();
if (next == null) {
this.plugin.getLogger().severe("Map queue was empty");
return;
}
target = next;
// refill queue if it's empty
if (!this.getQueue().hasNextMap()) {
this.fillDefaultQueue();
}
}
this.plugin.getLogger().info("Cycling to '" + target.getName() + "' from '" + target.getDirectory().getName() + "'...");
try {
Game oldGame = this.getCurrentGame();
Game game = this.createGame(target);
this.plugin.getEventBus().publish(new ServerCycleEvent(this.plugin, game, oldGame));
if (this.currentGame != null) {
this.destroyGame(this.getCurrentGame());
}
this.setCurrentGame(game);
game.start();
if (this.getGameId() >= this.getMaxGameId()) {
this.setNextRestart(true);
}
} catch (DOMException ex) {
this.plugin.getLogger().log(Level.SEVERE, "Could not cycle to '" + target.getName() + "': " + ex.toString());
this.cycleNext();
return;
} catch (Throwable th) {
this.plugin.getLogger().log(Level.SEVERE, "Could not cycle to '" + target.getName() + "'", th);
this.cycleNext();
return;
}
this.plugin.getLogger().info("Cycled in " + (Instant.now().toEpochMilli() - now.toEpochMilli()) + " ms.");
}
Aggregations