Item Serializer Utility - C00kier/CookiersLib GitHub Wiki

Utility class for serializing ItemStack objects to a YAML file.


Serialize ItemStack to a specific path in file

Save an item to a specific path in a plugin’s configuration file.

saveItemToFile(JavaPlugin plugin, ItemStack itemToSave, String fileName, String pathInFile)

Parameters:

  • plugin — the JavaPlugin instance used to get the plugin’s data folder and logger
  • itemToSave — the ItemStack object to be saved
  • fileName — the name of the YAML file to save the item in (e.g., "items.yml")
  • pathInFile — the YAML key/path where the item will be stored (e.g., "my_special_item")

Behavior:

  • Automatically creates the file and necessary directories if they do not exist
  • Stores the given item under the specified path in the YAML file
  • Logs success or error messages to the console

Returns:

  • Nothing
  • Logs outcome; prints error stack trace if saving fails