use of pl.themolka.arcade.dom.DOMException 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.");
}
use of pl.themolka.arcade.dom.DOMException in project Arcade2 by ShootGame.
the class MapLoaderModule method loadContainer.
@Override
public MapContainer loadContainer() {
MapContainer container = new MapContainer();
List<String> registeredNames = new ArrayList<>();
for (File worldDirectory : this.worldFiles) {
if (!worldDirectory.isDirectory()) {
continue;
}
try {
OfflineMap map = this.readMapDirectory(worldDirectory);
if (map != null) {
if (registeredNames.contains(map.getName())) {
this.getLogger().log(Level.CONFIG, "'" + map.getName() + "' from '" + worldDirectory.getPath() + "' is a duplicate.");
continue;
}
container.register(map);
registeredNames.add(map.getName());
}
} catch (DOMException ex) {
this.getLogger().log(Level.SEVERE, "Could not load map '" + worldDirectory.getName() + "': " + ex.toString());
} catch (Throwable th) {
String message = th.getMessage();
if (message == null) {
message = th.getClass().getName();
}
this.getLogger().log(Level.SEVERE, "Could not load map '" + worldDirectory.getName() + "': " + message);
}
}
return container;
}
Aggregations