Class LanguageProvider
- All Implemented Interfaces:
ConfigProvider<LanguageSetting>
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 Summary
Modifier and TypeMethodDescriptionstatic LanguageProvider
create
(org.bukkit.plugin.Plugin plugin) Creates aLanguageProvider
by reading the configuration from the given plugin.get()
Returns the currentLanguageSetting
.getName()
Returns the configured language file name string (e.g.,en-US
).
-
Method Details
-
create
Creates aLanguageProvider
by reading the configuration from the given plugin.Searches for
language
orlocale
keys in the plugin’s configuration, and constructs aLanguageSetting
accordingly. Defaults toen-US
if no valid key is found.- Parameters:
plugin
- the plugin providing the configuration- Returns:
- a new
LanguageProvider
instance
-
get
Returns the currentLanguageSetting
.- Specified by:
get
in interfaceConfigProvider<LanguageSetting>
- Returns:
- the current language setting
-
getName
Returns the configured language file name string (e.g.,en-US
).- Returns:
- the string representation of the current language file setting
-