Remove dangerous RecipeUtil method.

This commit is contained in:
Olof Larsson 2017-07-02 18:23:53 +02:00
parent d74690ec7c
commit 3964089955

View File

@ -19,33 +19,6 @@ import java.util.Objects;
// NOTE: This utility targets 1.9 and will crash on older servers. // NOTE: This utility targets 1.9 and will crash on older servers.
public class RecipeUtil public class RecipeUtil
{ {
// ------------------------------------------- //
// REMOVE
// -------------------------------------------- //
public static void remove(Predicate<Recipe> removePredicate)
{
Objects.requireNonNull(removePredicate);
List<Recipe> recipesToRemove = new MassiveList<>();
List<Recipe> recipesToKeep = new MassiveList<>();
Iterator<Recipe> iterator = Bukkit.recipeIterator();
while (iterator.hasNext())
{
Recipe recipe = iterator.next();
List<Recipe> recipes = removePredicate.apply(recipe) ? recipesToRemove : recipesToKeep;
recipes.add(recipe);
}
if (recipesToRemove.isEmpty()) return;
Bukkit.clearRecipes();
for (Recipe recipe : recipesToKeep) {
Bukkit.addRecipe(recipe);
}
}
// ------------------------------------------- // // ------------------------------------------- //
// POTION // POTION
// -------------------------------------------- // // -------------------------------------------- //