Search in sources :

Example 46 with ICombatManager

use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.

the class UntagTask method run.

@Override
public void run() {
    ICombatManager combatManager = this.plugin.getCombatManager();
    List<Player> playerCombatList = combatManager.getPlayersInCombat();
    for (Player player : playerCombatList) {
        long timeLeftMillis = combatManager.getTimerLeftMillis(player);
        if (timeLeftMillis > 0) {
            continue;
        }
        combatManager.untag(player, UntagReason.EXPIRE);
    }
}
Also used : Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager)

Example 47 with ICombatManager

use of com.github.sirblobman.combatlogx.api.manager.ICombatManager 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 48 with ICombatManager

use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.

the class ListenerDamage method checkTag.

private void checkTag(Entity entity, Entity enemy, TagReason tagReason) {
    if (!(entity instanceof Player)) {
        return;
    }
    Player player = (Player) entity;
    if (hasBypassPermission(player)) {
        return;
    }
    if (!(enemy instanceof LivingEntity)) {
        return;
    }
    LivingEntity livingEnemy = (LivingEntity) enemy;
    EntityType enemyType = livingEnemy.getType();
    if (isDisabled(enemyType)) {
        return;
    }
    SpawnReason spawnReason = getSpawnReason(livingEnemy);
    if (isDisabled(spawnReason)) {
        return;
    }
    ICombatLogX plugin = getCombatLogX();
    ICombatManager combatManager = plugin.getCombatManager();
    combatManager.tag(player, livingEnemy, TagType.MOB, tagReason);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) EntityType(org.bukkit.entity.EntityType) Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) SpawnReason(org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 49 with ICombatManager

use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.

the class HookPlaceholderAPI method getEnemyPlaceholder.

private String getEnemyPlaceholder(Player player, String enemyPlaceholder) {
    ICombatLogX plugin = this.expansion.getPlugin();
    ICombatManager combatManager = plugin.getCombatManager();
    LivingEntity enemy = combatManager.getEnemy(player);
    if (enemy instanceof Player) {
        Player playerEnemy = (Player) enemy;
        String placeholder = String.format(Locale.US, "{%s}", enemyPlaceholder);
        return PlaceholderAPI.setBracketPlaceholders(playerEnemy, placeholder);
    }
    return getUnknownEnemy(plugin, player);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 50 with ICombatManager

use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.

the class ListenerForceField method isSafeSurround.

protected boolean isSafeSurround(Player player, Location location) {
    ICombatManager combatManager = getCombatManager();
    LivingEntity enemy = combatManager.getEnemy(player);
    TagType tagType = getTagType(enemy);
    return isSafeSurround(player, location, tagType);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) TagType(com.github.sirblobman.combatlogx.api.object.TagType) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager)

Aggregations

ICombatManager (com.github.sirblobman.combatlogx.api.manager.ICombatManager)56 Player (org.bukkit.entity.Player)29 LivingEntity (org.bukkit.entity.LivingEntity)24 ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)19 EventHandler (org.bukkit.event.EventHandler)9 Location (org.bukkit.Location)8 LanguageManager (com.github.sirblobman.api.language.LanguageManager)7 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)7 ConfigurationManager (com.github.sirblobman.api.configuration.ConfigurationManager)5 TagType (com.github.sirblobman.combatlogx.api.object.TagType)5 Entity (org.bukkit.entity.Entity)5 Replacer (com.github.sirblobman.api.language.Replacer)4 DecimalFormat (java.text.DecimalFormat)4 Collections (java.util.Collections)4 List (java.util.List)4 Set (java.util.Set)4 OfflinePlayer (org.bukkit.OfflinePlayer)4 EntityType (org.bukkit.entity.EntityType)3 PacketContainer (com.comphenix.protocol.events.PacketContainer)2 EntityHandler (com.github.sirblobman.api.nms.EntityHandler)2