Class ConfigValidation2
Rather than hardcoding default values, this class reads the bundled
Config from the JAR at runtime and registers every leaf
key it finds as a Config.addValidationEntry(java.lang.String, java.lang.Object) call, comparing it
against the user's live config so any missing keys are written with their
defaults.
Comments are preserved: block comments attached to a YAML section header are forwarded to the first leaf discovered inside that section; block and inline comments on leaf nodes are forwarded directly to their own entry.
-
Method Summary
Modifier and TypeMethodDescriptionstatic valorless.valorlessutils.config.ConfigvalidateAndGetConfig(String conf) Reads the bundled defaultConfigfile from the JAR, then registers every leaf key as a validation entry — with its default value and any associated comments — before callingConfig.validate().static valorless.valorlessutils.config.ConfigvalidateAndGetConfig(String conf, List<String> ignoredKeys) Reads the bundled defaultConfigfile from the JAR, then registers every leaf key as a validation entry — with its default value and any associated comments — before callingConfig.validate().
-
Method Details
-
validateAndGetConfig
Reads the bundled defaultConfigfile from the JAR, then registers every leaf key as a validation entry — with its default value and any associated comments — before callingConfig.validate().Block comments that sit above a YAML section header are collected and prepended to the first leaf key encountered in that section so they are not silently discarded.
- Parameters:
conf- the path to the config file to validate (e.g."abyss/config.yml")- Returns:
- a Config instance with all validation entries registered and validated
-
validateAndGetConfig
public static valorless.valorlessutils.config.Config validateAndGetConfig(String conf, List<String> ignoredKeys) Reads the bundled defaultConfigfile from the JAR, then registers every leaf key as a validation entry — with its default value and any associated comments — before callingConfig.validate().Block comments that sit above a YAML section header are collected and prepended to the first leaf key encountered in that section so they are not silently discarded.
- Parameters:
conf- the path to the config file to validate (e.g."abyss/config.yml")ignoredKeys- keys (or key prefixes) to skip during validation — useful for template/example entries that should not be re-added to the user's config- Returns:
- a Config instance with all validation entries registered and validated
-