Class NmsBridge
java.lang.Object
com.github.pinont.singularitylib.api.nms.NmsBridge
Soft-loading bridge to the optional SingularityNMS module.
The lib is designed to run WITHOUT SingularityNMS installed: all NMS access is
funneled through this class, which reflectively probes for
com.github.pinont.singularitynms.* at runtime. When the NMS plugin (or jar)
is present on the server, deep vanilla-NBT operations become available; otherwise
the bridge reports isAvailable() == false and callers degrade gracefully
(e.g. fall back to PersistentDataContainer).
Bootstrap-model note: SingularityNMS ships as its own jar; on a server with both plugins installed, consumers get NMS-backed item/entity NBT through this neutral seam with no compile-time dependency.
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.inventory.ItemStackapplyItemNbt(org.bukkit.inventory.ItemStack item, Object nbt) Writes processed NBT back to an item via the NMSapplyTo(ItemStack); returns the new ItemStack (NMS treats Bukkit stacks as value copies) or the original when NMS is unavailable.static booleanhasVanillaNbt(org.bukkit.inventory.ItemStack item) Convenience: whether an item currently carries vanilla custom_data (best-effort; only meaningful when NMS is available).static booleanstatic @Nullable ObjectreadItemNbt(org.bukkit.inventory.ItemStack item) Reads the vanilla NBT of an item as a raw Object (actuallysingularitynms.nbt.NbtCompound) — usable via reflection only, ornullwhen NMS is unavailable.readItemNbtAsMap(org.bukkit.inventory.ItemStack item) Returns a map of the item's vanilla NBT keys to their SNBT string values (best-effort via reflection on the NMS NbtCompound; empty when NMS is absent).
-
Method Details
-
isAvailable
public static boolean isAvailable()- Returns:
- true if the SingularityNMS classes are loadable on this runtime
-
readItemNbt
Reads the vanilla NBT of an item as a raw Object (actuallysingularitynms.nbt.NbtCompound) — usable via reflection only, ornullwhen NMS is unavailable. -
applyItemNbt
public static org.bukkit.inventory.ItemStack applyItemNbt(org.bukkit.inventory.ItemStack item, Object nbt) Writes processed NBT back to an item via the NMSapplyTo(ItemStack); returns the new ItemStack (NMS treats Bukkit stacks as value copies) or the original when NMS is unavailable. -
hasVanillaNbt
public static boolean hasVanillaNbt(org.bukkit.inventory.ItemStack item) Convenience: whether an item currently carries vanilla custom_data (best-effort; only meaningful when NMS is available). -
readItemNbtAsMap
Returns a map of the item's vanilla NBT keys to their SNBT string values (best-effort via reflection on the NMS NbtCompound; empty when NMS is absent). Used by the DevTool inspector to display raw NBT without compile-time NMS deps.
-