Search in sources :

Example 6 with DOMException

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.");
}
Also used : DOMException(pl.themolka.arcade.dom.DOMException) ServerCycleEvent(pl.themolka.arcade.cycle.ServerCycleEvent) Instant(java.time.Instant) OfflineMap(pl.themolka.arcade.map.OfflineMap)

Example 7 with DOMException

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;
}
Also used : DOMException(pl.themolka.arcade.dom.DOMException) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

DOMException (pl.themolka.arcade.dom.DOMException)7 IOException (java.io.IOException)4 InputStream (java.io.InputStream)3 ParserNotSupportedException (pl.themolka.arcade.parser.ParserNotSupportedException)3 ArrayList (java.util.ArrayList)2 Settings (pl.themolka.arcade.settings.Settings)2 SettingsReloadEvent (pl.themolka.arcade.settings.SettingsReloadEvent)2 File (java.io.File)1 Instant (java.time.Instant)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 World (org.bukkit.World)1 Vector (org.bukkit.util.Vector)1 BukkitCommands (pl.themolka.arcade.command.BukkitCommands)1 ConsoleSender (pl.themolka.arcade.command.ConsoleSender)1 ServerCycleEvent (pl.themolka.arcade.cycle.ServerCycleEvent)1 Node (pl.themolka.arcade.dom.Node)1 EngineManager (pl.themolka.arcade.dom.engine.EngineManager)1 Import (pl.themolka.arcade.dom.preprocess.Import)1 Include (pl.themolka.arcade.dom.preprocess.Include)1 Preprocessor (pl.themolka.arcade.dom.preprocess.Preprocessor)1