Class Language
java.lang.Object
com.tomkeuper.bedwars.api.configuration.ConfigManager
com.tomkeuper.bedwars.api.language.Language
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.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.static void
addDefaultMessagesCommandItems
(Language language) Creates missing name/lore for items: multi-arena lobby, waiting, spectating.void
addDefaultStatsMsg
(org.bukkit.configuration.file.YamlConfiguration yml, String path, String name, String... lore) Adds a default stats message to the YAML configuration.boolean
Checks if a message is set.static String[]
getCountDownTitle
(Language playerLang, int second) Retrieves the countdown title for a specific language and second.static Language
Retrieves the server's default language.getIso()
Retrieves the ISO code of the language.static Language
Retrieves the language with the given ISO code.Retrieves the language mapping by player UUID.Retrieves the display name of the language.Retrieves the list of loaded languages.Retrieves a string list in the player's language.static String
Retrieves a message in the specific language and applies PlaceholderAPI (Papi) placeholders to the target player.static String
Retrieves a message in the player's language and applies PlaceholderAPI placeholders.static Language
Retrieves the language of a player.static Language
getPlayerLanguage
(org.bukkit.entity.Player p) Retrieves the language of a player.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.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.static boolean
isLanguageExist
(String iso) Checks if a language with the specified ISO code exists.Get a color translated list.Get a color translated message.static void
saveIfNotExists
(String path, Object data) Saves a value to the file if the specified path does not already exist.static void
setDefaultLanguage
(Language defaultLanguage) Sets the server's default language.static boolean
setPlayerLanguage
(UUID uuid, String iso) Changes a player's language and refreshes the scoreboard and custom join items accordingly.void
Sets the chat prefix for the language.void
setPrefixStatic
(String prefix) Sets the chat prefix for the language.static void
Save messages for unset stats items.void
Creates message paths for new shop categories and adds default messages to the corresponding YAML configuration.Methods inherited from class com.tomkeuper.bedwars.api.configuration.ConfigManager
compareArenaLoc, convertStringToArenaLocation, getArenaLoc, getArenaLocations, getBoolean, getConfigLoc, getDouble, getInt, getList, getName, getString, getYml, isFirstTime, reload, save, saveArenaLoc, saveConfigLoc, set, setName, stringLocationArenaFormat, stringLocationConfigFormat
-
Constructor Details
-
Language
Constructs a Language object with the specified plugin and ISO language code.- Parameters:
plugin
- the reference to the pluginiso
- the ISO language code
-
-
Method Details
-
setPrefix
Sets the chat prefix for the language.- Parameters:
prefix
- the chat prefix to be set
-
setPrefixStatic
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 stringspath
- the path of the scoreboard stringsalternative
- 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
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 stringspath
- the path of the scoreboard stringsalternative
- 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
Retrieves the display name of the language.- Returns:
- the display name of the language
-
getMsg
Retrieves a message in the player's language and applies PlaceholderAPI placeholders.- Parameters:
p
- the player for whom to retrieve the messagepath
- the path of the message- Returns:
- the retrieved message in the player's language with applied placeholders
-
getMsg
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 messagepapiPlayer
- the target player for the PlaceholderAPI placeholderspath
- the path of the message- Returns:
- the retrieved message with applied placeholders
-
getPlayerLanguage
Retrieves the language of a player.- Parameters:
p
- the player for whom to retrieve the language- Returns:
- the language of the player
-
getPlayerLanguage
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
Checks if a message is set.- Parameters:
path
- the path of the message- Returns:
- true if the message exists, otherwise false
-
getList
Retrieves a string list in the player's language.- Parameters:
p
- the player for whom to retrieve the string listpath
- the path of the string list- Returns:
- the string list in the player's language
-
saveIfNotExists
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 existdata
- the data to be saved if the path does not already exist
-
m
Get a color translated message.- Parameters:
path
- The path to the message- Returns:
- The message.
-
l
Get a color translated list.- Parameters:
path
- The path to the list.- Returns:
- The list of mesaages.
-
getLangByPlayer
Retrieves the language mapping by player UUID.- Returns:
- the language mapping by player UUID
-
isLanguageExist
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
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
Retrieves the ISO code of the language.- Returns:
- the ISO code of the 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 addedpath
- the path in the YAML configurationname
- the name of the stats messagelore
- the lore of the stats message
-
addDefaultMessagesCommandItems
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 addedcategoryName
- the name of the categoryinvName
- the name of the inventoryitemName
- the name of the itemitemLore
- 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 addedcontentName
- the name of the contentcategoryName
- the name of the categoryitemName
- the name of the itemitemLore
- the lore of the item
-
setPlayerLanguage
Changes a player's language and refreshes the scoreboard and custom join items accordingly.- Parameters:
uuid
- the UUID of the playeriso
- the ISO code for the language- Returns:
- true if the language change was successful, false otherwise
-
getCountDownTitle
Retrieves the countdown title for a specific language and second.- Parameters:
playerLang
- the language of the playersecond
- the countdown second- Returns:
- an array of two strings representing the countdown title and subtitle
-
setDefaultLanguage
Sets the server's default language.- Parameters:
defaultLanguage
- the default language to be set
-
getDefaultLanguage
Retrieves the server's default language.- Returns:
- the default language of the server
-