Search in sources :

Example 51 with ICombatManager

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

the class ListenerForceField method updateForceField.

protected void updateForceField(Player player) {
    ICombatManager combatManager = getCombatManager();
    if (!combatManager.isInCombat(player)) {
        return;
    }
    Location playerLocation = player.getLocation();
    if (isSafe(player, playerLocation)) {
        return;
    }
    if (isSafeMode())
        safeForceField(player);
    else
        this.forceFieldExecutor.submit(() -> safeForceField(player));
}
Also used : ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) Location(org.bukkit.Location)

Example 52 with ICombatManager

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

the class ListenerForceField method safeForceField.

private void safeForceField(Player player) {
    ICombatManager combatManager = getCombatManager();
    LivingEntity enemy = combatManager.getEnemy(player);
    safeForceField(player, enemy);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager)

Example 53 with ICombatManager

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

the class ListenerForceField method updateForceField.

protected void updateForceField(Player player, LivingEntity enemy) {
    ICombatManager combatManager = getCombatManager();
    if (!combatManager.isInCombat(player)) {
        return;
    }
    Location playerLocation = player.getLocation();
    if (isSafe(player, playerLocation)) {
        return;
    }
    if (isSafeMode())
        safeForceField(player, enemy);
    else
        this.forceFieldExecutor.submit(() -> safeForceField(player, enemy));
}
Also used : ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) Location(org.bukkit.Location)

Example 54 with ICombatManager

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

the class ListenerForceField method onMove.

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onMove(PlayerMoveEvent e) {
    Location toLocation = e.getTo();
    if (toLocation == null || !isEnabled()) {
        return;
    }
    Player player = e.getPlayer();
    if (canBypass(player)) {
        return;
    }
    ICombatManager combatManager = getCombatManager();
    if (!combatManager.isInCombat(player)) {
        return;
    }
    Location fromLocation = e.getFrom();
    if (Objects.equals(WorldXYZ.from(toLocation), WorldXYZ.from(fromLocation))) {
        return;
    }
    if (isSafe(player, toLocation)) {
        return;
    }
    updateForceField(player);
}
Also used : Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 55 with ICombatManager

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

the class ListenerTeleport method checkEnderPearlRetag.

private void checkEnderPearlRetag(PlayerTeleportEvent e) {
    printDebug("Checking if ender pearl should re-tag player...");
    if (!shouldRetag()) {
        printDebug("Re-tag option is disabled.");
        return;
    }
    if (e.isCancelled()) {
        printDebug("Event was cancelled, ignoring.");
        return;
    }
    TeleportCause teleportCause = e.getCause();
    if (teleportCause != TeleportCause.ENDER_PEARL) {
        printDebug("Teleport cause was not ENDER_PEARL, ignoring.");
        return;
    }
    Player player = e.getPlayer();
    ICombatManager combatManager = getCombatManager();
    LivingEntity enemy = combatManager.getEnemy(player);
    combatManager.tag(player, enemy, TagType.UNKNOWN, TagReason.UNKNOWN);
    printDebug("Player will be re-tagged. Done.");
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) TeleportCause(org.bukkit.event.player.PlayerTeleportEvent.TeleportCause)

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