Search in sources :

Example 26 with ICombatManager

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

the class ActionBarUpdater method replacePlaceholders.

private String replacePlaceholders(Player player, String message, long timeLeftMillis) {
    if (message.contains("{bars}")) {
        String bars = getBars(player, timeLeftMillis);
        message = message.replace("{bars}", bars);
    }
    ICombatLogX combatLogX = getCombatLogX();
    ICombatManager combatManager = combatLogX.getCombatManager();
    LivingEntity enemy = combatManager.getEnemy(player);
    return combatManager.replaceVariables(player, enemy, message);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 27 with ICombatManager

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

the class ListenerEssentials method onTeleportRequest.

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onTeleportRequest(TPARequestEvent e) {
    if (isTeleportRequestEnabled())
        return;
    ICombatManager combatManager = getCombatManager();
    LanguageManager languageManager = getLanguageManager();
    CommandSource requester = e.getRequester();
    Player player = requester.getPlayer();
    if (player == null)
        return;
    if (combatManager.isInCombat(player)) {
        sendMessageWithPrefix(player, "expansion.essentials-compatibility.prevent-teleport-request-self", null, true);
        e.setCancelled(true);
        return;
    }
    IUser targetUser = e.getTarget();
    Player target = targetUser.getBase();
    if (target == null)
        return;
    if (combatManager.isInCombat(target)) {
        sendMessageWithPrefix(player, "expansion.essentials-compatibility.prevent-teleport-request-other", null, true);
        e.setCancelled(true);
    // return;
    }
}
Also used : Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) LanguageManager(com.github.sirblobman.api.language.LanguageManager) IUser(net.ess3.api.IUser) CommandSource(com.earth2me.essentials.CommandSource) EventHandler(org.bukkit.event.EventHandler)

Example 28 with ICombatManager

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

the class ListenerTeleport method checkUntag.

private void checkUntag(PlayerTeleportEvent e) {
    printDebug("Checking if player should be untagged by teleport event...");
    if (!shouldUntag()) {
        printDebug("Untag option is set to false, not untagging.");
        return;
    }
    if (e.isCancelled()) {
        printDebug("Event was cancelled, not untagging.");
        return;
    }
    TeleportCause teleportCause = e.getCause();
    if (teleportCause == TeleportCause.UNKNOWN) {
        printDebug("Teleport cause was unknown, not untagging.");
        return;
    }
    Player player = e.getPlayer();
    ICombatManager combatManager = getCombatManager();
    combatManager.untag(player, UntagReason.EXPIRE);
    printDebug("Untagging player due to teleport event.");
}
Also used : Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) TeleportCause(org.bukkit.event.player.PlayerTeleportEvent.TeleportCause)

Example 29 with ICombatManager

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

the class ListenerGameMode method checkUntag.

private void checkUntag(Player player) {
    if (!shouldUntagOnSwitch())
        return;
    ICombatLogX plugin = getCombatLogX();
    ICombatManager combatManager = plugin.getCombatManager();
    combatManager.untag(player, UntagReason.EXPIRE);
}
Also used : ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 30 with ICombatManager

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

the class RegionMoveListener method onMove.

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onMove(PlayerMoveEvent e) {
    Location toLocation = e.getTo();
    if (toLocation == null) {
        return;
    }
    Player player = e.getPlayer();
    ICombatLogX combatLogX = getCombatLogX();
    ICombatManager combatManager = combatLogX.getCombatManager();
    if (!combatManager.isInCombat(player)) {
        return;
    }
    LivingEntity enemy = combatManager.getEnemy(player);
    TagType tagType = getTagType(enemy);
    RegionHandler regionHandler = getRegionHandler();
    if (regionHandler.isSafeZone(player, toLocation, tagType)) {
        Location fromLocation = e.getFrom();
        if (!regionHandler.isSafeZone(player, fromLocation, tagType)) {
            regionHandler.preventEntry(e, player, fromLocation, toLocation);
        }
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) TagType(com.github.sirblobman.combatlogx.api.object.TagType) Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

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