Class Language

java.lang.Object
com.tomkeuper.bedwars.api.configuration.ConfigManager
com.tomkeuper.bedwars.api.language.Language

public class Language extends ConfigManager
  • Constructor Details

    • Language

      public Language(org.bukkit.plugin.Plugin plugin, String iso)
      Constructs a Language object with the specified plugin and ISO language code.
      Parameters:
      plugin - the reference to the plugin
      iso - the ISO language code
  • Method Details

    • setPrefix

      public void setPrefix(String prefix)
      Sets the chat prefix for the language.
      Parameters:
      prefix - the chat prefix to be set
    • setPrefixStatic

      public void setPrefixStatic(String prefix)
      Sets the chat prefix for the language.
      Parameters:
      prefix - the chat prefix to be set
    • getScoreboard

      public static List<String> getScoreboard(org.bukkit.entity.Player p, String path, String alternative)
      Retrieves the scoreboard strings for the specified player in the player's language, with an alternative fallback if the message is not found.
      Parameters:
      p - the player for whom to retrieve the scoreboard strings
      path - the path of the scoreboard strings
      alternative - the alternative string if the specified path is not found
      Returns:
      the retrieved scoreboard strings for the specified player, or the alternative string if not found
    • getScoreboard

      public static List<String> getScoreboard(Language language, String path, String alternative)
      Retrieves the scoreboard strings in the specified language, with an alternative fallback if the message is not found.
      Parameters:
      language - the language from which to retrieve the scoreboard strings
      path - the path of the scoreboard strings
      alternative - the alternative string if the specified path is not found
      Returns:
      the retrieved scoreboard strings in the specified language, or the alternative string if not found
    • getLangName

      public String getLangName()
      Retrieves the display name of the language.
      Returns:
      the display name of the language
    • getMsg

      public static String getMsg(org.bukkit.entity.Player p, String path)
      Retrieves a message in the player's language and applies PlaceholderAPI placeholders.
      Parameters:
      p - the player for whom to retrieve the message
      path - the path of the message
      Returns:
      the retrieved message in the player's language with applied placeholders
    • getMsg

      public static String getMsg(Language language, org.bukkit.entity.Player papiPlayer, String path)
      Retrieves a message in the specific language and applies PlaceholderAPI (Papi) placeholders to the target player.
      Parameters:
      language - the language from which to retrieve the message
      papiPlayer - the target player for the PlaceholderAPI placeholders
      path - the path of the message
      Returns:
      the retrieved message with applied placeholders
    • getPlayerLanguage

      public static Language getPlayerLanguage(org.bukkit.entity.Player p)
      Retrieves the language of a player.
      Parameters:
      p - the player for whom to retrieve the language
      Returns:
      the language of the player
    • getPlayerLanguage

      public static Language getPlayerLanguage(UUID p)
      Retrieves the language of a player.
      Parameters:
      p - the unique identifier of the player for whom to retrieve the language
      Returns:
      the language of the player
    • exists

      public boolean exists(String path)
      Checks if a message is set.
      Parameters:
      path - the path of the message
      Returns:
      true if the message exists, otherwise false
    • getList

      public static List<String> getList(org.bukkit.entity.Player p, String path)
      Retrieves a string list in the player's language.
      Parameters:
      p - the player for whom to retrieve the string list
      path - the path of the string list
      Returns:
      the string list in the player's language
    • saveIfNotExists

      public static void saveIfNotExists(String path, Object data)
      Saves a value to the file if the specified path does not already exist.
      Parameters:
      path - the path at which to save the data if it does not exist
      data - the data to be saved if the path does not already exist
    • m

      public String m(String path)
      Get a color translated message.
      Parameters:
      path - The path to the message
      Returns:
      The message.
    • l

      public List<String> l(String path)
      Get a color translated list.
      Parameters:
      path - The path to the list.
      Returns:
      The list of mesaages.
    • getLangByPlayer

      public static HashMap<UUID,Language> getLangByPlayer()
      Retrieves the language mapping by player UUID.
      Returns:
      the language mapping by player UUID
    • isLanguageExist

      public static boolean isLanguageExist(String iso)
      Checks if a language with the specified ISO code exists.
      Parameters:
      iso - the ISO language code to check
      Returns:
      true if the language with the specified ISO code exists, otherwise false
    • getLang

      public static Language getLang(String iso)
      Retrieves the language with the given ISO code.
      Parameters:
      iso - the ISO language code to retrieve
      Returns:
      the language with the given ISO code, or null if not found
    • getIso

      public String getIso()
      Retrieves the ISO code of the language.
      Returns:
      the ISO code of the language
    • getLanguages

      public static List<Language> getLanguages()
      Retrieves the list of loaded languages.
      Returns:
      the list of loaded languages
    • setupCustomStatsMessages

      public static void setupCustomStatsMessages()
      Save messages for unset stats items.
    • addDefaultStatsMsg

      public void addDefaultStatsMsg(org.bukkit.configuration.file.YamlConfiguration yml, String path, String name, String... lore)
      Adds a default stats message to the YAML configuration.
      Parameters:
      yml - the YAML configuration to which the default message is to be added
      path - the path in the YAML configuration
      name - the name of the stats message
      lore - the lore of the stats message
    • addDefaultMessagesCommandItems

      public static void addDefaultMessagesCommandItems(Language language)
      Creates missing name/lore for items: multi-arena lobby, waiting, spectating. Adds default values to the provided language's YAML configuration.
      Parameters:
      language - the language for which the default values are to be added
    • setupUnSetCategories

      public void setupUnSetCategories()
      Creates message paths for new shop categories and adds default messages to the corresponding YAML configuration.
    • addCategoryMessages

      public static void addCategoryMessages(org.bukkit.configuration.file.YamlConfiguration yml, String categoryName, String invName, String itemName, List<String> itemLore)
      Adds required messages for a shop category to the provided YAML configuration.
      Parameters:
      yml - the YAML configuration to which the messages are to be added
      categoryName - the name of the category
      invName - the name of the inventory
      itemName - the name of the item
      itemLore - the lore of the item
    • addContentMessages

      public static void addContentMessages(org.bukkit.configuration.file.YamlConfiguration yml, String contentName, String categoryName, String itemName, List<String> itemLore)
      Adds required messages for a shop content to the provided YAML configuration.
      Parameters:
      yml - the YAML configuration to which the messages are to be added
      contentName - the name of the content
      categoryName - the name of the category
      itemName - the name of the item
      itemLore - the lore of the item
    • setPlayerLanguage

      public static boolean setPlayerLanguage(UUID uuid, String iso)
      Changes a player's language and refreshes the scoreboard and custom join items accordingly.
      Parameters:
      uuid - the UUID of the player
      iso - the ISO code for the language
      Returns:
      true if the language change was successful, false otherwise
    • getCountDownTitle

      public static String[] getCountDownTitle(Language playerLang, int second)
      Retrieves the countdown title for a specific language and second.
      Parameters:
      playerLang - the language of the player
      second - the countdown second
      Returns:
      an array of two strings representing the countdown title and subtitle
    • setDefaultLanguage

      public static void setDefaultLanguage(Language defaultLanguage)
      Sets the server's default language.
      Parameters:
      defaultLanguage - the default language to be set
    • getDefaultLanguage

      public static Language getDefaultLanguage()
      Retrieves the server's default language.
      Returns:
      the default language of the server