private boolean registerShaped(ShapedRecipe recipe) { boolean failed = false; Plugin plugin = recipe.getPlugin(); if (plugin != null) { ConcurrentHashMap<Integer, RecipeTree> recipesMap = (ConcurrentHashMap<Integer, RecipeTree>) registeredShapedRecipes.get(plugin); if (recipesMap == null) { recipesMap = new ConcurrentHashMap<Integer, RecipeTree>(); registeredShapedRecipes.put(plugin, recipesMap); } if (recipesMap.get(recipe.getIngredients().size()) == null) { RecipeTree recipes = new RecipeTree(); registeredShapedRecipes.get(plugin).put(recipe.getIngredients().size(), recipes); } failed = !registeredShapedRecipes.get(plugin).get(recipe.getIngredients().size()).addRecipe(recipe) || failed; } if (allShapedRecipes.get(recipe.getIngredients().size()) == null) { RecipeTree recipes = new RecipeTree(); allShapedRecipes.put(recipe.getIngredients().size(), recipes); } failed = !allShapedRecipes.get(recipe.getIngredients().size()).addRecipe(recipe) || failed; return !failed; }
private boolean removeShaped(ShapedRecipe recipe) { boolean failed = false; Plugin plugin = recipe.getPlugin(); if (plugin != null) { if (!registeredShapedRecipes.containsKey(plugin)) { return false; } if (!registeredShapedRecipes.get(plugin).containsKey(recipe.getIngredients().size())) { return false; } failed = !registeredShapedRecipes .get(plugin) .get(recipe.getIngredients().size()) .removeRecipe(recipe) || failed; } if (!allShapedRecipes.containsKey(recipe.getIngredients().size())) { return false; } failed = !allShapedRecipes.get(recipe.getIngredients().size()).removeRecipe(recipe) || failed; return !failed; }