knokko / custom-items-gradle

Knokko's Custom Items: Add custom items to your server, completely free of charge
MIT License
15 stars 3 forks source link

Handle unsupported ingredients more gracefully #319

Closed knokko closed 1 month ago

knokko commented 2 months ago

Someone made an item set with an invalid shapeless ingredient, resulting in the following nasty error:

[14:34:22 INFO]: Downloading content...
[14:34:23 ERROR]: [CustomItems] [STDERR] An error occurred during KCI reloading
[14:34:23 WARN]: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Cannot have non-item choice COCOA
[14:34:23 WARN]:        at org.bukkit.craftbukkit.scheduler.CraftFuture.get(CraftFuture.java:73)
[14:34:23 WARN]:        at org.bukkit.craftbukkit.scheduler.CraftFuture.get(CraftFuture.java:40)
[14:34:23 WARN]:        at CustomItems.jar//nl.knokko.customitems.plugin.set.loading.ItemSetLoader.lambda$null$7(ItemSetLoader.java:304)
[14:34:23 WARN]:        at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftTask.java:86)
[14:34:23 WARN]:        at org.bukkit.craftbukkit.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57)
[14:34:23 WARN]:        at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22)
[14:34:23 WARN]:        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
[14:34:23 WARN]:        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
[14:34:23 WARN]:        at java.base/java.lang.Thread.run(Thread.java:1583)
[14:34:23 WARN]: Caused by: java.lang.IllegalArgumentException: Cannot have non-item choice COCOA
[14:34:23 WARN]:        at com.google.common.base.Preconditions.checkArgument(Preconditions.java:218)
[14:34:23 WARN]:        at org.bukkit.inventory.RecipeChoice$MaterialChoice.<init>(RecipeChoice.java:100)
[14:34:23 WARN]:        at org.bukkit.inventory.ShapelessRecipe.addIngredient(ShapelessRecipe.java:126)
[14:34:23 WARN]:        at org.bukkit.inventory.ShapelessRecipe.addIngredient(ShapelessRecipe.java:103)
[14:34:23 WARN]:        at CustomItems.jar//nl.knokko.customrecipes.crafting.CustomShapelessRecipes.lambda$null$1(CustomShapelessRecipes.java:42)
[14:34:23 WARN]:        at java.base/java.util.Map.forEach(Map.java:733)
[14:34:23 WARN]:        at CustomItems.jar//nl.knokko.customrecipes.crafting.CustomShapelessRecipes.lambda$register$2(CustomShapelessRecipes.java:42)
[14:34:23 WARN]:        at java.base/java.util.HashMap.forEach(HashMap.java:1429)
[14:34:23 WARN]:        at CustomItems.jar//nl.knokko.customrecipes.crafting.CustomShapelessRecipes.register(CustomShapelessRecipes.java:35)
[14:34:23 WARN]:        at CustomItems.jar//nl.knokko.customrecipes.crafting.CustomCraftingRecipes.register(CustomCraftingRecipes.java:54)
[14:34:23 WARN]:        at CustomItems.jar//nl.knokko.customrecipes.CustomRecipes.register(CustomRecipes.java:71)
[14:34:23 WARN]:        at CustomItems.jar//nl.knokko.customitems.plugin.recipe.CustomItemsRecipes.register(CustomItemsRecipes.java:238)
[14:34:23 WARN]:        at CustomItems.jar//nl.knokko.customitems.plugin.CustomItemsPlugin.afterReloadItems(CustomItemsPlugin.java:68)
[14:34:23 WARN]:        at CustomItems.jar//nl.knokko.customitems.plugin.set.loading.ItemSetLoader.reloadItems(ItemSetLoader.java:187)
[14:34:23 WARN]:        at CustomItems.jar//nl.knokko.customitems.plugin.set.loading.ItemSetLoader.doReload(ItemSetLoader.java:328)
[14:34:23 WARN]:        at CustomItems.jar//nl.knokko.customitems.plugin.set.loading.ItemSetLoader.lambda$null$5(ItemSetLoader.java:292)
[14:34:23 WARN]:        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
[14:34:23 WARN]:        at org.bukkit.craftbukkit.scheduler.CraftFuture.run(CraftFuture.java:88)
[14:34:23 WARN]:        at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:475)
[14:34:23 WARN]:        at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1724)
[14:34:23 WARN]:        at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:473)
[14:34:23 WARN]:        at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1596)
[14:34:23 WARN]:        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1302)
[14:34:23 WARN]:        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:329)
[14:34:23 WARN]:        ... 1 more

I should either validate this kind of stuff in the Editor, or check it during reload.