Search in sources :

Example 21 with ICombatManager

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

the class PlaceholderHelper method getEnemyLocation.

@Nullable
public static Location getEnemyLocation(ICombatLogX plugin, Player player) {
    ICombatManager combatManager = plugin.getCombatManager();
    LivingEntity enemy = combatManager.getEnemy(player);
    return (enemy == null ? null : enemy.getLocation());
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) Nullable(org.jetbrains.annotations.Nullable)

Example 22 with ICombatManager

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

the class PlaceholderHelper method getEnemyDisplayName.

public static String getEnemyDisplayName(ICombatLogX plugin, Player player) {
    ICombatManager combatManager = plugin.getCombatManager();
    LivingEntity enemy = combatManager.getEnemy(player);
    if (enemy instanceof Player) {
        Player enemyPlayer = (Player) enemy;
        return enemyPlayer.getDisplayName();
    }
    return getEnemyName(plugin, player);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager)

Example 23 with ICombatManager

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

the class PlaceholderHelper method getEnemyHearts.

public static String getEnemyHearts(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);
    if (enemyHeartsRounded > 10L) {
        return Long.toString(enemyHeartsRounded);
    }
    char heartSymbol = '\u2764';
    char[] charArray = new char[(int) enemyHeartsRounded];
    Arrays.fill(charArray, heartSymbol);
    String hearts = new String(charArray);
    return MessageUtility.color("&4" + hearts);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager)

Example 24 with ICombatManager

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

the class PlaceholderHelper method getStatus.

public static String getStatus(ICombatLogX plugin, Player player) {
    ICombatManager combatManager = plugin.getCombatManager();
    LanguageManager languageManager = plugin.getLanguageManager();
    boolean inCombat = combatManager.isInCombat(player);
    String key = ("placeholder.status." + (inCombat ? "fighting" : "idle"));
    return languageManager.getMessage(player, key, null, true);
}
Also used : ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) LanguageManager(com.github.sirblobman.api.language.LanguageManager)

Example 25 with ICombatManager

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

the class PlaceholderHelper method getEnemyHealth.

public static String getEnemyHealth(ICombatLogX plugin, Player player) {
    ICombatManager combatManager = plugin.getCombatManager();
    LivingEntity enemy = combatManager.getEnemy(player);
    if (enemy == null)
        return getUnknownEnemy(plugin, player);
    double enemyHealth = enemy.getHealth();
    DecimalFormat decimalFormat = getDecimalFormat(plugin, player);
    return decimalFormat.format(enemyHealth);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) DecimalFormat(java.text.DecimalFormat)

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