/** * Reload RecipeManager's settings, messages, etc and re-parse recipes. * * @param sender To whom to send the messages to, null = console. * @param check Set to true to only check recipes, settings are unaffected. */ public void reload(CommandSender sender, boolean check, boolean firstTime) { Settings.getInstance().reload(sender); // (re)load settings Messages.getInstance().reload(sender); // (re)load messages from messages.yml Files.reload(sender); // (re)generate info files if they do not exist Updater.init(this, 32835, null); if (metrics == null) { if (Settings.getInstance().getMetrics()) { // start/stop metrics accordingly try { metrics = new Metrics(this); metrics.start(); } catch (IOException e) { e.printStackTrace(); } } } else { metrics.stop(); } if (!check) { if (Settings.getInstance().getClearRecipes() || !firstTime) { Vanilla.removeAllButSpecialRecipes(); Recipes.getInstance().clean(); } if (!firstTime && !Settings.getInstance().getClearRecipes()) { Vanilla.restoreAllButSpecialRecipes(); Recipes.getInstance().index.putAll(Vanilla.initialRecipes); } } RecipeProcessor.reload(sender, check); // (re)parse recipe files Events.reload(); // (re)register events }
public static String getIngTypesAndStocksAsHTML2(Menuweekall menuweekall) { // SimpleDateFormat sdf = new SimpleDateFormat("EEEE, d. MMMM yyyy"); String html = ""; LocalDate startDay = new LocalDate(menuweekall.getWeek()); for (int day = 0; day < 7; day++) { LocalDate thisDay = startDay.plusDays(day); String dayHTML = ""; // HTML.h1(thisDay.toString("EEEE, d. MMMM yyyy")); boolean firstMenuThisDay = true; // just for the pagebreak for (Menuweek menuweek : menuweekall.getMenuweeks()) { Menuweek2Menu menuweek2Menu = menuweek.getMenuweek2menus().get(day); Menu menu = menuweek2Menu.getMenu(); if (!menu.isEmpty()) { if (!firstMenuThisDay) dayHTML += HTML.pagebreak(); firstMenuThisDay = false; dayHTML += HTML.h1( menuweek.getRecipefeature().getText() + " (" + thisDay.toString("EEEE, d. MMMM yyyy") + ")"); for (int dish : MenuTools.DISHES) { Recipes recipe = MenuTools.getDish(menu, dish); if (recipe != null) { dayHTML += HTML.h2(recipe.getTitle()); String list = RecipeTools.getSubRecipesAsHTML(MenuTools.getDish(menu, dish)); Set<Stock> stocks = MenuTools.getStocklist(menu, dish); for (Stock stock : stocks) { list += HTML.li(stock.getId() + ": " + stock.getProdukt().getBezeichnung()); } dayHTML += HTML.ul(list); } } } } html += dayHTML; if (day < 6) html += HTML.pagebreak(); } return html; }
public static void SetupWorld(World world) { long seed = world.getSeed(); Random R = new Random(seed); world.provider.registerWorld(world); Recipes.registerAnvilRecipes(R, world); // TerraFirmaCraft.proxy.registerSkyProvider(world.provider); }
public Recipes unmarshall(JsonUnmarshallerContext context) throws Exception { Recipes recipes = new Recipes(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.currentToken; if (token == null) token = context.nextToken(); if (token == VALUE_NULL) return null; while (true) { if (token == null) break; if (token == FIELD_NAME || token == START_OBJECT) { if (context.testExpression("Setup", targetDepth)) { context.nextToken(); recipes.setSetup( new ListUnmarshaller<String>(StringJsonUnmarshaller.getInstance()) .unmarshall(context)); } if (context.testExpression("Configure", targetDepth)) { context.nextToken(); recipes.setConfigure( new ListUnmarshaller<String>(StringJsonUnmarshaller.getInstance()) .unmarshall(context)); } if (context.testExpression("Deploy", targetDepth)) { context.nextToken(); recipes.setDeploy( new ListUnmarshaller<String>(StringJsonUnmarshaller.getInstance()) .unmarshall(context)); } if (context.testExpression("Undeploy", targetDepth)) { context.nextToken(); recipes.setUndeploy( new ListUnmarshaller<String>(StringJsonUnmarshaller.getInstance()) .unmarshall(context)); } if (context.testExpression("Shutdown", targetDepth)) { context.nextToken(); recipes.setShutdown( new ListUnmarshaller<String>(StringJsonUnmarshaller.getInstance()) .unmarshall(context)); } } else if (token == END_ARRAY || token == END_OBJECT) { if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) { if (context.getCurrentDepth() <= originalDepth) break; } } token = context.nextToken(); } return recipes; }
@Override public void onDisable() { try { Bukkit.getScheduler().cancelTasks(this); if (plugin == null) { return; } Vanilla.removeCustomRecipes(); Furnaces.save(); Furnaces.clean(); BrewingStands.save(); BrewingStands.clean(); Workbenches.clean(); Players.clean(); Vanilla.clean(); recipes.clean(); recipes = null; recipeBooks.clean(); recipeBooks = null; events.clean(); events = null; Settings.clean(); Econ.getInstance().clean(); Perms.getInstance().clean(); if (metrics != null) { metrics.stop(); metrics = null; } plugin = null; } catch (Throwable e) { MessageSender.getInstance().error(null, e, null); } }
public static String getIngTypesAndStocksAsHTML(Menuweekall menuweekall) { // SimpleDateFormat sdf = new SimpleDateFormat("EEEE, d. MMMM yyyy"); String html = "<h1 id=\"fonth1\">Zutaten und Vorräte</h1>"; HashSet<Additives> setAdditives = new HashSet<Additives>(); HashSet<Allergene> setAllergenes = new HashSet<Allergene>(); LocalDate startDay = new LocalDate(menuweekall.getWeek()); String outerTable = ""; for (int day = 0; day < 6; day++) { LocalDate thisDay = startDay.plusDays(day); outerTable += HTML.table_tr( HTML.table_th(HTML.fontface + thisDay.toString("EEEE, d. MMMM yyyy") + "</font>", 2)); String midTable = ""; for (Menuweek menuweek : menuweekall.getMenuweeks()) { Menuweek2Menu menuweek2Menu = menuweek.getMenuweek2menus().get(day); Menu menu = menuweek2Menu.getMenu(); if (!menu.isEmpty()) { outerTable += HTML.table_tr( HTML.table_th( menuweek2Menu.getMenu().getText() + " (" + menuweek.getRecipefeature().getText() + ")", 2)); for (int dish : MenuTools.DISHES) { Recipes recipe = MenuTools.getDish(menu, dish); if (recipe != null) { outerTable += HTML.table_tr(HTML.table_td(recipe.getTitle(), 2)); outerTable += HTML.table_tr(HTML.table_td("Zutaten") + HTML.table_td("Vorräte")); String ingList = recipe.getIngTypes2Recipes().isEmpty() ? HTML.li(HTML.italic("leer...")) : ""; for (Ingtypes2Recipes it2r : recipe.getIngTypes2Recipes()) { ingList += HTML.li( it2r.getIngType().getBezeichnung() + (it2r.getAmount().compareTo(BigDecimal.ZERO) > 0 ? ", " + it2r.getAmount() + " " + IngTypesTools.EINHEIT[it2r.getIngType().getEinheit()] : "")); } Set<Stock> stocks = MenuTools.getStocklist(menu, dish); String stocklist = stocks.isEmpty() ? HTML.li(HTML.italic("leer...")) : ""; for (Stock stock : stocks) { stocklist += HTML.li(stock.getId() + ": " + stock.getProdukt().getBezeichnung()); } outerTable += HTML.table_tr( HTML.table_td(HTML.ul(ingList)) + HTML.table_td(HTML.ul(stocklist))); } } } // outerTable += HTML.table_tr( // HTML.table( // midTable // ,"1" // ) // ); } } html += HTML.table(outerTable, "1"); // // print a keymap on the next page // if (!setAdditives.isEmpty() || !setAllergenes.isEmpty()) { // html += "<h1 id=\"fonth1\" style=\"page-break-before:always\">Legende</h1>"; // // if (!setAllergenes.isEmpty()) { // html += "<h2 id=\"fonth2\">Allergene</h2>"; // html += "<ul>"; // // ArrayList<Allergene> list = new ArrayList<Allergene>(setAllergenes); // Collections.sort(list); // // for (Allergene allergene : list) { // html += "<li><b>" + allergene.getKennung() + "</b> " + // allergene.getText(); // } // // html += "</ul>"; // } // // if (!setAdditives.isEmpty()) { // html += "<h2 id=\"fonth2\">Zusatzstoffe</h2>"; // html += "<ul>"; // // ArrayList<Additives> list = new ArrayList<Additives>(setAdditives); // Collections.sort(list); // // for (Additives additive : list) { // html += "<li><b>" + additive.getSymbol() + "</b> " + additive.getName() + // (additive.getText().isEmpty() ? "" : " <i>" + additive.getText() + "</i>"); // } // // html += "</ul>"; // } // } return html; }
@EventHandler public void postInit(FMLPostInitializationEvent event) { Recipes.addRecipes(); }
@Override public void addRecipes() { addFluids(); Recipes.add(); }
public static RecipeData getDishwasherRecipeFromInput(ItemStack itemStack) { return Recipes.getDishwasherRecipeFromInput(itemStack); }
public static RecipeData getWashingMachineRecipeFromInput(ItemStack itemStack) { return Recipes.getWashingMachineRecipeFromInput(itemStack); }
public static RecipeData getMicrowaveRecipeFromIngredients(ItemStack itemStack) { return Recipes.getMicrowaveRecipeFromInput(itemStack); }
public static RecipeData getBlenderRecipeDataFromIngredients(ItemStack[] itemStack) { return Recipes.getBlenderRecipeFromIngredients(itemStack); }
public static RecipeData getChoppingBoardRecipeFromInput(ItemStack itemStack) { return Recipes.getChoppingBoardRecipeFromInput(itemStack); }
public static RecipeData getToasterRecipeFromInput(ItemStack itemStack) { return Recipes.getToasterRecipeFormInput(itemStack); }
public static RecipeData getFreezerRecipeFromInput(ItemStack itemStack) { return Recipes.getFreezerRecipeFromInput(itemStack); }
public static RecipeData[] getMineBayItems() { return Recipes.getMineBayItems(); }