Skip to content

NoSuchMethodError: ShapedRecipe.getChoiceMap() crashes randomized_crafts scenario on 1.8.8, blocking all default scenarios from loading #109

Description

@Gale0ne

UhcCore version: 1.19.4
Server software: Paper 1.8.8 (git-PaperSpigot-445, v1_8_R3)
Java version: 21 (Temurin)

Description

When the randomized_crafts scenario is enabled as one of the default scenarios,
the server throws a NoSuchMethodError while loading scenarios at game start.
This exception interrupts ScenarioManager.loadDefaultScenarios, which causes
ALL default scenarios to fail to load, not just randomized_crafts, resulting
in an empty scenario list / hotbar item for the entire game.

Steps to reproduce

  1. Run UhcCore 1.19.4 on Paper 1.8.8
  2. Enable randomized_crafts in the default-enabled-scenarios list
  3. Start a UHC game
  4. Observe the console error and the resulting empty scenario list

Expected behavior

Either randomized_crafts works correctly on 1.8.8, or a failure in one
scenario should not prevent the rest of the default scenarios from loading.

Actual behavior / Stack trace

[15:12:22 INFO]: [UhcCore] Loading randomized_crafts
[15:12:22 WARN]: [UhcCore] Task #35 for UhcCore v1.19.4 generated an exception
java.lang.NoSuchMethodError: 'java.util.Map org.bukkit.inventory.ShapedRecipe.getChoiceMap()'
at com.gmail.val59000mc.scenarios.scenariolisteners.RandomizedCraftsListener.cloneRecipeWithResult(RandomizedCraftsListener.java:58)
at com.gmail.val59000mc.scenarios.scenariolisteners.RandomizedCraftsListener.onEnable(RandomizedCraftsListener.java:38)
at com.gmail.val59000mc.scenarios.ScenarioManager.enableScenario(ScenarioManager.java:93)
at com.gmail.val59000mc.scenarios.ScenarioManager.loadDefaultScenarios(ScenarioManager.java:212)
at com.gmail.val59000mc.game.GameManager.startWaitingPlayers(GameManager.java:257)
at com.gmail.val59000mc.maploader.MapLoader$1.onDoneLoadingWorld(MapLoader.java:446)
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:59)
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:352)
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:783)
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378)
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:713)
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:616)
at java.lang.Thread.run(Thread.java:1474)

Suspected cause

ShapedRecipe.getChoiceMap() does not exist in the legacy 1.8.8 Bukkit API
(org.bukkit.craftbukkit.v1_8_R3). This method appears to have been introduced
in a later Bukkit API version. Since UhcCore advertises support for 1.8.8
through 1.21.10, this call likely needs a version-aware fallback (reflection
or an NMS-specific implementation) for legacy servers.

Suggested fix

Either:

  • Wrap the getChoiceMap() call in a version check / try-catch with a legacy
    fallback, or
  • Explicitly disable/skip randomized_crafts on server versions below the one
    where getChoiceMap() was introduced, with a warning log instead of a hard
    crash.

More importantly: one scenario failing to load should not abort the loading
of the remaining default scenarios.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions