java.lang.Object
com.winterhavenmc.library.messagebuilder.adapters.resources.configuration.BukkitConfigRepository
All Implemented Interfaces:
ConfigProvider<LocaleSetting>, ConfigRepository

public final class BukkitConfigRepository extends Object implements ConfigRepository
A configuration-backed provider for both Locale and ZoneId settings.

This class wraps a LocaleSetting and provides a centralized access point for retrieving the user's desired locale and timezone, both of which are commonly required for time/date formatting and localization operations throughout the plugin.

The LocaleProvider resolves configuration values from the plugin config.yml in the following order:

The timezone configuration value, if present and valid, is resolved into a ZoneId. If the value is invalid or missing, the system default time zone is used.

See Also:
  • Method Details

    • create

      public static ConfigRepository create(org.bukkit.plugin.Plugin plugin)
      Factory method to construct a LocaleProvider using a plugin's configuration.

      This method attempts to extract valid configuration values in the following order:

      1. locale setting (must be a valid BCP-47 language tag)
      2. language setting (fallback, same format or else ignored)
      3. System default locale and timezone as final fallback
      Parameters:
      plugin - the plugin whose configuration will be consulted
      Returns:
      a new LocaleProvider with dynamic access to locale and time zone settings
    • get

      public LocaleSetting get()
      Returns the resolved LocaleSetting based on the plugin configuration.
      Specified by:
      get in interface ConfigProvider<LocaleSetting>
      Specified by:
      get in interface ConfigRepository
      Returns:
      a locale setting encapsulating a LanguageTag
    • languageTag

      public LanguageTag languageTag()
      Returns the resolved LanguageTag representing the locale tag.
      Specified by:
      languageTag in interface ConfigRepository
      Returns:
      a valid LanguageTag
    • locale

      public Locale locale()
      Returns the resolved Locale object derived from the configuration.
      Specified by:
      locale in interface ConfigRepository
      Returns:
      a Java Locale
    • zoneId

      public ZoneId zoneId()
      Returns the configured ZoneId if valid, or the system default otherwise.
      Specified by:
      zoneId in interface ConfigRepository
      Returns:
      the applicable time zone as represented by a ZoneId object.
    • language

      public String language()
      Specified by:
      language in interface ConfigRepository