shadab8672

Create a Minecraft Java plugin for Paper 1.21.11 called CombatLog 2.0 that provides a premium combat-tag system for PvP servers.

Main Goal

When two players successfully damage each other in PvP, both players enter combat for 20 seconds.

The plugin should be lightweight, accurate, and optimized for multiplayer servers.

Combat Detection

Combat should ONLY start when:

  • A player successfully damages another player.
  • The damage event is NOT cancelled by another plugin.
  • PvP is actually allowed at that location.
  • The hit deals real damage.

Combat should NOT start if:

  • PvP is disabled by WorldGuard or any protection plugin.
  • The damage event is cancelled.
  • Friendly-fire is disabled.
  • The attacker is inside a safe zone.
  • The attack is blocked by another plugin.
  • Fake or cancelled damage events occur.

The plugin must automatically respect all protection plugins.

Combat Timer

  • Combat lasts 20 seconds.
  • Every successful PvP hit refreshes the timer back to 20 seconds.
  • DO NOT use the player's XP level as the timer.
  • DO NOT modify the player's XP level or XP progress bar.
  • Instead, display the countdown directly above the XP bar (using an Action Bar style message positioned above the XP bar, like premium PvP servers).
  • The countdown should appear like:

⚔ Combat: 20s

⚔ Combat: 19s

⚔ Combat: 18s

...

⚔ Combat: 1s

  • Update the timer every second.
  • Remove the timer immediately when combat ends.

Combat Messages

When a player enters combat for the FIRST time:

Send ONLY ONCE:

§c⚔ You are now in combat for 20 seconds!

If the player is already combat tagged:

  • Do NOT send the message again.
  • Do NOT spam chat.
  • Simply refresh the timer back to 20 seconds.

When combat ends:

Send ONLY ONCE:

§a✔ You are now out of combat.

If the player later enters combat again:

  • Show the red combat message again.

Screen Display

  • Do NOT use Titles.
  • Do NOT use Subtitles.
  • Do NOT use BossBars.
  • Do NOT display giant "COMBAT" text in the middle of the screen.
  • The ONLY combat indicator should be the timer displayed above the XP bar.

Commands Blocked During Combat

While combat tagged, block commands such as:

  • /home
  • /spawn
  • /lobby
  • /hub
  • /warp
  • /rtp
  • /tpa
  • /tpaccept
  • /tpdeny
  • /back
  • /suicide

The blocked command list must be configurable in config.yml.

If a player uses one:

§cYou cannot use this command while in combat!

Combat Logging

If a player disconnects while combat tagged:

  • Instantly kill the player.
  • Drop all inventory.
  • Drop armor.
  • Drop off-hand items.
  • Drop experience.
  • Count it as a normal PvP death.
  • Optionally broadcast:

§c<Player> combat logged and died.

Death Handling

If either player dies:

  • Remove combat immediately.
  • Remove the combat timer.
  • Clear all combat data.

Configuration

Include config.yml with:

  • Combat duration.
  • Enable/disable combat timer.
  • Enable/disable combat messages.
  • Enable/disable logout broadcast.
  • Blocked commands.
  • Sounds.
  • Permissions.
  • Debug mode.

Performance

  • No unnecessary repeating tasks.
  • No constant entity scanning.
  • Efficient HashMap usage.
  • Automatic cleanup.
  • Optimized for servers with 200+ players.
  • No memory leaks.

Compatibility

  • Paper 1.21.11
  • Java 21
  • Maven project.
  • Include plugin.yml.

Automatically support:

  • WorldGuard
  • GriefPrevention
  • Lands
  • Residence
  • Towny
  • KingdomsX
  • Any plugin that cancels EntityDamageByEntityEvent.

If another plugin cancels the PvP damage event, combat MUST NOT start.

Code Quality

  • Clean OOP design.
  • Modular package structure.
  • Well-commented code.
  • No deprecated APIs.
  • Fully configurable.
  • Production-ready.
  • Compiles without errors.

Output Required

Generate the complete plugin source code including:

  • plugin.yml
  • config.yml
  • pom.xml
  • All Java classes.
  • Maven build instructions.

The finished plugin should behave like premium combat log plugins used on large PvP servers:

  • Combat starts only on successful PvP hits.
  • No combat in safe zones.
  • No repeated chat spam.
  • No giant COMBAT title.
  • Timer displayed above the XP bar only.
  • Timer refreshes silently when hit again.
  • Green chat message when combat ends.
  • Lightweight, fast, and production-ready.
Kodari AI
KodariJul 5 at 1:02 pm 1

I’ll create the CombatLog 2.0 plugin — a premium combat-tag system for Paper PvP servers.

CombatLog
A lightweight combat-tag system for Paper PvP servers. Automatically tags both players on successful PvP hits, displays a countdown timer above the XP bar (no titles or boss bars), blocks configured commands during combat, handles combat-log disconnects with inventory drops, and respects all protection plugins via cancelled event detection. Fully configurable with sounds, permissions, and debug mode.

Starting with the build configuration and resource files:

Now the Java classes. I’ll build them in dependency order — utilities → managers → listeners → main plugin.

All files are created. Build instructions:

Shell
cd combatlog/
mvn clean package

Output JAR: target/CombatLog-2.0.jar — drop into your server’s plugins/ folder and restart.

Plugin architecture summary:

Layer
Class
Role
Entry
CombatLogPlugin
Registers managers, listeners, commands
Config
ConfigManager
Reads/reloads
config.yml
, exposes typed getters
Core
CombatManager
Combat map (
UUID→endTime
), single 20-tick repeating task, enter/silent-remove/expire
Detection
CombatListener
MONITOR + ignoreCancelled
— fires only on uncancelled PvP hits, tags both players
Player
PlayerListener
Quit → combat log kill + broadcast; Death → silent cleanup; Command blocking
Command
CombatLogCommand
/combatlog check
and
/combatlog reload
Util
MessageUtil
Legacy
§
color codes → Adventure
Component

Key design decisions:

  1. MONITOR + ignoreCancelled on the damage listener — if WorldGuard, GriefPrevention, Lands, or any plugin cancels the event, combat never starts. No soft-dependency imports needed.

  2. Single repeating task (not per-player) — iterates the HashMap once per second. Scales to 200+ players with zero overhead.

  3. Silent refresh — enterCombat() only sends the red message on first entry. Subsequent hits silently extend the timer.

  4. silentRemoveCombat() for death — avoids the awkward “you’re out of combat” message right after dying.

  5. Combat log drops inventory/armor/offhand/XP, kills via setHealth(0), and broadcasts the configurable message with <player> placeholder.

  6. Command blocking uses HIGHEST priority and checks for exact match + subcommand prefix to avoid false positives.

  7. No Titles, BossBars, or XP bar manipulation — only action bar text above the XP bar, exactly as specified.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
10 761
src/main/java/com/combatlog/CombatLogPlugin.java
package com.combatlog;

import com.combatlog.command.CombatLogCommand;
import com.combatlog.config.ConfigManager;
import com.combatlog.manager.CombatManager;
import com.combatlog.listener.CombatListener;
import com.combatlog.listener.PlayerListener;
import org.bukkit.plugin.java.JavaPlugin;

/**
 * CombatLog 2.0 — Premium combat tag system for PvP servers.
 *
 * Lightweight, event-driven combat detection with action-bar timer,
 * configurable command blocking, and combat-log handling.
 */
public class CombatLogPlugin extends JavaPlugin {

    private ConfigManager configManager;
    private CombatManager combatManager;

    @Override
    public void onEnable() {
        // Save default config if it doesn't exist
        saveDefaultConfig();

        // Initialize managers
        this.configManager = new ConfigManager(this);
        this.combatManager = new CombatManager(this, this.configManager);
        this.combatManager.start();

        // Register event listeners
        getServer().getPluginManager().registerEvents(new CombatListener(this.combatManager), this);
        getServer().getPluginManager().registerEvents(new PlayerListener(this, this.combatManager, this.configManager), this);

        // Register commands
        getCommand("combatlog").setExecutor(new CombatLogCommand(this, this.combatManager, this.configManager));

        getLogger().info("CombatLog 2.0 enabled." + (configManager.isDebug() ? " (debug mode)" : ""));
    }

    @Override
    public void onDisable() {
        if (this.combatManager != null) {
            this.combatManager.stop();
        }
        getLogger().info("CombatLog 2.0 disabled.");
    }

    public ConfigManager getConfigManager() {
        return configManager;
    }

    public CombatManager getCombatManager() {
        return combatManager;
    }
}