Luohuayu / CatServer

高性能和高兼容性的1.12.2/1.16.5/1.18.2版本Forge+Bukkit+Spigot服务端 (A high performance and high compatibility 1.12.2/1.16.5/1.18.2 version Forge+Bukkit+Spigot server)
https://catmc.org
GNU Lesser General Public License v3.0
1.98k stars 211 forks source link

[1.16.5] NoSuchElementException when looping over Bukkit.recipeIterator() #540

Closed mfnalex closed 2 years ago

mfnalex commented 2 years ago

Using Bukkit's recipe iterator, it throws the following error when simply looping over the iterator:

[20:23:09] [Server thread/ERROR]: Error occurred while enabling AngelChest v9.4.0 (Is it up to date?)
 java.util.NoSuchElementException: null
        at java.util.HashMap$HashIterator.nextNode(HashMap.java:1471) ~[?:1.8.0_333]
        at java.util.HashMap$ValueIterator.next(HashMap.java:1498) ~[?:1.8.0_333]
        at org.bukkit.craftbukkit.v1_16_R3.inventory.RecipeIterator.next(RecipeIterator.java:31) ~[forge:?]
        at org.bukkit.craftbukkit.v1_16_R3.inventory.RecipeIterator.next(RecipeIterator.java:12) ~[forge:?]
        at de.jeff_media.angelchest.jC.<init>(lt:360) ~[?:?] <-- See below java code
        ...

To reproduce (the marked line is the line that throws the above error):

        Iterator<Recipe> iterator = Bukkit.recipeIterator();
        while(iterator.hasNext()) { // <-- This is the marked line from the above stacktrace
            // Do something...

This probably only happens when using blocks / items added by forge mods.

Suggested fix: Make the RecipeIterator only return recipes that contain blocks / items recognizable by Bukkit's Material class.

Kotori0629 commented 2 years ago

Thanks for your submission, we will fix it asap

Baikele commented 2 years ago

这个修复了么?