Search in sources :

Example 41 with ICombatManager

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

the class CommandCombatLogXUntag method execute.

@Override
protected boolean execute(CommandSender sender, String[] args) {
    if (!checkPermission(sender, "combatlogx.command.combatlogx.untag", true)) {
        return true;
    }
    if (args.length < 1) {
        return false;
    }
    Player target = findTarget(sender, args[0]);
    if (target == null) {
        return true;
    }
    String targetName = target.getName();
    Replacer replacer = message -> message.replace("{target}", targetName);
    ICombatLogX plugin = getCombatLogX();
    ICombatManager combatManager = plugin.getCombatManager();
    if (!combatManager.isInCombat(target)) {
        sendMessageWithPrefix(sender, "error.target-not-in-combat", replacer, true);
        return true;
    }
    combatManager.untag(target, UntagReason.EXPIRE);
    sendMessageWithPrefix(sender, "command.combatlogx.untag-player", replacer, true);
    return true;
}
Also used : UntagReason(com.github.sirblobman.combatlogx.api.object.UntagReason) List(java.util.List) CommandSender(org.bukkit.command.CommandSender) CombatLogCommand(com.github.sirblobman.combatlogx.api.command.CombatLogCommand) Replacer(com.github.sirblobman.api.language.Replacer) Set(java.util.Set) Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) Collections(java.util.Collections) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) Replacer(com.github.sirblobman.api.language.Replacer) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 42 with ICombatManager

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

the class ListenerConfiguration method runTagCommands.

private void runTagCommands(Player player, LivingEntity enemy) {
    ConfigurationManager configurationManager = getPluginConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("commands.yml");
    ICombatLogX plugin = getCombatLogX();
    ICombatManager combatManager = getCombatManager();
    List<String> tagCommandList = configuration.getStringList("tag-command-list");
    if (tagCommandList.isEmpty())
        return;
    for (String tagCommand : tagCommandList) {
        String replacedCommand = combatManager.replaceVariables(player, enemy, tagCommand);
        if (replacedCommand.startsWith("[PLAYER]")) {
            String command = replacedCommand.substring("[PLAYER]".length());
            CommandHelper.runAsPlayer(plugin, player, command);
            continue;
        }
        if (replacedCommand.startsWith("[OP]")) {
            String command = replacedCommand.substring("[OP]".length());
            CommandHelper.runAsOperator(plugin, player, command);
            continue;
        }
        CommandHelper.runAsConsole(plugin, replacedCommand);
    }
}
Also used : ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Example 43 with ICombatManager

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

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

the class PunishManager method runPunishCommands.

private void runPunishCommands(Player player, LivingEntity previousEnemy, List<String> punishCommandList) {
    if (punishCommandList.isEmpty()) {
        return;
    }
    ICombatManager combatManager = this.plugin.getCombatManager();
    for (String punishCommand : punishCommandList) {
        String replacedCommand = combatManager.replaceVariables(player, previousEnemy, punishCommand);
        if (replacedCommand.startsWith("[PLAYER]")) {
            String command = replacedCommand.substring("[PLAYER]".length());
            CommandHelper.runAsPlayer(this.plugin, player, command);
            continue;
        }
        if (replacedCommand.startsWith("[OP]")) {
            String command = replacedCommand.substring("[OP]".length());
            CommandHelper.runAsOperator(this.plugin, player, command);
            continue;
        }
        CommandHelper.runAsConsole(this.plugin, replacedCommand);
    }
}
Also used : ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager)

Example 45 with ICombatManager

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

the class TimerUpdateTask method update.

private void update(Player player) {
    ICombatManager combatManager = this.plugin.getCombatManager();
    long timeLeftMillis = combatManager.getTimerLeftMillis(player);
    if (timeLeftMillis <= 0L) {
        return;
    }
    Set<TimerUpdater> timerUpdaterSet = getTimerUpdaters();
    for (TimerUpdater timerUpdater : timerUpdaterSet) {
        timerUpdater.update(player, timeLeftMillis);
    }
}
Also used : ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) TimerUpdater(com.github.sirblobman.combatlogx.api.object.TimerUpdater)

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