senorbitor

need a Minecraft plugin for combat logging. When a player enters combat, a 20-second combat timer should start. After 20 seconds without fighting, the player should automatically leave combat.

If a player leaves the server before the 20 seconds end, it should count as a combat log. The player should not die in-game when they leave.

When a combat log happens, the combat log data should be sent to Discord. The message should not show the player’s location, but it should show which player they were fighting against when they logged out.

Kodari AI
KodariMar 16 at 7:26 am 7,753 (v2)

I’ll create a combat logging plugin with Discord webhook integration for combat log notifications.

CombatLogger
A comprehensive combat logging system that tracks PvP combat and prevents players from escaping fights by logging out. When players engage in combat, a 20-second timer begins. If a player disconnects during this timer, it's logged as a combat log and reported to Discord with details about who they were fighting. Includes configurable combat duration, Discord webhook integration, and admin commands for monitoring combat status.

Combat logging plugin created successfully! The system tracks PvP combat with a configurable 20-second timer, prevents player deaths on disconnect, and sends detailed Discord webhook notifications showing who was fighting whom (without location data). Includes admin commands, bypass permissions, and full Folia/Paper compatibility via FoliaLib.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
11 588
src/main/java/com/combatlogger/CombatLogger.java
package com.combatlogger;

import com.combatlogger.commands.CombatCommand;
import com.combatlogger.listeners.CombatListener;
import com.combatlogger.managers.CombatManager;
import com.combatlogger.managers.ConfigManager;
import com.combatlogger.utils.DiscordWebhook;
import com.tcoded.folialib.FoliaLib;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class CombatLogger extends JavaPlugin {

    private FoliaLib foliaLib;
    private ConfigManager configManager;
    private CombatManager combatManager;
    private DiscordWebhook discordWebhook;

    @Override
    public void onEnable() {
        foliaLib = new FoliaLib(this);
        
        configManager = new ConfigManager(this);
        configManager.loadConfig();
        
        discordWebhook = new DiscordWebhook(this);
        
        combatManager = new CombatManager(this);
        combatManager.startCombatCheckTask();
        
        getServer().getPluginManager().registerEvents(new CombatListener(this), this);
        
        getCommand("combat").setExecutor(new CombatCommand(this));
        
        getLogger().info("CombatLogger has been enabled!");
    }

    @Override
    public void onDisable() {
        if (foliaLib != null) {
            foliaLib.getScheduler().cancelAllTasks();
        }
        
        if (combatManager != null) {
            combatManager.clearAllCombat();
        }
        
        getLogger().info("CombatLogger has been disabled!");
    }
}