java.lang.Object
com.winterhavenmc.library.messagebuilder.resources.configuration.LanguageProvider
All Implemented Interfaces:
ConfigProvider<LanguageSetting>

public class LanguageProvider extends Object implements ConfigProvider<LanguageSetting>
Provides a dynamic LanguageSetting derived from the plugin's config.yml.

This class implements ConfigProvider to supply a language setting, allowing server operators to specify a localized language file containing plugin messages and other localized strings. It checks for the presence of the language or locale keys in the configuration and uses the first valid match. If neither setting is found, a default of en-US is used. While an IETF language tag is recommended for language file naming, it is not required. This allows server operators to use a custom language file of their own creation, without interfering with existing or provided files.

The configuration value is accessed via a Supplier, allowing dynamic reloading of the setting without requiring object reinitialization. This enables consistent behavior across classes that rely on the selected language configuration.

Note that the .yml suffix is appended to the setting, and therefore should not be included in the language file name setting of the config.yml file.

  • Method Details

    • create

      public static LanguageProvider create(org.bukkit.plugin.Plugin plugin)
      Creates a LanguageProvider by reading the configuration from the given plugin.

      Searches for language or locale keys in the plugin’s configuration, and constructs a LanguageSetting accordingly. Defaults to en-US if no valid key is found.

      Parameters:
      plugin - the plugin providing the configuration
      Returns:
      a new LanguageProvider instance
    • get

      public LanguageSetting get()
      Returns the current LanguageSetting.
      Specified by:
      get in interface ConfigProvider<LanguageSetting>
      Returns:
      the current language setting
    • getName

      public String getName()
      Returns the configured language file name string (e.g., en-US).
      Returns:
      the string representation of the current language file setting