Interface LanguageManager
public interface LanguageManager
The language system. Get it from
EssentialsCAPI.getLanguageManager().
Messages are sent in each players own language. Add your own keys with
registerMessages(Plugin, String...) and prefix them with your
addon name, like "myverycoolplugin.somemessage".-
Method Summary
Modifier and TypeMethodDescriptionvoidSends a message to all players with the permission and to the console.net.kyori.adventure.text.ComponentGets a message in the sender's language.net.kyori.adventure.text.ComponentGets a message in the sender's language.Gets all loaded languages.Gets the default language from the config.getLanguage(org.bukkit.command.CommandSender sender) Gets the language a sender sees messages in.getPlayerLanguage(UUID playerId) Gets the language a player picked with /language.Gets a message as a raw MiniMessage string.booleanChecks if a key exists.voidregisterMessages(org.bukkit.plugin.Plugin plugin, String... languageCodes) Registers your addon's messages.voidSends a message to the sender.voidSends a message to the sender.
-
Method Details
-
get
net.kyori.adventure.text.Component get(org.bukkit.command.CommandSender sender, String key, Map<String, String> placeholders) Gets a message in the sender's language.- Parameters:
sender- the sender, or null for the default languagekey- the message keyplaceholders- placeholder values, may be null- Returns:
- the message, never null
-
get
Gets a message in the sender's language.- Parameters:
sender- the sender, or null for the default languagekey- the message key- Returns:
- the message, never null
-
getRaw
Gets a message as a raw MiniMessage string.- Parameters:
sender- the sender, or null for the default languagekey- the message keyplaceholders- placeholder values, may be null- Returns:
- the raw message, never null
-
send
Sends a message to the sender.- Parameters:
sender- the senderkey- the message keyplaceholders- placeholder values, may be null
-
send
Sends a message to the sender.- Parameters:
sender- the senderkey- the message key
-
broadcast
Sends a message to all players with the permission and to the console.- Parameters:
permission- the permissionkey- the message keyplaceholders- placeholder values, may be null
-
hasKey
Checks if a key exists.- Parameters:
key- the message key- Returns:
- true if found
-
registerMessages
Registers your addon's messages. Copies lang/<code>.json from your jar to your plugin folder and adds any new keys. Call it in onEnable.- Parameters:
plugin- your pluginlanguageCodes- the language files in your jar, for example "en_US"
-
getLanguage
Gets the language a sender sees messages in.- Parameters:
sender- the sender, or null for the default language- Returns:
- the language code, for example "en_US"
-
getPlayerLanguage
Gets the language a player picked with /language.- Parameters:
playerId- the player UUID- Returns:
- the language code, or null if not set
-
getDefaultLanguage
String getDefaultLanguage()Gets the default language from the config.- Returns:
- the language code, never null
-
getAvailableLanguages
Gets all loaded languages.- Returns:
- language codes, never null
-