Search in sources :

Example 6 with ExtensionPredicate

use of delta.common.utils.files.filter.ExtensionPredicate 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());
    }
}
Also used : Recipe(delta.games.lotro.lore.crafting.recipes.Recipe) ArrayList(java.util.ArrayList) ExtensionPredicate(delta.common.utils.files.filter.ExtensionPredicate) RecipesManager(delta.games.lotro.lore.crafting.recipes.RecipesManager) ItemReference(delta.games.lotro.lore.crafting.recipes.ItemReference) Ingredient(delta.games.lotro.lore.crafting.recipes.Ingredient) RecipeVersion(delta.games.lotro.lore.crafting.recipes.RecipeVersion) FileFilter(java.io.FileFilter) File(java.io.File) CraftingResult(delta.games.lotro.lore.crafting.recipes.CraftingResult) HashSet(java.util.HashSet)

Aggregations

ExtensionPredicate (delta.common.utils.files.filter.ExtensionPredicate)6 File (java.io.File)6 FileFilter (java.io.FileFilter)4 ArrayList (java.util.ArrayList)3 Recipe (delta.games.lotro.lore.crafting.recipes.Recipe)2 Item (delta.games.lotro.lore.items.Item)2 ItemsManager (delta.games.lotro.lore.items.ItemsManager)2 IntegerHolder (delta.common.utils.misc.IntegerHolder)1 CraftingResult (delta.games.lotro.lore.crafting.recipes.CraftingResult)1 Ingredient (delta.games.lotro.lore.crafting.recipes.Ingredient)1 ItemReference (delta.games.lotro.lore.crafting.recipes.ItemReference)1 RecipeVersion (delta.games.lotro.lore.crafting.recipes.RecipeVersion)1 RecipesManager (delta.games.lotro.lore.crafting.recipes.RecipesManager)1 RecipesIndex (delta.games.lotro.lore.crafting.recipes.index.RecipesIndex)1 RecipesIndexXMLWriter (delta.games.lotro.lore.crafting.recipes.index.io.xml.RecipesIndexXMLWriter)1 RecipeXMLParser (delta.games.lotro.lore.crafting.recipes.io.xml.RecipeXMLParser)1 Bonus (delta.games.lotro.lore.items.bonus.Bonus)1 BonusManager (delta.games.lotro.lore.items.bonus.BonusManager)1 ItemXMLParser (delta.games.lotro.lore.items.io.xml.ItemXMLParser)1 QuestDescription (delta.games.lotro.lore.quests.QuestDescription)1