Search in sources :

Example 6 with ParserNotSupportedException

use of pl.themolka.arcade.parser.ParserNotSupportedException in project Arcade2 by ShootGame.

the class ArcadePlugin method reloadConfig.

@Override
public void reloadConfig() {
    try {
        this.settings.setDocument(this.settings.readSettingsFile());
        this.getEventBus().publish(new SettingsReloadEvent(this, this.settings));
    } catch (DOMException | IOException | ParserNotSupportedException ex) {
        throw new RuntimeException(ex);
    }
}
Also used : DOMException(pl.themolka.arcade.dom.DOMException) SettingsReloadEvent(pl.themolka.arcade.settings.SettingsReloadEvent) IOException(java.io.IOException) ParserNotSupportedException(pl.themolka.arcade.parser.ParserNotSupportedException)

Example 7 with ParserNotSupportedException

use of pl.themolka.arcade.parser.ParserNotSupportedException in project Arcade2 by ShootGame.

the class SimpleGameManager method createGame.

@Override
public Game createGame(OfflineMap map) throws DOMException, IOException {
    File file = map.getSettings();
    DOMEngine engine = this.plugin.getDomEngines().forFile(file);
    Parser<MapManifest> parser;
    try {
        parser = this.plugin.getParsers().forType(MapManifest.class);
    } catch (ParserNotSupportedException ex) {
        throw new RuntimeException("No " + MapManifest.class.getSimpleName() + " parser installed");
    }
    Document document = engine.read(file);
    this.plugin.getDomPreprocessor().preprocess(document);
    ArcadeMap realMap = new ArcadeMap(map, parser.parse(document).orFail());
    WorldNameGenerator worldNameGenerator = new WorldNameGenerator(map);
    realMap.setWorldName(worldNameGenerator.nextWorldName());
    return this.createGame(realMap);
}
Also used : DOMEngine(pl.themolka.arcade.dom.engine.DOMEngine) WorldNameGenerator(pl.themolka.arcade.map.WorldNameGenerator) ArcadeMap(pl.themolka.arcade.map.ArcadeMap) MapManifest(pl.themolka.arcade.map.MapManifest) Document(pl.themolka.arcade.dom.Document) File(java.io.File) ParserNotSupportedException(pl.themolka.arcade.parser.ParserNotSupportedException)

Aggregations

ParserNotSupportedException (pl.themolka.arcade.parser.ParserNotSupportedException)7 IOException (java.io.IOException)3 DOMException (pl.themolka.arcade.dom.DOMException)3 File (java.io.File)2 Document (pl.themolka.arcade.dom.Document)2 Node (pl.themolka.arcade.dom.Node)2 DOMEngine (pl.themolka.arcade.dom.engine.DOMEngine)2 ParserContext (pl.themolka.arcade.parser.ParserContext)2 SettingsReloadEvent (pl.themolka.arcade.settings.SettingsReloadEvent)2 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 EngineManager (pl.themolka.arcade.dom.engine.EngineManager)1 Import (pl.themolka.arcade.dom.preprocess.Import)1 Preprocessor (pl.themolka.arcade.dom.preprocess.Preprocessor)1 Environment (pl.themolka.arcade.environment.Environment)1 ArcadeMap (pl.themolka.arcade.map.ArcadeMap)1 MapManifest (pl.themolka.arcade.map.MapManifest)1 WorldNameGenerator (pl.themolka.arcade.map.WorldNameGenerator)1 ParserContainer (pl.themolka.arcade.parser.ParserContainer)1 ParserException (pl.themolka.arcade.parser.ParserException)1