Class BukkitConfigRepository
java.lang.Object
com.winterhavenmc.library.messagebuilder.adapters.resources.configuration.BukkitConfigRepository
- All Implemented Interfaces:
ConfigProvider<LocaleSetting>,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:
localestring (preferred)languagestring (fallback)Locale.getDefault()(system fallback)
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 Summary
Modifier and TypeMethodDescriptionstatic ConfigRepositorycreate(org.bukkit.plugin.Plugin plugin) Factory method to construct aLocaleProviderusing a plugin's configuration.get()Returns the resolvedLocaleSettingbased on the plugin configuration.language()Returns the resolvedLanguageTagrepresenting the locale tag.locale()Returns the resolvedLocaleobject derived from the configuration.zoneId()Returns the configuredZoneIdif valid, or the system default otherwise.
-
Method Details
-
create
Factory method to construct aLocaleProviderusing a plugin's configuration.This method attempts to extract valid configuration values in the following order:
localesetting (must be a valid BCP-47 language tag)languagesetting (fallback, same format or else ignored)- System default locale and timezone as final fallback
- Parameters:
plugin- the plugin whose configuration will be consulted- Returns:
- a new
LocaleProviderwith dynamic access to locale and time zone settings
-
get
Returns the resolvedLocaleSettingbased on the plugin configuration.- Specified by:
getin interfaceConfigProvider<LocaleSetting>- Specified by:
getin interfaceConfigRepository- Returns:
- a locale setting encapsulating a
LanguageTag
-
languageTag
Returns the resolvedLanguageTagrepresenting the locale tag.- Specified by:
languageTagin interfaceConfigRepository- Returns:
- a valid LanguageTag
-
locale
Returns the resolvedLocaleobject derived from the configuration.- Specified by:
localein interfaceConfigRepository- Returns:
- a Java
Locale
-
zoneId
Returns the configuredZoneIdif valid, or the system default otherwise.- Specified by:
zoneIdin interfaceConfigRepository- Returns:
- the applicable time zone as represented by a
ZoneIdobject.
-
language
- Specified by:
languagein interfaceConfigRepository
-