From 01e54db12194ed76b514717342c984dec98a09b9 Mon Sep 17 00:00:00 2001 From: Namayake5 Date: Mon, 18 Jul 2022 09:09:41 +0900 Subject: [PATCH] Changing timing of calling AutoCraft:collectRecipes() to correctly load recipes added by other plugins. --- src/main/java/fliens/autocraft/AutoCraft.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/fliens/autocraft/AutoCraft.java b/src/main/java/fliens/autocraft/AutoCraft.java index c5bca6e..125d54c 100644 --- a/src/main/java/fliens/autocraft/AutoCraft.java +++ b/src/main/java/fliens/autocraft/AutoCraft.java @@ -44,7 +44,7 @@ public class AutoCraft extends JavaPlugin { public static boolean allowBlockRecipeModification; public static ArrayList autoCrafters; - private ArrayList recipes = new ArrayList<>(); + private ArrayList recipes; @Override public void onEnable() { @@ -54,8 +54,8 @@ public void onEnable() { checkConfigFile(); updateConfig(); - - recipes = collectRecipes(); + //If you do this, every plugins that add recipes must be "LoadBefore" in plugin.yml. + //recipes = collectRecipes(); new EventListener(this); BukkitScheduler scheduler = getServer().getScheduler(); @@ -409,6 +409,11 @@ private ItemStack getCraftResult(List items) { } ItemStack result; + + // Load recipes after every plugin activated. + if(recipes == null){ + recipes = collectRecipes(); + } for (Recipe recipe : recipes) { if (recipe instanceof ShapelessRecipe) { // shapeless recipe result = matchesShapeless(((ShapelessRecipe) recipe).getChoiceList(), items) ? recipe.getResult()