use of delta.games.lotro.lore.crafting.recipes.RecipesManager in project lotro-tools by dmorcellet.
the class ResolveItemLinksInRecipes method handleRecipes.
private void handleRecipes(ItemsResolver resolver) {
// Load recipes
RecipesManager rMgr = RecipesManager.getInstance();
File recipesDir = LotroCoreConfig.getInstance().getRecipesDir();
FileFilter fileFilter = new ExtensionPredicate("xml");
File[] recipeFiles = recipesDir.listFiles(fileFilter);
if (recipeFiles != null) {
Set<String> missingKeys = new HashSet<String>();
for (File recipeFile : recipeFiles) {
String idStr = recipeFile.getName();
idStr = idStr.substring(0, idStr.length() - 4);
int id = NumericTools.parseInt(idStr, -1);
if (id != -1) {
Recipe recipe = rMgr.getRecipe(Integer.valueOf(id));
List<Ingredient> ingredients = recipe.getIngredients();
for (Ingredient ingredient : ingredients) {
ItemReference itemRef = ingredient.getItem();
handleItemRef(resolver, missingKeys, itemRef);
}
/*
ItemReference scroll=recipe.getRecipeScroll();
if (scroll!=null)
{
handleItemRef(ids,missingKeys,scroll);
}
*/
List<RecipeVersion> versions = recipe.getVersions();
for (RecipeVersion version : versions) {
CraftingResult regular = version.getRegular();
if (regular != null) {
ItemReference ref = regular.getItem();
handleItemRef(resolver, missingKeys, ref);
}
CraftingResult critical = version.getCritical();
if (critical != null) {
ItemReference ref = critical.getItem();
handleItemRef(resolver, missingKeys, ref);
}
}
}
}
List<String> sortedKeys = new ArrayList<String>(missingKeys);
Collections.sort(sortedKeys);
for (String missingKey : sortedKeys) {
System.out.println("Missing : " + missingKey);
}
System.out.println("Missing : " + sortedKeys.size());
}
}
Aggregations