Class ModelDataCompat

java.lang.Object
tech.guilhermekaua.spigotboot.core.spigot.utils.ModelDataCompat

public final class ModelDataCompat extends Object
Version-safe item model data helpers for the Bukkit/Spigot API surface.
  • Method Details

    • setLegacyData

      public static boolean setLegacyData(org.bukkit.inventory.ItemStack item, Integer data)
      Sets the legacy durability/data value used by old pre-flattening item variants.
      Parameters:
      item - the item to mutate
      data - the data value, or null to leave it unchanged
      Returns:
      true when the value was applied
    • setCustomModelData

      public static boolean setCustomModelData(org.bukkit.inventory.meta.ItemMeta meta, Integer data)
      Sets integer custom model data. On 1.21.5+ this writes the equivalent single float into the custom model data component when that API is available; on 1.14-1.21.4 it falls back to ItemMeta#setCustomModelData(Integer) reflectively.
      Parameters:
      meta - the meta to mutate
      data - the custom model data value, or null to leave it unchanged
      Returns:
      true when a compatible API accepted the value
    • setCustomModelDataComponent

      public static boolean setCustomModelDataComponent(org.bukkit.inventory.meta.ItemMeta meta, List<Float> floats, List<Boolean> flags, List<String> strings, List<org.bukkit.Color> colors)
      Sets the custom model data component values introduced for the component-backed model data API. Any null list is left unchanged on the component snapshot.
      Parameters:
      meta - the meta to mutate
      floats - range dispatch float values, or null to leave unchanged
      flags - condition flag values, or null to leave unchanged
      strings - select string values, or null to leave unchanged
      colors - tint colors, or null to leave unchanged
      Returns:
      true when the component API is present and accepted the values
    • setItemModel

      public static boolean setItemModel(org.bukkit.inventory.meta.ItemMeta meta, String itemModel)
      Sets the direct item model key added by newer Spigot/Paper APIs.
      Parameters:
      meta - the meta to mutate
      itemModel - a namespaced key such as my_pack:bronze_sword; keys without a namespace use minecraft
      Returns:
      true when the item model API is present and accepted the key