Search in sources :

Example 21 with LanguageManager

use of com.github.sirblobman.api.language.LanguageManager in project CombatLogX by SirBlobman.

the class CombatListener method getMessageWithPrefix.

protected final String getMessageWithPrefix(@Nullable CommandSender sender, @NotNull String key, @Nullable Replacer replacer, boolean color) {
    ICombatLogX plugin = getCombatLogX();
    LanguageManager languageManager = plugin.getLanguageManager();
    String message = languageManager.getMessage(sender, key, replacer, color);
    if (message.isEmpty())
        return "";
    String prefix = languageManager.getMessage(sender, "prefix", null, true);
    return (prefix.isEmpty() ? message : String.format(Locale.US, "%s %s", prefix, message));
}
Also used : LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 22 with LanguageManager

use of com.github.sirblobman.api.language.LanguageManager in project CombatLogX by SirBlobman.

the class CombatLogCommand method getMessageWithPrefix.

protected final String getMessageWithPrefix(@Nullable CommandSender sender, @NotNull String key, @Nullable Replacer replacer, boolean color) {
    ICombatLogX plugin = getCombatLogX();
    LanguageManager languageManager = plugin.getLanguageManager();
    String message = languageManager.getMessage(sender, key, replacer, color);
    if (message.isEmpty())
        return "";
    String prefix = languageManager.getMessage(sender, "prefix", null, true);
    return (prefix.isEmpty() ? message : String.format(Locale.US, "%s %s", prefix, message));
}
Also used : LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 23 with LanguageManager

use of com.github.sirblobman.api.language.LanguageManager in project CombatLogX by SirBlobman.

the class CommandCombatLogXToggle method toggleValue.

private void toggleValue(Player player, String value) {
    ICombatLogX plugin = getCombatLogX();
    PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
    LanguageManager languageManager = getLanguageManager();
    YamlConfiguration playerData = playerDataManager.get(player);
    boolean currentValue = playerData.getBoolean(value, true);
    playerData.set(value, !currentValue);
    playerDataManager.save(player);
    boolean status = playerData.getBoolean(value, true);
    String statusPath = ("placeholder.toggle." + (status ? "enabled" : "disabled"));
    String statusString = languageManager.getMessage(player, statusPath, null, true);
    Replacer replacer = message -> message.replace("{status}", statusString);
    String messagePath = ("command.combatlogx.toggle-" + value);
    sendMessageWithPrefix(player, messagePath, replacer, true);
}
Also used : Arrays(java.util.Arrays) List(java.util.List) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager) Replacer(com.github.sirblobman.api.language.Replacer) Locale(java.util.Locale) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) LanguageManager(com.github.sirblobman.api.language.LanguageManager) CombatLogPlayerCommand(com.github.sirblobman.combatlogx.api.command.CombatLogPlayerCommand) Player(org.bukkit.entity.Player) Collections(java.util.Collections) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) Replacer(com.github.sirblobman.api.language.Replacer) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager)

Example 24 with LanguageManager

use of com.github.sirblobman.api.language.LanguageManager in project CombatLogX by SirBlobman.

the class ListenerDamage method getName.

private String getName(Entity entity) {
    ICombatLogX plugin = getCombatLogX();
    if (entity == null) {
        CommandSender console = Bukkit.getConsoleSender();
        LanguageManager languageManager = plugin.getLanguageManager();
        return languageManager.getMessage(console, "placeholder.unknown-enemy", null, true);
    }
    MultiVersionHandler multiVersionHandler = plugin.getMultiVersionHandler();
    EntityHandler entityHandler = multiVersionHandler.getEntityHandler();
    return entityHandler.getName(entity);
}
Also used : MultiVersionHandler(com.github.sirblobman.api.nms.MultiVersionHandler) LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) CommandSender(org.bukkit.command.CommandSender) EntityHandler(com.github.sirblobman.api.nms.EntityHandler)

Example 25 with LanguageManager

use of com.github.sirblobman.api.language.LanguageManager in project CombatLogX by SirBlobman.

the class CombatManager method getEntityName.

private String getEntityName(Player player, LivingEntity entity) {
    if (entity == null) {
        LanguageManager languageManager = this.plugin.getLanguageManager();
        return languageManager.getMessage(player, "placeholder.unknown-enemy", null, true);
    }
    MultiVersionHandler multiVersionHandler = this.plugin.getMultiVersionHandler();
    EntityHandler entityHandler = multiVersionHandler.getEntityHandler();
    return entityHandler.getName(entity);
}
Also used : MultiVersionHandler(com.github.sirblobman.api.nms.MultiVersionHandler) LanguageManager(com.github.sirblobman.api.language.LanguageManager) EntityHandler(com.github.sirblobman.api.nms.EntityHandler)

Aggregations

LanguageManager (com.github.sirblobman.api.language.LanguageManager)36 ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)12 Player (org.bukkit.entity.Player)12 ConfigurationManager (com.github.sirblobman.api.configuration.ConfigurationManager)9 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)9 ICombatManager (com.github.sirblobman.combatlogx.api.manager.ICombatManager)7 Replacer (com.github.sirblobman.api.language.Replacer)6 NewbieHelperExpansion (combatlogx.expansion.newbie.helper.NewbieHelperExpansion)6 PVPManager (combatlogx.expansion.newbie.helper.manager.PVPManager)6 Collections (java.util.Collections)6 List (java.util.List)6 CommandSender (org.bukkit.command.CommandSender)6 Set (java.util.Set)5 MultiVersionHandler (com.github.sirblobman.api.nms.MultiVersionHandler)4 ProtectionManager (combatlogx.expansion.newbie.helper.manager.ProtectionManager)4 DecimalFormat (java.text.DecimalFormat)4 ArrayList (java.util.ArrayList)4 Arrays (java.util.Arrays)4 Locale (java.util.Locale)4 UUID (java.util.UUID)4