`/ocm reload` of GApple module fails on 1.13
I-Al-Istannen opened this issue ยท 2 comments
Info
- Server version: 1.13.1
- Relevant log excerpt:
Caused by: java.lang.IllegalStateException: Duplicate recipe ignored with ID oldcombatmechanics:minecraft
at net.minecraft.server.v1_13_R2.CraftingManager.a(CraftingManager.java:86) ~[spigot-1.13.1.jar:git-Spigot-0ede7d0-ee5efeb]
at org.bukkit.craftbukkit.v1_13_R2.inventory.CraftShapedRecipe.addToCraftingManager(CraftShapedRecipe.java:60) ~[spigot-1.13.1.jar:git-Spigot-0ede7d0-ee5efeb]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.addRecipe(CraftServer.java:1147) ~[spigot-1.13.1.jar:git-Spigot-0ede7d0-ee5efeb]
at org.bukkit.Bukkit.addRecipe(Bukkit.java:588) ~[spigot-1.13.1.jar:git-Spigot-0ede7d0-ee5efeb]
at gvlfm78.plugin.OldCombatMechanics.module.ModuleGoldenApple.registerCrafting(ModuleGoldenApple.java:59) ~[?:?]
at gvlfm78.plugin.OldCombatMechanics.module.ModuleGoldenApple.reload(ModuleGoldenApple.java:53) ~[?:?]
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) ~[?:1.8.0_181]
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) ~[?:1.8.0_181]
Problem Description
Spigot introduced a compatibility layer for materials in 1.13 that rewrites the bytecode to replace Material enum entries with their legacy version. It does however not take that into account when finding a recipe, which is why this little safeguard fails:
if(Bukkit.getRecipesFor(napple).size() > 0) return;
Bukkit.addRecipe(r);
Proper solution
Make the target api version 1.13 to disable the rewriting (add api-version: 1.13
to the plugin.yml).
Problems with proper solution
- Material.INK_SACK was renamed to Material.INK_SAC, so we'd need to safeguard that. Not sure how to do that scalable, it is late today. I will have a go at that tomorrow unless somebody picks it up.
If you add api-version: 1.13
to the plugin.yml, does that still make the plugin work with 1.9 to 1.12 server versions?