L

⚔️ Combat Logging is Disabled! ⚔️

If you log out while in combat, your character will be instantly killed.

You enter combat when you hit another player or when another player hits you.

When you enter combat, a bold red message will appear in chat: “YOU’VE ENTERED COMBAT — DO NOT LOG OFF!”

If you are still in combat and you hit someone or get hit again, the 20-second timer will reset.

After 20 seconds without fighting, you will leave combat and see a bold green message: “YOU’VE LEFT COMBAT — YOU CAN SAFELY LOG OFF.”

Kodari AI
KodariApr 24 at 1:55 pm 2,898 (v2)
CombatLogger
Punishes players who disconnect during PvP combat. Players enter combat when they hit or are hit by another player, receiving a bold red chat alert. A 20-second inactivity timer resets on each hit. If a player logs out while in combat, their NPC remains in the world and is instantly killed, dropping their inventory. After 20 seconds of no combat, players receive a bold green exit message. Fully configurable timer duration via config.yml.

Plan:

  • CombatLogger — main plugin, registers events and commands

  • CombatManager — tracks who is in combat and manages timers

  • CombatListener — handles entity damage, player quit, and player death events

  • config.yml — combat duration setting

  • plugin.yml — plugin manifest

When a tagged player disconnects, their inventory is dropped at their location and setHealth(0) kills them immediately, removing them from combat tracking via the death event.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
6 195
src/main/java/com/combat/logger/CombatLogger.java
package com.combat.logger;

import com.combat.logger.combat.CombatListener;
import com.combat.logger.combat.CombatManager;
import org.bukkit.plugin.java.JavaPlugin;

public class CombatLogger extends JavaPlugin {

    private CombatManager combatManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        this.combatManager = new CombatManager(this);
        getServer().getPluginManager().registerEvents(new CombatListener(this, combatManager), this);
    }

    @Override
    public void onDisable() {
        combatManager.cancelAll();
    }

    public CombatManager getCombatManager() {
        return combatManager;
    }
}