use of com.google.gson.JsonParseException in project Almura by AlmuraDev.
the class RecipeManager method load.
public void load() throws IOException {
this.logger.debug("Loading recipes...");
for (final Path source : this.sources) {
final Iterator<Path> it = Files.walk(source).iterator();
while (it.hasNext()) {
final Path path = it.next();
if ("json".equals(FilenameUtils.getExtension(path.toString()))) {
final String id = FilenameUtils.removeExtension(source.relativize(path).toString()).replace("\\\\", "/");
try (final BufferedReader br = Files.newBufferedReader(path)) {
try {
final Object recipe = parseRecipe(JsonUtils.fromJson(GSON, br, JsonObject.class));
if (recipe instanceof IRecipe) {
((IRecipe) recipe).setRegistryName(new ResourceLocation("almura", id));
GameData.register_impl((IRecipe) recipe);
} else if (recipe instanceof FurnaceRecipe) {
((FurnaceRecipe) recipe).register();
}
} catch (final JsonParseException e) {
this.logger.error("Encountered an exception parsing recipe '{}'", path.toAbsolutePath().toString(), e);
}
}
}
}
}
}
Aggregations