Skip to content

Commit

Permalink
Merge pull request #20 from Namakeya/main
Browse files Browse the repository at this point in the history
Changing timing of calling AutoCraft:collectRecipes() to correctly lo…
  • Loading branch information
Fliens authored Jul 18, 2022
2 parents 68cd111 + 01e54db commit 7bd518c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/java/fliens/autocraft/AutoCraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class AutoCraft extends JavaPlugin {
public static boolean allowBlockRecipeModification;

public static ArrayList<Block> autoCrafters;
private ArrayList<Recipe> recipes = new ArrayList<>();
private ArrayList<Recipe> recipes;

@Override
public void onEnable() {
Expand All @@ -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();
Expand Down Expand Up @@ -409,6 +409,11 @@ private ItemStack getCraftResult(List<ItemStack> 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()
Expand Down

0 comments on commit 7bd518c

Please sign in to comment.