Search in sources :

Example 31 with LanguageManager

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

the class CommandCombatTimer method checkOther.

private void checkOther(Player player, Player target) {
    ICombatLogX plugin = getCombatLogX();
    ICombatManager combatManager = plugin.getCombatManager();
    LanguageManager languageManager = getLanguageManager();
    if (combatManager.isInCombat(target)) {
        double timeLeftMillis = combatManager.getTimerLeftMillis(target);
        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-other", replacer, true);
        return;
    }
    sendMessageWithPrefix(player, "error.target-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)

Example 32 with LanguageManager

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

the class HookPlaceholderAPI method getNewbieHelperPVPStatus.

private String getNewbieHelperPVPStatus(Player player) {
    ICombatLogX plugin = this.expansion.getPlugin();
    LanguageManager languageManager = plugin.getLanguageManager();
    boolean pvp = true;
    Expansion expansion = getNewbieHelper();
    if (expansion != null) {
        NewbieHelperExpansion newbieHelperExpansion = (NewbieHelperExpansion) expansion;
        PVPManager pvpManager = newbieHelperExpansion.getPVPManager();
        pvp = !pvpManager.isDisabled(player);
    }
    String messagePath = ("placeholder.pvp-status." + (pvp ? "enabled" : "disabled"));
    return languageManager.getMessage(player, messagePath, null, true);
}
Also used : NewbieHelperExpansion(combatlogx.expansion.newbie.helper.NewbieHelperExpansion) PVPManager(combatlogx.expansion.newbie.helper.manager.PVPManager) LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) NewbieHelperExpansion(combatlogx.expansion.newbie.helper.NewbieHelperExpansion) PlaceholderExpansion(me.clip.placeholderapi.expansion.PlaceholderExpansion) Expansion(com.github.sirblobman.combatlogx.api.expansion.Expansion)

Example 33 with LanguageManager

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

the class ProtectionStonesListener method onCreateRegion.

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onCreateRegion(PSCreateEvent e) {
    Player player = e.getPlayer();
    if (!isInCombat(player))
        return;
    e.setCancelled(true);
    LanguageManager languageManager = getLanguageManager();
    languageManager.sendMessage(player, "expansion.region-protection.protectionstones.prevent-area-creation", null, true);
}
Also used : Player(org.bukkit.entity.Player) LanguageManager(com.github.sirblobman.api.language.LanguageManager) EventHandler(org.bukkit.event.EventHandler)

Example 34 with LanguageManager

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

the class ProtectionManager method isProtected.

public boolean isProtected(Player player) {
    Validate.notNull(player, "player must not be null!");
    if (player.hasMetadata("NPC")) {
        return false;
    }
    ICombatLogX plugin = this.expansion.getPlugin();
    PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
    YamlConfiguration configuration = playerDataManager.get(player);
    if (!configuration.getBoolean("newbie-helper.protected")) {
        return false;
    }
    long expireTime = configuration.getLong("newbie-helper.protection-expire-time", 0L);
    long systemTime = System.currentTimeMillis();
    if (systemTime < expireTime) {
        return true;
    }
    setProtected(player, false);
    LanguageManager languageManager = this.expansion.getPlugin().getLanguageManager();
    languageManager.sendMessage(player, "expansion.newbie-helper.protection-disabled.expired", null, true);
    return false;
}
Also used : LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager)

Example 35 with LanguageManager

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

the class ListenerLands method disableNewbieProtection.

private void disableNewbieProtection(Player player) {
    NewbieHelperExpansion newbieHelperExpansion = getNewbieHelperExpansion();
    ProtectionManager protectionManager = newbieHelperExpansion.getProtectionManager();
    PVPManager pvpManager = newbieHelperExpansion.getPVPManager();
    if (protectionManager.isProtected(player) || pvpManager.isDisabled(player)) {
        protectionManager.setProtected(player, false);
        pvpManager.setPVP(player, true);
        LanguageManager languageManager = getLanguageManager();
        languageManager.sendMessage(player, "expansion.region-protection.lands.war-disable-newbie-protection", null, true);
    }
}
Also used : 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)

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