Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-2787

"Cannot copy null stack" when iterating over recipes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None

      Something goes wrong with validating item stacks when iterating over recipes. Using the following code:

      Iterator<Recipe> it = plugin.getServer().recipeIterator();
                  while (it.hasNext())
                  {
                      Recipe defaultRecipe = it.next();
                      // intend to do something with this recipe, but the above line throws an Exception
                 }
      

      I get the following Exception:

      java.lang.IllegalArgumentException: Cannot copy null stack
      	at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[spigot-1.11-R0.1-SNAPSHOT.jar:git-Spigot-d60de0a-d8c6364]
      	at org.bukkit.inventory.ItemStack.<init>(ItemStack.java:135) ~[spigot-1.11-R0.1-SNAPSHOT.jar:git-Spigot-d60de0a-d8c6364]
      	at org.bukkit.inventory.ShapelessRecipe.<init>(ShapelessRecipe.java:34) ~[spigot-1.11-R0.1-SNAPSHOT.jar:git-Spigot-d60de0a-d8c6364]
      	at org.bukkit.craftbukkit.v1_11_R1.inventory.CraftShapelessRecipe.<init>(CraftShapelessRecipe.java:17) ~[spigot-1.11-R0.1-SNAPSHOT.jar:git-Spigot-d60de0a-d8c6364]
      	at org.bukkit.craftbukkit.v1_11_R1.inventory.CraftShapelessRecipe.<init>(CraftShapelessRecipe.java:21) ~[spigot-1.11-R0.1-SNAPSHOT.jar:git-Spigot-d60de0a-d8c6364]
      	at net.minecraft.server.v1_11_R1.ShapelessRecipes.toBukkitRecipe(ShapelessRecipes.java:27) ~[spigot-1.11-R0.1-SNAPSHOT.jar:git-Spigot-d60de0a-d8c6364]
      	at net.minecraft.server.v1_11_R1.ShapelessRecipes.toBukkitRecipe(ShapelessRecipes.java:1) ~[spigot-1.11-R0.1-SNAPSHOT.jar:git-Spigot-d60de0a-d8c6364]
      	at org.bukkit.craftbukkit.v1_11_R1.inventory.RecipeIterator.next(RecipeIterator.java:30) ~[spigot-1.11-R0.1-SNAPSHOT.jar:git-Spigot-d60de0a-d8c6364]
      	at org.bukkit.craftbukkit.v1_11_R1.inventory.RecipeIterator.next(RecipeIterator.java:1) ~[spigot-1.11-R0.1-SNAPSHOT.jar:git-Spigot-d60de0a-d8c6364]
      ... my code as above
      

      This seems to be relatively new, I did not see the issue in git-Spigot-d60de0a-a951a88

            Unassigned Unassigned
            NathanWolf Nathan Wolf
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: