Search in sources :

Example 1 with TagType

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

the class ListenerDamage method beforeTag.

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void beforeTag(PlayerPreTagEvent e) {
    TagType tagType = e.getTagType();
    if (tagType != TagType.MOB) {
        return;
    }
    LivingEntity enemy = e.getEnemy();
    if (enemy == null || enemy instanceof Player) {
        return;
    }
    EntityType entityType = enemy.getType();
    if (isDisabled(entityType)) {
        e.setCancelled(true);
        return;
    }
    SpawnReason spawnReason = getSpawnReason(enemy);
    if (isDisabled(spawnReason)) {
        e.setCancelled(true);
    }
}
Also used : TagType(com.github.sirblobman.combatlogx.api.object.TagType) LivingEntity(org.bukkit.entity.LivingEntity) EntityType(org.bukkit.entity.EntityType) Player(org.bukkit.entity.Player) SpawnReason(org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason) EventHandler(org.bukkit.event.EventHandler)

Example 2 with TagType

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

the class ListenerForceField method isSafe.

protected boolean isSafe(Player player, Location location) {
    ICombatManager combatManager = getCombatManager();
    LivingEntity enemy = combatManager.getEnemy(player);
    TagType tagType = getTagType(enemy);
    return isSafe(player, location, tagType);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) TagType(com.github.sirblobman.combatlogx.api.object.TagType) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager)

Example 3 with TagType

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

the class ListenerLogger method beforeTag.

@EventHandler(priority = EventPriority.MONITOR)
public void beforeTag(PlayerPreTagEvent e) {
    if (isDisabled("log-pretag"))
        return;
    Player player = e.getPlayer();
    LivingEntity enemy = e.getEnemy();
    TagReason tagReason = e.getTagReason();
    TagType tagType = e.getTagType();
    String format = getLoggerFormat("pretag-format");
    String playerName = player.getName();
    String enemyName = getEntityName(enemy);
    String tagReasonName = tagReason.name();
    String tagTypeName = tagType.name();
    String cancelledString = Boolean.toString(e.isCancelled());
    String message = format.replace("{player}", playerName).replace("{enemy}", enemyName).replace("{tag_reason}", tagReasonName).replace("{tag_type}", tagTypeName).replace("{was_cancelled}", cancelledString);
    appendLog(message);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) TagType(com.github.sirblobman.combatlogx.api.object.TagType) Player(org.bukkit.entity.Player) TagReason(com.github.sirblobman.combatlogx.api.object.TagReason) EventHandler(org.bukkit.event.EventHandler)

Example 4 with TagType

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

the class ListenerLogger method onTag.

@EventHandler(priority = EventPriority.MONITOR)
public void onTag(PlayerTagEvent e) {
    if (isDisabled("log-tag"))
        return;
    Player player = e.getPlayer();
    LivingEntity enemy = e.getEnemy();
    TagReason tagReason = e.getTagReason();
    TagType tagType = e.getTagType();
    String format = getLoggerFormat("tag-format");
    String playerName = player.getName();
    String enemyName = getEntityName(enemy);
    String tagReasonName = tagReason.name();
    String tagTypeName = tagType.name();
    String message = format.replace("{player}", playerName).replace("{enemy}", enemyName).replace("{tag_reason}", tagReasonName).replace("{tag_type}", tagTypeName);
    appendLog(message);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) TagType(com.github.sirblobman.combatlogx.api.object.TagType) Player(org.bukkit.entity.Player) TagReason(com.github.sirblobman.combatlogx.api.object.TagReason) EventHandler(org.bukkit.event.EventHandler)

Example 5 with TagType

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

the class ListenerMythicMobs method beforeTag.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void beforeTag(PlayerPreTagEvent e) {
    TagType tagType = e.getTagType();
    if (tagType != TagType.MYTHIC_MOB) {
        return;
    }
    LivingEntity enemy = e.getEnemy();
    if (enemy == null || !isMythicMob(enemy)) {
        return;
    }
    String mobName = getMythicMobName(enemy);
    if (isNoTag(mobName)) {
        e.setCancelled(true);
    }
}
Also used : TagType(com.github.sirblobman.combatlogx.api.object.TagType) LivingEntity(org.bukkit.entity.LivingEntity) EventHandler(org.bukkit.event.EventHandler)

Aggregations

TagType (com.github.sirblobman.combatlogx.api.object.TagType)12 LivingEntity (org.bukkit.entity.LivingEntity)10 Player (org.bukkit.entity.Player)7 EventHandler (org.bukkit.event.EventHandler)7 ICombatManager (com.github.sirblobman.combatlogx.api.manager.ICombatManager)5 TagReason (com.github.sirblobman.combatlogx.api.object.TagReason)4 ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)3 Location (org.bukkit.Location)3 HashSet (java.util.HashSet)2 UUID (java.util.UUID)2 EntityType (org.bukkit.entity.EntityType)2 ConfigurationManager (com.github.sirblobman.api.configuration.ConfigurationManager)1 LanguageManager (com.github.sirblobman.api.language.LanguageManager)1 Replacer (com.github.sirblobman.api.language.Replacer)1 EntityHandler (com.github.sirblobman.api.nms.EntityHandler)1 MultiVersionHandler (com.github.sirblobman.api.nms.MultiVersionHandler)1 WorldXYZ (com.github.sirblobman.api.object.WorldXYZ)1 Validate (com.github.sirblobman.api.utility.Validate)1 PlayerPreTagEvent (com.github.sirblobman.combatlogx.api.event.PlayerPreTagEvent)1 PlayerReTagEvent (com.github.sirblobman.combatlogx.api.event.PlayerReTagEvent)1