Package de.themoep.utils.lang
Class LanguageManagerCore<S,C>
java.lang.Object
de.themoep.utils.lang.LanguageManagerCore<S,C>
- Type Parameters:
S
- The command sender typeC
- The configuration type
- Direct Known Subclasses:
LanguageManager
,LanguageManager
,LanguageManager
,LanguageManager
,LanguageManager
The core language manager
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
LanguageManagerCore
(String defaultLocale, String resourceFolder, File folder, LanguageProvider<S> provider, String filePrefix, String fileSuffix, boolean saveFiles, LanguageConfig<C>... configs) -
Method Summary
Modifier and TypeMethodDescriptionaddConfig
(LanguageConfig<C> config) Add a new language config for a specific localeGet a language config for a specific localeGet a language config for a sender object using the specified providerGet all defined language configsGet the default language configGet the default locale to use when no special one was specified or the one requested doesn't exist.Get the folder that the language files are inGet the prefix of placeholders for replacementsGet the suffix of placeholders for replacementsGet the specified language providerGet the path to the folder that contains the default language configs inside of the jarabstract void
protected void
loadConfigs
(Class<?> pluginClass, LangLogger logger, Function<String, LanguageConfig<C>> configCreator) void
setDefaultLocale
(String locale) Set the default locale to use when no special one was specified or the one requested doesn't exist.void
setPlaceholderPrefix
(String placeholderPrefix) Set the prefix of placeholders for replacementsvoid
setPlaceholderSuffix
(String placeholderSuffix) Set the suffix of placeholders for replacementsvoid
setProvider
(LanguageProvider<S> provider) Set the provider for the player's language
-
Field Details
-
filePrefix
-
fileSuffix
-
saveFiles
protected final boolean saveFiles
-
-
Constructor Details
-
LanguageManagerCore
protected LanguageManagerCore(String defaultLocale, String resourceFolder, File folder, LanguageProvider<S> provider, String filePrefix, String fileSuffix, boolean saveFiles, LanguageConfig<C>... configs)
-
-
Method Details
-
loadConfigs
public abstract void loadConfigs() -
loadConfigs
protected void loadConfigs(Class<?> pluginClass, LangLogger logger, Function<String, LanguageConfig<C>> configCreator) -
addConfig
Add a new language config for a specific locale- Parameters:
config
- The language config that holds all messages for the specified locale- Returns:
- The previous language config if it existed or
null
if not
-
getConfig
Get a language config for a specific locale- Parameters:
locale
- The string representation of the locale to add the config for- Returns:
- The language config that holds all messages for the specified locale. If no config is defined for that locale it will return the default locale.
-
getConfig
Get a language config for a sender object using the specified provider- Parameters:
sender
- The sender to get the language config for- Returns:
- The language config that holds all messages for the locale specified by the provider. If no config is defined for that locale it will return the default locale.
-
getConfigs
Get all defined language configs- Returns:
- A collection of defined language configs
-
getDefaultLocale
Get the default locale to use when no special one was specified or the one requested doesn't exist. Also used as the default config when querying a message by its key.- Returns:
- The default locale string
-
setDefaultLocale
Set the default locale to use when no special one was specified or the one requested doesn't exist. Also used as the default config when querying a message by its key. If set to null it will use the first define language config.- Parameters:
locale
- The default locale string
-
getPlaceholderPrefix
Get the prefix of placeholders for replacements- Returns:
- The placeholder prefix
-
setPlaceholderPrefix
Set the prefix of placeholders for replacements- Parameters:
placeholderPrefix
- The placeholder prefix
-
getPlaceholderSuffix
Get the suffix of placeholders for replacements- Returns:
- The placeholder suffix
-
setPlaceholderSuffix
Set the suffix of placeholders for replacements- Parameters:
placeholderSuffix
- The placeholder suffix
-
getDefaultConfig
Get the default language config- Returns:
- The default language config. If none was defined it will return the first found language. If none is found then it returns null.
-
getResourceFolder
Get the path to the folder that contains the default language configs inside of the jar- Returns:
- The path to the folder, should never be null or empty!
-
getFolder
Get the folder that the language files are in- Returns:
- The folder that is used to store this manager's config files
-
setProvider
Set the provider for the player's language- Parameters:
provider
- The provider- Throws:
IllegalArgumentException
- when provider is null
-
getProvider
Get the specified language provider- Returns:
- The specified provider or null if not set
-