Search in sources :

Example 1 with Replacer

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

the class CommandTogglePVP method sendAdminToggleMessage.

private void sendAdminToggleMessage(CommandSender sender, Player target) {
    LanguageManager languageManager = getLanguageManager();
    PVPManager pvpManager = this.expansion.getPVPManager();
    boolean pvpEnabled = !pvpManager.isDisabled(target);
    String targetName = target.getName();
    String pvpStatus = languageManager.getMessage(sender, "placeholder.toggle." + (pvpEnabled ? "enabled" : "disabled"), null, true);
    Replacer replacer = message -> message.replace("{target}", targetName).replace("{status}", pvpStatus);
    sendMessageWithPrefix(sender, "expansion.newbie-helper.togglepvp.admin", replacer, true);
}
Also used : Arrays(java.util.Arrays) CommandSender(org.bukkit.command.CommandSender) CombatLogCommand(com.github.sirblobman.combatlogx.api.command.CombatLogCommand) PVPManager(combatlogx.expansion.newbie.helper.manager.PVPManager) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager) Set(java.util.Set) HashMap(java.util.HashMap) UUID(java.util.UUID) Player(org.bukkit.entity.Player) ArrayList(java.util.ArrayList) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) NewbieHelperExpansion(combatlogx.expansion.newbie.helper.NewbieHelperExpansion) Replacer(com.github.sirblobman.api.language.Replacer) Locale(java.util.Locale) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) Map(java.util.Map) LanguageManager(com.github.sirblobman.api.language.LanguageManager) ProtectionManager(combatlogx.expansion.newbie.helper.manager.ProtectionManager) Collections(java.util.Collections) PVPManager(combatlogx.expansion.newbie.helper.manager.PVPManager) LanguageManager(com.github.sirblobman.api.language.LanguageManager) Replacer(com.github.sirblobman.api.language.Replacer)

Example 2 with Replacer

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

the class CommandTogglePVP method sendCooldownMessage.

private void sendCooldownMessage(Player player) {
    if (!hasCooldown(player)) {
        return;
    }
    long expireMillis = getCooldownExpireMillis(player);
    long systemTimeMillis = System.currentTimeMillis();
    long subtractMillis = (expireMillis - systemTimeMillis);
    long subtractSeconds = TimeUnit.MILLISECONDS.toSeconds(subtractMillis);
    String timeLeftString = Long.toString(subtractSeconds);
    Replacer replacer = message -> message.replace("{time_left}", timeLeftString);
    sendMessageWithPrefix(player, "expansion.newbie-helper.togglepvp.cooldown", replacer, true);
}
Also used : Arrays(java.util.Arrays) CommandSender(org.bukkit.command.CommandSender) CombatLogCommand(com.github.sirblobman.combatlogx.api.command.CombatLogCommand) PVPManager(combatlogx.expansion.newbie.helper.manager.PVPManager) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager) Set(java.util.Set) HashMap(java.util.HashMap) UUID(java.util.UUID) Player(org.bukkit.entity.Player) ArrayList(java.util.ArrayList) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) NewbieHelperExpansion(combatlogx.expansion.newbie.helper.NewbieHelperExpansion) Replacer(com.github.sirblobman.api.language.Replacer) Locale(java.util.Locale) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) Map(java.util.Map) LanguageManager(com.github.sirblobman.api.language.LanguageManager) ProtectionManager(combatlogx.expansion.newbie.helper.manager.ProtectionManager) Collections(java.util.Collections) Replacer(com.github.sirblobman.api.language.Replacer)

Example 3 with Replacer

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

the class CommandTogglePVP method sendToggleMessage.

private void sendToggleMessage(Player player) {
    LanguageManager languageManager = getLanguageManager();
    PVPManager pvpManager = this.expansion.getPVPManager();
    boolean pvpEnabled = !pvpManager.isDisabled(player);
    String pvpStatus = languageManager.getMessage(player, "placeholder.toggle." + (pvpEnabled ? "enabled" : "disabled"), null, true);
    Replacer replacer = message -> message.replace("{status}", pvpStatus);
    sendMessageWithPrefix(player, "expansion.newbie-helper.togglepvp.self", replacer, true);
}
Also used : Arrays(java.util.Arrays) CommandSender(org.bukkit.command.CommandSender) CombatLogCommand(com.github.sirblobman.combatlogx.api.command.CombatLogCommand) PVPManager(combatlogx.expansion.newbie.helper.manager.PVPManager) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager) Set(java.util.Set) HashMap(java.util.HashMap) UUID(java.util.UUID) Player(org.bukkit.entity.Player) ArrayList(java.util.ArrayList) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) NewbieHelperExpansion(combatlogx.expansion.newbie.helper.NewbieHelperExpansion) Replacer(com.github.sirblobman.api.language.Replacer) Locale(java.util.Locale) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) Map(java.util.Map) LanguageManager(com.github.sirblobman.api.language.LanguageManager) ProtectionManager(combatlogx.expansion.newbie.helper.manager.ProtectionManager) Collections(java.util.Collections) PVPManager(combatlogx.expansion.newbie.helper.manager.PVPManager) LanguageManager(com.github.sirblobman.api.language.LanguageManager) Replacer(com.github.sirblobman.api.language.Replacer)

Example 4 with Replacer

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

the class CommandTogglePVP method commandCheck.

private boolean commandCheck(CommandSender sender, String[] args) {
    if (args.length < 1) {
        return false;
    }
    Player target = findTarget(sender, args[0]);
    if (target == null) {
        return true;
    }
    String targetName = target.getName();
    LanguageManager languageManager = getLanguageManager();
    NewbieHelperExpansion expansion = getExpansion();
    ProtectionManager protectionManager = expansion.getProtectionManager();
    PVPManager pvpManager = expansion.getPVPManager();
    boolean targetProtected = protectionManager.isProtected(target);
    boolean targetPvpStatus = !pvpManager.isDisabled(target);
    String placeholderPath0 = ("placeholder.toggle.");
    String placeholderPath1 = (placeholderPath0 + (targetProtected ? "enabled" : "disabled"));
    String placeholderPath2 = (placeholderPath0 + (targetPvpStatus ? "enabled" : "disabled"));
    String protectedString = languageManager.getMessage(sender, placeholderPath1, null, true);
    String pvpStatusString = languageManager.getMessage(sender, placeholderPath2, null, true);
    Replacer replacer = message -> message.replace("{target}", targetName).replace("{protected}", protectedString).replace("{pvp}", pvpStatusString);
    sendMessageWithPrefix(sender, "expansion.newbie-helper.check-format", replacer, true);
    return true;
}
Also used : Arrays(java.util.Arrays) CommandSender(org.bukkit.command.CommandSender) CombatLogCommand(com.github.sirblobman.combatlogx.api.command.CombatLogCommand) PVPManager(combatlogx.expansion.newbie.helper.manager.PVPManager) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager) Set(java.util.Set) HashMap(java.util.HashMap) UUID(java.util.UUID) Player(org.bukkit.entity.Player) ArrayList(java.util.ArrayList) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) NewbieHelperExpansion(combatlogx.expansion.newbie.helper.NewbieHelperExpansion) Replacer(com.github.sirblobman.api.language.Replacer) Locale(java.util.Locale) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) Map(java.util.Map) LanguageManager(com.github.sirblobman.api.language.LanguageManager) ProtectionManager(combatlogx.expansion.newbie.helper.manager.ProtectionManager) Collections(java.util.Collections) Player(org.bukkit.entity.Player) NewbieHelperExpansion(combatlogx.expansion.newbie.helper.NewbieHelperExpansion) PVPManager(combatlogx.expansion.newbie.helper.manager.PVPManager) ProtectionManager(combatlogx.expansion.newbie.helper.manager.ProtectionManager) LanguageManager(com.github.sirblobman.api.language.LanguageManager) Replacer(com.github.sirblobman.api.language.Replacer)

Example 5 with Replacer

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

the class CommandCombatTimer method checkSelf.

private void checkSelf(Player player) {
    ICombatLogX plugin = getCombatLogX();
    ICombatManager combatManager = plugin.getCombatManager();
    LanguageManager languageManager = getLanguageManager();
    if (combatManager.isInCombat(player)) {
        double timeLeftMillis = combatManager.getTimerLeftMillis(player);
        double timeLeftSeconds = (timeLeftMillis / 1_000.0D);
        String decimalFormatString = languageManager.getMessage(player, "decimal-format", null, false);
        DecimalFormat decimalFormat = new DecimalFormat(decimalFormatString);
        String timeLeftString = decimalFormat.format(timeLeftSeconds);
        Replacer replacer = message -> message.replace("{time_left}", timeLeftString);
        sendMessageWithPrefix(player, "command.combat-timer.time-left-self", replacer, true);
        return;
    }
    sendMessageWithPrefix(player, "error.self-not-in-combat", null, true);
}
Also used : List(java.util.List) Replacer(com.github.sirblobman.api.language.Replacer) DecimalFormat(java.text.DecimalFormat) LanguageManager(com.github.sirblobman.api.language.LanguageManager) Set(java.util.Set) CombatLogPlayerCommand(com.github.sirblobman.combatlogx.api.command.CombatLogPlayerCommand) Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) Collections(java.util.Collections) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) DecimalFormat(java.text.DecimalFormat) LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) Replacer(com.github.sirblobman.api.language.Replacer)

Aggregations

Replacer (com.github.sirblobman.api.language.Replacer)15 List (java.util.List)14 Player (org.bukkit.entity.Player)14 Collections (java.util.Collections)12 Set (java.util.Set)12 ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)10 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)10 ConfigurationManager (com.github.sirblobman.api.configuration.ConfigurationManager)9 LanguageManager (com.github.sirblobman.api.language.LanguageManager)8 Map (java.util.Map)8 UUID (java.util.UUID)8 CombatLogCommand (com.github.sirblobman.combatlogx.api.command.CombatLogCommand)7 TimeUnit (java.util.concurrent.TimeUnit)7 CommandSender (org.bukkit.command.CommandSender)7 ICombatManager (com.github.sirblobman.combatlogx.api.manager.ICombatManager)6 UntagReason (com.github.sirblobman.combatlogx.api.object.UntagReason)6 Locale (java.util.Locale)6 Expansion (com.github.sirblobman.combatlogx.api.expansion.Expansion)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5