Search in sources :

Example 66 with ICombatLogX

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

the class ListenerDamage method getDamager.

@Contract("null -> null")
private Entity getDamager(Entity entity) {
    if (entity == null) {
        return null;
    }
    ICombatLogX plugin = getCombatLogX();
    YamlConfiguration configuration = getConfiguration();
    if (configuration.getBoolean("link-projectiles")) {
        entity = EntityHelper.linkProjectile(plugin, entity);
    }
    if (configuration.getBoolean("link-pets")) {
        entity = EntityHelper.linkPet(entity);
    }
    if (configuration.getBoolean("link-tnt")) {
        entity = EntityHelper.linkTNT(entity);
    }
    return entity;
}
Also used : ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) Contract(org.jetbrains.annotations.Contract)

Example 67 with ICombatLogX

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

the class ListenerDamage method getName.

private String getName(Entity entity) {
    ICombatLogX plugin = getCombatLogX();
    if (entity == null) {
        CommandSender console = Bukkit.getConsoleSender();
        LanguageManager languageManager = plugin.getLanguageManager();
        return languageManager.getMessage(console, "placeholder.unknown-enemy", null, true);
    }
    MultiVersionHandler multiVersionHandler = plugin.getMultiVersionHandler();
    EntityHandler entityHandler = multiVersionHandler.getEntityHandler();
    return entityHandler.getName(entity);
}
Also used : MultiVersionHandler(com.github.sirblobman.api.nms.MultiVersionHandler) LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) CommandSender(org.bukkit.command.CommandSender) EntityHandler(com.github.sirblobman.api.nms.EntityHandler)

Example 68 with ICombatLogX

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

the class ListenerUntag method onUntag.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onUntag(PlayerUntagEvent e) {
    Player player = e.getPlayer();
    LivingEntity previousEnemy = e.getPreviousEnemy();
    UntagReason untagReason = e.getUntagReason();
    ICombatLogX plugin = getCombatLogX();
    IPunishManager punishManager = plugin.getPunishManager();
    punishManager.punish(player, untagReason, previousEnemy);
    sendUntagMessage(player, untagReason);
    runUntagCommands(player, previousEnemy);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) IPunishManager(com.github.sirblobman.combatlogx.api.manager.IPunishManager) Player(org.bukkit.entity.Player) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) UntagReason(com.github.sirblobman.combatlogx.api.object.UntagReason) EventHandler(org.bukkit.event.EventHandler)

Example 69 with ICombatLogX

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

the class CustomScoreboard method replacePlaceholders.

private String replacePlaceholders(String string) {
    ScoreboardExpansion expansion = getExpansion();
    ICombatLogX plugin = expansion.getPlugin();
    ICombatManager combatManager = plugin.getCombatManager();
    Player player = getPlayer();
    LivingEntity enemy = combatManager.getEnemy(player);
    String color = MessageUtility.color(string);
    return combatManager.replaceVariables(player, enemy, color);
}
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) ScoreboardExpansion(combatlogx.expansion.scoreboard.ScoreboardExpansion)

Example 70 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX 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)

Aggregations

ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)96 ExpansionManager (com.github.sirblobman.combatlogx.api.expansion.ExpansionManager)24 ICombatManager (com.github.sirblobman.combatlogx.api.manager.ICombatManager)19 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)19 Player (org.bukkit.entity.Player)18 JavaPlugin (org.bukkit.plugin.java.JavaPlugin)14 LivingEntity (org.bukkit.entity.LivingEntity)13 LanguageManager (com.github.sirblobman.api.language.LanguageManager)12 Logger (java.util.logging.Logger)11 ConfigurationManager (com.github.sirblobman.api.configuration.ConfigurationManager)10 MultiVersionHandler (com.github.sirblobman.api.nms.MultiVersionHandler)9 PlayerDataManager (com.github.sirblobman.api.configuration.PlayerDataManager)8 Expansion (com.github.sirblobman.combatlogx.api.expansion.Expansion)8 List (java.util.List)8 Replacer (com.github.sirblobman.api.language.Replacer)6 EntityHandler (com.github.sirblobman.api.nms.EntityHandler)5 State (com.github.sirblobman.combatlogx.api.expansion.Expansion.State)5 Collections (java.util.Collections)5 EventHandler (org.bukkit.event.EventHandler)5 NewbieHelperExpansion (combatlogx.expansion.newbie.helper.NewbieHelperExpansion)4