use of pl.themolka.arcade.parser.ParserException in project Arcade2 by ShootGame.
the class SimpleGameManager method setDefaultMaxGameId.
@Override
public void setDefaultMaxGameId() {
Node node = this.plugin.getSettings().getData().child("queue");
if (node == null) {
return;
}
try {
ParserContext context = this.plugin.getParsers().createContext();
this.setMaxGameId(context.type(Integer.class).parse(node.property("restart-after")).orFail());
} catch (ParserNotSupportedException | ParserException ex) {
ex.printStackTrace();
}
}
use of pl.themolka.arcade.parser.ParserException in project Arcade2 by ShootGame.
the class OfflineMapParser method parseTree.
@Override
protected ParserResult<OfflineMap> parseTree(Node node, String name) throws ParserException {
Property fileVersionProperty = node.property("fileversion", "file-version", "ver", "version", "proto", "manifest");
MapFileVersion fileVersion = this.fileVersionParser.parse(fileVersionProperty).orDefault(MapFileVersions.NEWEST);
Node nameNode = node.firstChild("name");
Node versionNode = node.firstChild("version", "ver");
if (nameNode == null || versionNode == null) {
throw new ParserException(node, MISSING_NAME_VERSION);
}
String mapName = this.nameParser.parse(nameNode).orFail();
MapVersion version = this.versionParser.parse(versionNode).orFail();
String description = this.descriptionParser.parse(node.firstChild("description", "objective", "goal", "about")).orNull();
int mapNameLength = mapName.length();
if (mapNameLength < OfflineMap.NAME_MIN_LENGTH) {
throw this.fail(nameNode, nameNode.getName(), nameNode.getValue(), "Map name is shorter than " + OfflineMap.NAME_MIN_LENGTH + " characters");
} else if (mapNameLength > OfflineMap.NAME_MAX_LENGTH) {
throw this.fail(nameNode, nameNode.getName(), nameNode.getValue(), "Map name is longer than " + OfflineMap.NAME_MAX_LENGTH + " characters");
}
List<Author> authors = this.parseAuthors(node);
Node authorsNode = node.firstChild("authors", "contributors", "teams");
if (authorsNode != null) {
authors.addAll(this.parseAuthors(authorsNode));
}
List<Changelog> changelogs = new ArrayList<>();
Node changelogsNode = node.firstChild("changelog", "change-log", "changes");
if (changelogsNode != null) {
changelogs.addAll(this.parseChangelogs(changelogsNode));
}
return ParserResult.fine(node, name, new OfflineMap(fileVersion, mapName, version, description, authors, changelogs));
}
Aggregations