Class NMSHandler

java.lang.Object
com.ordwen.odailyquests.nms.NMSHandler

public final class NMSHandler extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.bukkit.inventory.meta.SkullMeta
    applySkullTexture(org.bukkit.inventory.meta.SkullMeta skullMeta, String texture)
    Applies a Mojang skin texture to the provided SkullMeta.
    static org.bukkit.NamespacedKey
    getItemModel(org.bukkit.inventory.meta.ItemMeta meta)
    Retrieves the NamespacedKey associated with an item's model.
    static String
     
    static boolean
    hasItemModel(org.bukkit.inventory.meta.ItemMeta meta)
    Indicates whether the provided ItemMeta declares a custom item_model.
    static boolean
    isVersionAtLeast(String versionPrefix)
    Checks whether the current server version is at least the provided prefix.
    static boolean
    trySetItemModel(org.bukkit.inventory.meta.ItemMeta meta, String itemModel)
    Tries to set the item_model of an ItemMeta using reflection.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getVersion

      public static String getVersion()
      Returns:
      the Bukkit version prefix (e.g. "1.20.4").
    • isVersionAtLeast

      public static boolean isVersionAtLeast(String versionPrefix)
      Checks whether the current server version is at least the provided prefix.

      This is a simple lexicographical comparison (String.compareTo(String)).

      Parameters:
      versionPrefix - a version prefix like "1.18.1"
      Returns:
      true if getVersion() is lexicographically >= versionPrefix
    • trySetItemModel

      public static boolean trySetItemModel(org.bukkit.inventory.meta.ItemMeta meta, String itemModel)
      Tries to set the item_model of an ItemMeta using reflection.
      Parameters:
      meta - the item meta to mutate
      itemModel - the model key in namespace:value form (namespace optional)
      Returns:
      true if the model was applied, false if unsupported or invalid input
    • hasItemModel

      public static boolean hasItemModel(org.bukkit.inventory.meta.ItemMeta meta)
      Indicates whether the provided ItemMeta declares a custom item_model.

      Uses reflection to remain compatible with server versions that do not provide ItemMeta#hasItemModel().

      Parameters:
      meta - item metadata to inspect
      Returns:
      true if an item model is present; false otherwise or on unsupported versions
    • getItemModel

      public static org.bukkit.NamespacedKey getItemModel(org.bukkit.inventory.meta.ItemMeta meta)
      Retrieves the NamespacedKey associated with an item's model.

      Uses reflection to call ItemMeta#getItemModel() only when available.

      Parameters:
      meta - item metadata to inspect
      Returns:
      the model key, or null if unavailable or unsupported
    • applySkullTexture

      public static org.bukkit.inventory.meta.SkullMeta applySkullTexture(org.bukkit.inventory.meta.SkullMeta skullMeta, String texture)
      Applies a Mojang skin texture to the provided SkullMeta.

      The texture argument must be the texture hash/id (not base64), for example "f84c6a790a4e...". The final URL is built as: https://textures.minecraft.net/texture/<texture>.

      Implementation is selected based on server version: modern profile API for >= 1.18.1, otherwise legacy GameProfile injection.

      Parameters:
      skullMeta - the skull meta to mutate
      texture - the Mojang texture id (hash)
      Returns:
      the same meta instance, for chaining