private void processConfig(RecipeConfig config) { List<Recipe> newRecipes = config.getRecipes(false); Log.info("Found " + newRecipes.size() + " valid Vat recipes in config."); for (Recipe rec : newRecipes) { addRecipe(rec); } Log.info("Finished processing Vat recipes. " + recipes.size() + " recipes avaliable."); }
public void addCustomRecipes(String xmlDef) { RecipeConfig config; try { config = RecipeConfigParser.parse(xmlDef, null); } catch (Exception e) { Log.error("Error parsing custom xml"); return; } if (config == null) { Log.error("Could process custom XML"); return; } processConfig(config); }
public void addRecipe(IRecipe recipe) { if (recipe == null || !recipe.isValid()) { Log.debug("Could not add invalid Vat recipe: " + recipe); return; } recipes.add(new VatRecipe(recipe)); }
public static RecipeConfig loadRecipeConfig( String coreFileName, String customFileName, CustomTagHandler customHandler) { File coreFile = new File(Config.configDirectory, coreFileName); String defaultVals = null; try { defaultVals = readRecipes(coreFile, coreFileName, true); } catch (IOException e) { Log.error( "Could not load default recipes file " + coreFile + " from EnderIO jar: " + e.getMessage()); e.printStackTrace(); return null; } if (!coreFile.exists()) { Log.error("Could not load default recipes from " + coreFile + " as the file does not exist."); return null; } RecipeConfig config; try { config = RecipeConfigParser.parse(defaultVals, customHandler); } catch (Exception e) { Log.error("Error parsing " + coreFileName); return null; } File userFile = new File(Config.configDirectory, customFileName); String userConfigStr = null; try { userConfigStr = readRecipes(userFile, customFileName, false); if (userConfigStr == null || userConfigStr.trim().length() == 0) { Log.error("Empty user config file: " + userFile.getAbsolutePath()); } else { RecipeConfig userConfig = RecipeConfigParser.parse(userConfigStr, customHandler); config.merge(userConfig); } } catch (Exception e) { Log.error("Could not load user defined recipes from file: " + customFileName); e.printStackTrace(); } return config; }
private void updateConfig() { if (conf == null) { Log.warn("HyperCubeRegister.updateConfig: Config was null."); return; } conf.setPublicChannels(publicChannels); conf.setUserChannels(userChannels); conf.save(); }
public void loadRecipesFromConfig() { RecipeConfig config = RecipeConfig.loadRecipeConfig(CORE_FILE_NAME, CUSTOM_FILE_NAME, null); if (config != null) { processConfig(config); } else { Log.error("Could not load recipes for Vat."); } MachineRecipeRegistry.instance.registerRecipe( ModObject.blockVat.unlocalisedName, new VatMachineRecipe()); }
public void merge(RecipeConfig userConfig) { if (userConfig.dumpItemRegistery) { dumpItemRegistery = true; } if (userConfig.dumpOreDictionary) { dumpOreDictionary = true; } for (RecipeGroup group : userConfig.getRecipeGroups().values()) { if (!group.enabled) { if (recipeGroups.remove(group.name) != null) { Log.info("Disabled core recipe group " + group.name + " due to user config."); } } else { RecipeGroup modifyGroup = recipeGroups.get(group.name); if (modifyGroup == null) { Log.info("Added user defined recipe group " + group.name); modifyGroup = new RecipeGroup(group.name); recipeGroups.put(group.name, modifyGroup); } for (RecipeElement recipe : group.recipes.values()) { if (recipe.isValid()) { if (modifyGroup.recipes.containsKey(recipe.name)) { Log.info("Replacing core recipe " + recipe.name + " with user defined recipe."); } else { Log.info("Added user defined recipe " + recipe.name); } modifyGroup.addRecipe(recipe); } else { Log.info("Removed recipe " + recipe.name + " due to user config."); modifyGroup.recipes.remove(recipe.name); } } } } }
public static String readRecipes(File copyTo, String fileName, boolean replaceIfExists) throws IOException { if (!replaceIfExists && copyTo.exists()) { return readStream(new FileInputStream(copyTo)); } InputStream in = RecipeConfig.class.getResourceAsStream("/assets/enderio/config/" + fileName); if (in == null) { Log.error("Could load default AlloySmelter recipes."); throw new IOException( "Could not resource /assets/enderio/config/" + fileName + " form classpath. "); } String output = readStream(in); BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(copyTo, false)); writer.write(output.toString()); } finally { IOUtils.closeQuietly(writer); } return output.toString(); }