Class ConfigValidation2

java.lang.Object
valorless.havenbags.ConfigValidation2

public final class ConfigValidation2 extends Object
Handles configuration validation.

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 Type
    Method
    Description
    static valorless.valorlessutils.config.Config
    Reads the bundled default Config file from the JAR, then registers every leaf key as a validation entry — with its default value and any associated comments — before calling Config.validate().
    static valorless.valorlessutils.config.Config
    validateAndGetConfig(String conf, List<String> ignoredKeys)
    Reads the bundled default Config file from the JAR, then registers every leaf key as a validation entry — with its default value and any associated comments — before calling Config.validate().

    Methods inherited from class java.lang.Object

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

    • validateAndGetConfig

      public static valorless.valorlessutils.config.Config validateAndGetConfig(String conf)
      Reads the bundled default Config file from the JAR, then registers every leaf key as a validation entry — with its default value and any associated comments — before calling Config.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 default Config file from the JAR, then registers every leaf key as a validation entry — with its default value and any associated comments — before calling Config.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