Search in sources :

Example 1 with TagReason

use of com.github.sirblobman.combatlogx.api.object.TagReason 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 2 with TagReason

use of com.github.sirblobman.combatlogx.api.object.TagReason 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 3 with TagReason

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

the class CombatManager method sendTagMessage.

private void sendTagMessage(Player player, LivingEntity enemy, TagType tagType, TagReason tagReason) {
    if (tagType == TagType.DAMAGE) {
        return;
    }
    String enemyName = getEntityName(player, enemy);
    String enemyType = getEntityType(player, enemy);
    String tagReasonString = tagReason.name().toLowerCase(Locale.US);
    String tagTypeString = tagType.name().toLowerCase(Locale.US);
    Replacer replacer = message -> message.replace("{enemy}", enemyName).replace("{mob_type}", enemyType);
    String languagePath = ("tagged." + tagReasonString + "." + tagTypeString);
    this.plugin.sendMessageWithPrefix(player, languagePath, replacer, true);
}
Also used : PlayerTagEvent(com.github.sirblobman.combatlogx.api.event.PlayerTagEvent) PlayerReTagEvent(com.github.sirblobman.combatlogx.api.event.PlayerReTagEvent) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager) Player(org.bukkit.entity.Player) EntityHandler(com.github.sirblobman.api.nms.EntityHandler) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ITimerManager(com.github.sirblobman.combatlogx.api.manager.ITimerManager) Validate(com.github.sirblobman.api.utility.Validate) Replacer(com.github.sirblobman.api.language.Replacer) Locale(java.util.Locale) Map(java.util.Map) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) MultiVersionHandler(com.github.sirblobman.api.nms.MultiVersionHandler) Bukkit(org.bukkit.Bukkit) PlayerPreTagEvent(com.github.sirblobman.combatlogx.api.event.PlayerPreTagEvent) PlayerUntagEvent(com.github.sirblobman.combatlogx.api.event.PlayerUntagEvent) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) UUID(java.util.UUID) EntityType(org.bukkit.entity.EntityType) LivingEntity(org.bukkit.entity.LivingEntity) PermissionAttachmentInfo(org.bukkit.permissions.PermissionAttachmentInfo) TagReason(com.github.sirblobman.combatlogx.api.object.TagReason) Collectors(java.util.stream.Collectors) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) OfflinePlayer(org.bukkit.OfflinePlayer) UntagReason(com.github.sirblobman.combatlogx.api.object.UntagReason) TagType(com.github.sirblobman.combatlogx.api.object.TagType) List(java.util.List) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) PlaceholderHelper(com.github.sirblobman.combatlogx.api.utility.PlaceholderHelper) Entry(java.util.Map.Entry) LanguageManager(com.github.sirblobman.api.language.LanguageManager) TimerType(com.github.sirblobman.combatlogx.api.object.TimerType) PluginManager(org.bukkit.plugin.PluginManager) Replacer(com.github.sirblobman.api.language.Replacer)

Example 4 with TagReason

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

the class ListenerLogger method onReTag.

@EventHandler(priority = EventPriority.MONITOR)
public void onReTag(PlayerReTagEvent e) {
    if (isDisabled("log-retag"))
        return;
    Player player = e.getPlayer();
    LivingEntity enemy = e.getEnemy();
    TagReason tagReason = e.getTagReason();
    TagType tagType = e.getTagType();
    String format = getLoggerFormat("retag-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)

Aggregations

TagReason (com.github.sirblobman.combatlogx.api.object.TagReason)4 TagType (com.github.sirblobman.combatlogx.api.object.TagType)4 LivingEntity (org.bukkit.entity.LivingEntity)4 Player (org.bukkit.entity.Player)4 EventHandler (org.bukkit.event.EventHandler)3 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 Validate (com.github.sirblobman.api.utility.Validate)1 ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)1 PlayerPreTagEvent (com.github.sirblobman.combatlogx.api.event.PlayerPreTagEvent)1 PlayerReTagEvent (com.github.sirblobman.combatlogx.api.event.PlayerReTagEvent)1 PlayerTagEvent (com.github.sirblobman.combatlogx.api.event.PlayerTagEvent)1 PlayerUntagEvent (com.github.sirblobman.combatlogx.api.event.PlayerUntagEvent)1 ICombatManager (com.github.sirblobman.combatlogx.api.manager.ICombatManager)1 ITimerManager (com.github.sirblobman.combatlogx.api.manager.ITimerManager)1 TimerType (com.github.sirblobman.combatlogx.api.object.TimerType)1 UntagReason (com.github.sirblobman.combatlogx.api.object.UntagReason)1