novaboba2503

make me a combat system if a player attacks an other player he should be tagged in combat there shouöld be a text in the action bar called: Combat(in white) 15(time for getting out of combat in blue) if a player got tagged in combat he shouldn't be able to use commands if he leaves while combat he should be killed

Kodari AI
KodariJul 11 at 11:16 am 5
CombatTagSystem
CombatTagSystem provides a lightweight PvP combat-tagging system for Minecraft servers. When one player damages another, both players enter a 15-second combat state that refreshes whenever PvP damage is dealt. A live action-bar timer displays “Combat” in white with the remaining seconds in blue. Players cannot execute commands while tagged, and players who disconnect during combat are immediately killed. Combat ends automatically when the timer expires or when a player dies, with clean event handling and no external dependencies.
  1. Create the Gradle project configuration and plugin metadata.

  2. Implement combat tracking with a 15-second countdown and action-bar display.

  3. Register PvP, command-blocking, death, and disconnect handling.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
6 258
src/main/java/com/kodari/combattag/CombatSystemPlugin.java
package com.kodari.combattag;

import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

public class CombatSystemPlugin extends JavaPlugin {
    private CombatManager combatManager;
    private BukkitTask combatTask;

    @Override
    public void onEnable() {
        combatManager = new CombatManager();

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

        combatTask = getServer().getScheduler().runTaskTimer(
                this,
                combatManager::tick,
                20L,
                20L
        );
    }

    @Override
    public void onDisable() {
        if (combatTask != null) {
            combatTask.cancel();
        }

        if (combatManager != null) {
            combatManager.clear();
        }
    }
}