Search in sources :

Example 1 with UntagReason

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

the class ListenerLootProtection method onUntag.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onUntag(PlayerUntagEvent e) {
    LivingEntity previousEnemy = e.getPreviousEnemy();
    if (previousEnemy == null)
        return;
    Player player = e.getPlayer();
    UUID playerId = player.getUniqueId();
    UUID previousEnemyId = previousEnemy.getUniqueId();
    UntagReason untagReason = e.getUntagReason();
    if (untagReason == UntagReason.SELF_DEATH) {
        this.enemyMap.put(playerId, previousEnemyId);
    }
    if (untagReason == UntagReason.ENEMY_DEATH) {
        this.enemyMap.put(previousEnemyId, playerId);
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) UntagReason(com.github.sirblobman.combatlogx.api.object.UntagReason) UUID(java.util.UUID) EventHandler(org.bukkit.event.EventHandler)

Example 2 with UntagReason

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

the class ListenerLogger method onPunish.

@EventHandler(priority = EventPriority.MONITOR)
public void onPunish(PlayerPunishEvent e) {
    if (isDisabled("log-punish"))
        return;
    Player player = e.getPlayer();
    LivingEntity enemy = e.getPreviousEnemy();
    UntagReason untagReason = e.getPunishReason();
    String format = getLoggerFormat("untag-format");
    String playerName = player.getName();
    String enemyName = getEntityName(enemy);
    String untagReasonName = untagReason.name();
    String cancelledString = Boolean.toString(e.isCancelled());
    String message = format.replace("{player}", playerName).replace("{enemy}", enemyName).replace("{punish_reason}", untagReasonName).replace("{was_cancelled}", cancelledString);
    appendLog(message);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) UntagReason(com.github.sirblobman.combatlogx.api.object.UntagReason) EventHandler(org.bukkit.event.EventHandler)

Example 3 with UntagReason

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

the class ListenerPunish method beforePunish.

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void beforePunish(PlayerPunishEvent e) {
    UntagReason untagReason = e.getPunishReason();
    if (shouldPunishForReason(untagReason)) {
        return;
    }
    e.setCancelled(true);
}
Also used : UntagReason(com.github.sirblobman.combatlogx.api.object.UntagReason) EventHandler(org.bukkit.event.EventHandler)

Example 4 with UntagReason

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

the class ListenerUntag method onKick.

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onKick(PlayerKickEvent e) {
    Player player = e.getPlayer();
    if (!isInCombat(player)) {
        return;
    }
    String kickReason = e.getReason();
    UntagReason untagReason = (isKickReasonIgnored(kickReason) ? UntagReason.EXPIRE : UntagReason.KICK);
    ICombatManager combatManager = getCombatManager();
    combatManager.untag(player, untagReason);
}
Also used : Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) UntagReason(com.github.sirblobman.combatlogx.api.object.UntagReason) EventHandler(org.bukkit.event.EventHandler)

Example 5 with UntagReason

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

the class ListenerCommands method onUntag.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onUntag(PlayerUntagEvent e) {
    UntagReason untagReason = e.getUntagReason();
    if (!untagReason.isExpire())
        return;
    Player player = e.getPlayer();
    addCooldown(player);
}
Also used : Player(org.bukkit.entity.Player) UntagReason(com.github.sirblobman.combatlogx.api.object.UntagReason) EventHandler(org.bukkit.event.EventHandler)

Aggregations

UntagReason (com.github.sirblobman.combatlogx.api.object.UntagReason)7 EventHandler (org.bukkit.event.EventHandler)7 Player (org.bukkit.entity.Player)6 LivingEntity (org.bukkit.entity.LivingEntity)4 ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)1 ICombatManager (com.github.sirblobman.combatlogx.api.manager.ICombatManager)1 IPunishManager (com.github.sirblobman.combatlogx.api.manager.IPunishManager)1 UUID (java.util.UUID)1