use of pl.themolka.arcade.dom.engine.DOMEngine in project Arcade2 by ShootGame.
the class MapLoaderModule method readMapDirectory.
private OfflineMap readMapDirectory(File worldDirectory) throws DOMException, IOException {
File file = new File(worldDirectory, MapManifest.FILENAME);
if (!file.exists()) {
throw new FileNotFoundException("Missing " + file.getName());
}
DOMEngine engine = this.getPlugin().getDomEngines().forFile(file);
Parser<OfflineMap> parser;
try {
parser = this.getPlugin().getParsers().forType(OfflineMap.class);
} catch (ParserNotSupportedException ex) {
throw new RuntimeException("No " + OfflineMap.class.getSimpleName() + " parser installed");
}
Document document = engine.read(file);
this.getPlugin().getDomPreprocessor().preprocess(document);
OfflineMap map = parser.parse(document).orFail();
map.setDirectory(worldDirectory);
map.setSettings(file);
return map;
}
use of pl.themolka.arcade.dom.engine.DOMEngine 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);
}
Aggregations