Class LanguageConfig<C>

java.lang.Object
de.themoep.utils.lang.LanguageConfig<C>
Direct Known Subclasses:
BukkitLanguageConfig, BungeeLanguageConfig, SimpleLanguageConfig, SpongeLanguageConfig, VelocityLanguageConfig

public abstract class LanguageConfig<C> extends Object
  • Field Details

    • resourcePath

      protected final String resourcePath
    • configFile

      protected final File configFile
    • saveFile

      protected final boolean saveFile
    • config

      protected C config
    • defaultConfig

      protected C defaultConfig
  • Constructor Details

    • LanguageConfig

      protected LanguageConfig(String resourceFolder, File configFile, String locale)
    • LanguageConfig

      protected LanguageConfig(String resourceFolder, File configFile, String locale, boolean saveFile)
  • Method Details

    • loadConfig

      public abstract void loadConfig()
      Load the config from the file system
    • saveConfigResource

      public abstract boolean saveConfigResource()
      Save the default config resource from the jar file to the file system
      Returns:
      Whether or not the file was saved. If it already existed this will return false
    • contains

      public abstract boolean contains(String key)
      Check if the config contains a certain key
      Parameters:
      key - The key of the string
      Returns:
      true if this config (and not the defaults) has this key, false if not
    • contains

      public abstract boolean contains(String key, boolean checkDefault)
      Check if the config contains a certain key
      Parameters:
      key - The key of the string
      checkDefault - Whether or not to check the default config
      Returns:
      true if this config (and the default) has this key, false if not
    • get

      public abstract String get(String key)
      Get a string from the config by its key
      Parameters:
      key - The key of the string
      Returns:
      The message or an error message if it doesn't exist; never null! (use contains(String) to check existance)
    • getRawConfig

      public abstract C getRawConfig()
      Get the raw config object
      Returns:
      The raw config object
    • get

      public String get(String key, String... replacements)
      Get a string from the config by its key
      Parameters:
      key - The key of the string
      replacements - What to replace the placeholders with. The n-th index is the placeholder, the n+1-th the value.
      Returns:
      The message with the placeholders replaced
    • get

      public String get(String key, Map<String,String> replacements)
      Get a string from the config by its key
      Parameters:
      key - The key of the string
      replacements - What to replace the placeholders with
      Returns:
      The message with the placeholders replaced
    • getLocale

      public String getLocale()
      Get the locale that this language config is for
      Returns:
      The string representation of the locale of this config
    • setDefaults

      public void setDefaults(LanguageConfig<? extends C> defaults)
      Set the default config of this config
      Parameters:
      defaults - The default or config or null if it should not have one