nawajahmad.

I need a plugin for Combat Log such that when a player combat logs, their data gets saved to Discord.

Kodari AI
KodariMay 31 at 8:52 am 8
CombatLogTracker
A Minecraft plugin that detects combat logging — when players disconnect while in combat — and instantly reports the event to a Discord channel via webhook. Tracks PvP combat tags with a configurable duration, captures offender data (name, location, health, held item, armor), and sends a rich Discord embed. Includes an admin command to manually check a player's combat status and full config support for webhook URL, tag duration, and embed appearance.

Planning classes before writing:

  • CombatLogPlugin — main class, initializes managers

  • ConfigManager — wraps config.yml values

  • CombatManager — tracks tagged players via Map<UUID, BukkitTask>

  • CombatListener — handles damage tagging, quit/kick detection

  • DiscordWebhook — builds and POSTs embed payload via HttpURLConnection

  • CombatCommand — /combatlog admin command


Here’s what was built:

How it works:

  1. Any PvP damage tags both the attacker and victim for the configured duration (default 15s)

  2. If either disconnects while tagged → combat log detected → Discord webhook fires async

  3. On rejoin, the offender receives a configurable warning message

Discord embed includes: Player name, UUID, world, XYZ coordinates, health, food level, held item, and full armor breakdown.

Setup steps:

  1. Paste your Discord webhook URL into config.yml under webhook-url

  2. Optionally adjust combat-tag-duration (seconds) and embed appearance

  3. Grant combatlog.bypass to staff/admins who should be exempt

Commands:

  • /combatlog check <player> — see if someone is currently combat tagged

  • /combatlog reload — reload config without restart

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
9 480
src/main/java/com/kodari/combatlog/CombatLogPlugin.java
package com.kodari.combatlog;

import com.kodari.combatlog.command.CombatCommand;
import com.kodari.combatlog.listener.CombatListener;
import com.kodari.combatlog.manager.CombatManager;
import com.kodari.combatlog.manager.ConfigManager;
import org.bukkit.plugin.java.JavaPlugin;

public class CombatLogPlugin extends JavaPlugin {

    private ConfigManager configManager;
    private CombatManager combatManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        this.configManager = new ConfigManager(this);
        this.combatManager = new CombatManager(this);

        getServer().getPluginManager().registerEvents(new CombatListener(this), this);

        CombatCommand executor = new CombatCommand(this);
        getCommand("combatlog").setExecutor(executor);
        getCommand("combatlog").setTabCompleter(executor);

        getLogger().info("CombatLogTracker enabled.");
    }

    @Override
    public void onDisable() {
        combatManager.cancelAll();
        getLogger().info("CombatLogTracker disabled.");
    }

    public ConfigManager cfg() {
        return configManager;
    }

    public CombatManager getCombatManager() {
        return combatManager;
    }
}