Class CV4_DataConversion
java.lang.Object
valorless.havenbags.configconversion.CV4_DataConversion
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-versionto4and 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
ItemStackentries 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.
- 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 -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheck(@NotNull valorless.valorlessutils.config.Config config) Checks the provided configuration and, ifconfig-version < 4, converts each owner's legacy bag JSON files into YAML files containing bag metadata and serialized content.
-
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, ifconfig-version < 4, converts each owner's legacy bag JSON files into YAML files containing bag metadata and serialized content. The configuration is updated to version4and 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.
- Parameters:
config- non-null plugin configuration used to read/writeconfig-versionand defaults (e.g.,bag-texture).- Throws:
org.bukkit.configuration.InvalidConfigurationException- if a YAML configuration cannot be initialized or persisted during conversion.
-