Class LanguageManagerCore<S,C>

java.lang.Object
de.themoep.utils.lang.LanguageManagerCore<S,C>
Type Parameters:
S - The command sender type
C - The configuration type
Direct Known Subclasses:
LanguageManager, LanguageManager, LanguageManager, LanguageManager, LanguageManager

public abstract class LanguageManagerCore<S,C> extends Object
The core language manager
  • Field Details

    • filePrefix

      protected final String filePrefix
    • fileSuffix

      protected final String fileSuffix
    • saveFiles

      protected final boolean saveFiles
  • Constructor Details

  • Method Details

    • loadConfigs

      public abstract void loadConfigs()
    • loadConfigs

      protected void loadConfigs(Class<?> pluginClass, LangLogger logger, Function<String,LanguageConfig<C>> configCreator)
    • addConfig

      public LanguageConfig<C> addConfig(LanguageConfig<C> config)
      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

      public LanguageConfig<C> getConfig(String locale)
      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

      public LanguageConfig<C> getConfig(S sender)
      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

      public Collection<LanguageConfig<C>> getConfigs()
      Get all defined language configs
      Returns:
      A collection of defined language configs
    • getDefaultLocale

      public String 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

      public void setDefaultLocale(String locale)
      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

      public String getPlaceholderPrefix()
      Get the prefix of placeholders for replacements
      Returns:
      The placeholder prefix
    • setPlaceholderPrefix

      public void setPlaceholderPrefix(String placeholderPrefix)
      Set the prefix of placeholders for replacements
      Parameters:
      placeholderPrefix - The placeholder prefix
    • getPlaceholderSuffix

      public String getPlaceholderSuffix()
      Get the suffix of placeholders for replacements
      Returns:
      The placeholder suffix
    • setPlaceholderSuffix

      public void setPlaceholderSuffix(String placeholderSuffix)
      Set the suffix of placeholders for replacements
      Parameters:
      placeholderSuffix - The placeholder suffix
    • getDefaultConfig

      public LanguageConfig<C> 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

      public String 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

      public File getFolder()
      Get the folder that the language files are in
      Returns:
      The folder that is used to store this manager's config files
    • setProvider

      public void setProvider(LanguageProvider<S> provider) throws IllegalArgumentException
      Set the provider for the player's language
      Parameters:
      provider - The provider
      Throws:
      IllegalArgumentException - when provider is null
    • getProvider

      public LanguageProvider<S> getProvider()
      Get the specified language provider
      Returns:
      The specified provider or null if not set