Class CustomData

java.lang.Object
valorless.havenbags.features.CustomData

public class CustomData extends Object
Manages applying configured "custom data" entries onto HavenBags items.

Custom data can be written either to:

  • NBT via NBT (typically for compatibility with systems reading raw item NBT), or
  • PDC (PersistentDataContainer) via Bukkit's PersistentDataContainer API.

The definitions are loaded from the plugin config under the custom-data section. Entries are grouped by bag size (slot count). When a bag is updated, only models matching the bag's size (stored in PDC under key "size") are applied.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Model representing one configured custom-data entry for a specific bag size.
    static enum 
    Storage backend for a configured data entry.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Loads dataModels from Main.config.
    static void
    Clears the cached models and reloads them from config.
    static void
    updateBag(org.bukkit.inventory.ItemStack bag)
    Applies all configured custom-data entries relevant to this bag's size.

    Methods inherited from class java.lang.Object

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

    • CustomData

      public CustomData()
  • Method Details

    • init

      public static void init()
      Loads dataModels from Main.config.

      Expected config structure:

       custom-data:
         "9":
           example:
             plugin: "HavenBags"
             key: "some_key"
             type: "NBT" | "PDC"
             value: ...
             pdc-type: "STRING" | "INTEGER" | "DOUBLE" | "BOOLEAN" | "FLOAT" | "UUID"   # only for PDC
       
    • reload

      public static void reload()
      Clears the cached models and reloads them from config.
    • updateBag

      public static void updateBag(org.bukkit.inventory.ItemStack bag)
      Applies all configured custom-data entries relevant to this bag's size.

      The bag size is read from the bag's PDC key "size".

      Parameters:
      bag - the bag item to update (mutated in-place)