Class InventoryApiNMS

java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.nms.InventoryApiNMS

public final class InventoryApiNMS extends Object
Picks the right InventoryTitleUpdater for the running server. The strategy is:
  1. If the server exposes the modern public Bukkit API — the parsed minor version is 20 or newer (1.20+), or the CraftBukkit package is un-versioned (Paper 1.20.5+, where no vX_Y_RZ suffix is present) — return BukkitInventoryTitleUpdater, which uses InventoryView#setTitle (added in 1.20).
  2. Otherwise, look up the legacy CraftBukkit package suffix (e.g. v1_19_R3) and instantiate the matching per-version NMS class.

The dispatch uses static references — not reflection — so that the maven-shade-plugin's minimizer keeps each per-version class in the consumer's plugin jar. The JVM still loads each TitleUpdater_1_X_RY lazily on first use, so a server running 1.16.5 never resolves the net.minecraft.server.v1_19_R3.* types referenced by TitleUpdater_1_19_R3 — only the chosen branch is linked.

  • Method Details

    • getTitleUpdater

      public static InventoryTitleUpdater getTitleUpdater()
      Resolves the InventoryTitleUpdater appropriate for the current server.
      Returns:
      the resolved updater
      Throws:
      IllegalStateException - if the server version is older than 1.20 and the matching per-version NMS implementation cannot be found on the classpath