Search in sources :

Example 31 with ICombatManager

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

the class RegionVulnerableListener method onDamage.

@EventHandler(priority = EventPriority.HIGHEST)
public void onDamage(EntityDamageByEntityEvent e) {
    RegionHandler regionHandler = this.regionExpansion.getRegionHandler();
    NoEntryMode noEntryMode = regionHandler.getNoEntryMode();
    if (noEntryMode != NoEntryMode.VULNERABLE)
        return;
    Entity damaged = e.getEntity();
    Player player = getPlayerOrPassenger(damaged);
    if (player == null)
        return;
    if (isInCombat(player)) {
        ICombatManager combatManager = getCombatManager();
        LivingEntity enemy = combatManager.getEnemy(player);
        TagType tagType = getTagType(enemy);
        Location location = player.getLocation();
        if (regionHandler.isSafeZone(player, location, tagType)) {
            e.setCancelled(false);
        }
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) TagType(com.github.sirblobman.combatlogx.api.object.TagType) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) NoEntryMode(com.github.sirblobman.combatlogx.api.object.NoEntryMode) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 32 with ICombatManager

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

the class PlaceholderHelper method getTimeLeftDecimal.

public static String getTimeLeftDecimal(ICombatLogX plugin, Player player) {
    LanguageManager languageManager = plugin.getLanguageManager();
    ICombatManager combatManager = plugin.getCombatManager();
    double millisLeft = combatManager.getTimerLeftMillis(player);
    if (millisLeft <= 0.0D)
        return languageManager.getMessage(player, "placeholder.time-left-zero", null, true);
    double secondsLeft = (millisLeft / 1_000.0D);
    DecimalFormat decimalFormat = getDecimalFormat(plugin, player);
    return decimalFormat.format(secondsLeft);
}
Also used : ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) DecimalFormat(java.text.DecimalFormat) LanguageManager(com.github.sirblobman.api.language.LanguageManager)

Example 33 with ICombatManager

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

the class PlaceholderHelper method getEnemyHealthRounded.

public static String getEnemyHealthRounded(ICombatLogX plugin, Player player) {
    ICombatManager combatManager = plugin.getCombatManager();
    LivingEntity enemy = combatManager.getEnemy(player);
    if (enemy == null)
        return getUnknownEnemy(plugin, player);
    double enemyHealth = enemy.getHealth();
    long enemyHealthRounded = Math.round(enemyHealth);
    return Long.toString(enemyHealthRounded);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager)

Example 34 with ICombatManager

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

the class PlaceholderHelper method getTimeLeft.

public static String getTimeLeft(ICombatLogX plugin, Player player) {
    ICombatManager combatManager = plugin.getCombatManager();
    int secondsLeft = combatManager.getTimerLeftSeconds(player);
    if (secondsLeft > 0)
        return Integer.toString(secondsLeft);
    LanguageManager languageManager = plugin.getLanguageManager();
    return languageManager.getMessage(player, "placeholder.time-left-zero", null, true);
}
Also used : ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) LanguageManager(com.github.sirblobman.api.language.LanguageManager)

Example 35 with ICombatManager

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

the class PlaceholderHelper method getEnemyHeartsCount.

public static String getEnemyHeartsCount(ICombatLogX plugin, Player player) {
    ICombatManager combatManager = plugin.getCombatManager();
    LivingEntity enemy = combatManager.getEnemy(player);
    if (enemy == null)
        return getUnknownEnemy(plugin, player);
    double enemyHealth = enemy.getHealth();
    double enemyHearts = (enemyHealth / 2.0D);
    long enemyHeartsRounded = Math.round(enemyHearts);
    return Long.toString(enemyHeartsRounded);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) 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