Package com.ordwen.odailyquests.nms
Class NMSHandler
java.lang.Object
com.ordwen.odailyquests.nms.NMSHandler
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.inventory.meta.SkullMetaapplySkullTexture(org.bukkit.inventory.meta.SkullMeta skullMeta, String texture) Applies a Mojang skin texture to the providedSkullMeta.static org.bukkit.NamespacedKeygetItemModel(org.bukkit.inventory.meta.ItemMeta meta) Retrieves theNamespacedKeyassociated with an item's model.static Stringstatic booleanhasItemModel(org.bukkit.inventory.meta.ItemMeta meta) Indicates whether the providedItemMetadeclares a customitem_model.static booleanisVersionAtLeast(String versionPrefix) Checks whether the current server version is at least the provided prefix.static booleantrySetItemModel(org.bukkit.inventory.meta.ItemMeta meta, String itemModel) Tries to set theitem_modelof anItemMetausing reflection.
-
Method Details
-
getVersion
- Returns:
- the Bukkit version prefix (e.g.
"1.20.4").
-
isVersionAtLeast
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:
trueifgetVersion()is lexicographically >=versionPrefix
-
trySetItemModel
Tries to set theitem_modelof anItemMetausing reflection.- Parameters:
meta- the item meta to mutateitemModel- the model key innamespace:valueform (namespace optional)- Returns:
trueif the model was applied,falseif unsupported or invalid input
-
hasItemModel
public static boolean hasItemModel(org.bukkit.inventory.meta.ItemMeta meta) Indicates whether the providedItemMetadeclares a customitem_model.Uses reflection to remain compatible with server versions that do not provide ItemMeta#hasItemModel().
- Parameters:
meta- item metadata to inspect- Returns:
trueif an item model is present;falseotherwise or on unsupported versions
-
getItemModel
public static org.bukkit.NamespacedKey getItemModel(org.bukkit.inventory.meta.ItemMeta meta) Retrieves theNamespacedKeyassociated 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
nullif 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 providedSkullMeta.The
textureargument 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 legacyGameProfileinjection.- Parameters:
skullMeta- the skull meta to mutatetexture- the Mojang texture id (hash)- Returns:
- the same meta instance, for chaining
-