Search in sources :

Example 1 with CustomMessageKey

use of com.archyx.aureliumskills.lang.CustomMessageKey in project AureliumSkills by Archy-X.

the class LootHandler method attemptSendMessage.

private void attemptSendMessage(Player player, Loot loot) {
    String message = loot.getMessage();
    if (message != null && !message.equals("")) {
        PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
        if (playerData == null)
            return;
        Locale locale = playerData.getLocale();
        // Try to get message as message key
        CustomMessageKey key = new CustomMessageKey(message);
        String finalMessage = Lang.getMessage(key, locale);
        // Use input as message if fail
        if (finalMessage == null) {
            finalMessage = message;
        }
        // Replace placeholders
        if (plugin.isPlaceholderAPIEnabled()) {
            finalMessage = PlaceholderAPI.setPlaceholders(player, finalMessage);
        }
        player.sendMessage(finalMessage);
    }
}
Also used : Locale(java.util.Locale) PlayerData(com.archyx.aureliumskills.data.PlayerData) CustomMessageKey(com.archyx.aureliumskills.lang.CustomMessageKey)

Example 2 with CustomMessageKey

use of com.archyx.aureliumskills.lang.CustomMessageKey in project AureliumSkills by Archy-X.

the class MessagedReward method attemptAsMessageKey.

/**
 * Attempts to use the input as a message key. If a matching translation for the key is found, it will return the translation.
 * Otherwise it will return the key.
 */
private String attemptAsMessageKey(String potentialKey, Player player, Locale locale, Skill skill, int level) {
    CustomMessageKey key = new CustomMessageKey(potentialKey);
    String message = Lang.getMessage(key, locale);
    if (message == null) {
        message = potentialKey;
    }
    return replacePlaceholders(message, player, skill, level);
}
Also used : CustomMessageKey(com.archyx.aureliumskills.lang.CustomMessageKey)

Aggregations

CustomMessageKey (com.archyx.aureliumskills.lang.CustomMessageKey)2 PlayerData (com.archyx.aureliumskills.data.PlayerData)1 Locale (java.util.Locale)1