Class CV4_DataConversion

java.lang.Object
valorless.havenbags.configconversion.CV4_DataConversion

public class CV4_DataConversion extends Object
Handles migration of HavenBags per-bag data from legacy JSON files to the current YAML-based format when an outdated config-version is detected. When invoked against a configuration with version lower than 4, this converter will:
  • Update config-version to 4 and persist the change.
  • Enumerate bag owners and scan <dataFolder>/bags/<owner> for bag data files that are not YAML.
  • Deserialize each legacy JSON file into a list of ItemStack entries and write a new YAML file with structured metadata and content.
  • Log conversion progress and a final summary of converted and failed files. Legacy files are intentionally not deleted.
Notes:
  • Performs filesystem I/O and may take noticeable time on large data sets.
  • Not thread-safe; intended to run during plugin startup before other components access the data directory.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    check(@NotNull valorless.valorlessutils.config.Config config)
    Checks the provided configuration and, if config-version < 4, converts each owner's legacy bag JSON files into YAML files containing bag metadata and serialized content.

    Methods inherited from class java.lang.Object

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

    • CV4_DataConversion

      public CV4_DataConversion()
  • Method Details

    • check

      @DoNotCall("Internal Use Only") public static void check(@NotNull @NotNull valorless.valorlessutils.config.Config config) throws org.bukkit.configuration.InvalidConfigurationException
      Checks the provided configuration and, if config-version < 4, converts each owner's legacy bag JSON files into YAML files containing bag metadata and serialized content. The configuration is updated to version 4 and saved prior to performing file conversions. Side effects:
      • Updates and saves the supplied configuration.
      • Creates or overwrites YAML files under <dataFolder>/bags/<owner>/<bag>.yml.
      • Emits log messages for progress, warnings, and errors.
      • Does not remove legacy JSON files; manual cleanup may be required.
      Thread-safety: not thread-safe. Call during initialization only.
      Parameters:
      config - non-null plugin configuration used to read/write config-version and defaults (e.g., bag-texture).
      Throws:
      org.bukkit.configuration.InvalidConfigurationException - if a YAML configuration cannot be initialized or persisted during conversion.