shadab8672

Create a Minecraft Java plugin for Paper 1.21.11 called CombatLog that provides a professional 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 combat timer should be accurate, lightweight, 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.
  • The attacker is in a safe zone.
  • Friendly-fire is disabled.
  • The attack is blocked by another plugin.
  • Fake or cancelled damage events occur.

The plugin must respect all protection plugins and only tag players after a successful PvP hit.

Combat Timer

  • Combat lasts 20 seconds.
  • Every successful PvP hit refreshes the timer back to 20 seconds.
  • Display the remaining combat time above the xp level
  • It should count down from 20 → 0.

Commands Blocked During Combat

While combat tagged, block commands such as:

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

Allow server owners to configure the blocked command list in config.yml.

When a blocked command is used, send:

"§cYou cannot use this command while in combat!"

Combat Logging

If a player disconnects while combat tagged:

  • Instantly kill the player.
  • Drop their entire inventory.
  • Drop all armor.
  • Drop off-hand items.
  • Drop experience.
  • Count the death as a normal PvP death.
  • Optionally broadcast a configurable message.

Example:

"§c<Player> combat logged and died."

Death Handling

If either player dies:

  • Immediately remove both players from combat.
  • Restore their original XP level.
  • Clear all combat data.

Messages

When combat starts:

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

When combat ends:

"§a✔ You are no longer in combat."

When the timer refreshes:

Optionally send an Action Bar message (configurable).

Configuration

Create a config.yml containing:

  • Combat duration.
  • Enable/disable XP level timer.
  • Enable/disable Action Bar timer.
  • Enable/disable broadcast on combat log.
  • Custom messages.
  • Sounds.
  • Titles.
  • Permissions.
  • List of blocked commands.
  • Debug mode.

Performance

  • No unnecessary repeating tasks.
  • No constant entity scanning.
  • Efficient HashMap usage.
  • Automatically clean expired combat data.
  • Optimized for servers with 200+ players.
  • No memory leaks.

Compatibility

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

The plugin must automatically respect and support protection plugins such as:

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

If another plugin cancels the PvP hit, 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 a premium combat log plugin used on large PvP servers, with highly accurate combat detection, excellent performance, proper compatibility with protection plugins, and no false combat tags in PvP-disabled areas.

Kodari AI
KodariJul 5 at 11:48 am 1

I’ll create a comprehensive CombatLog plugin for Paper 1.21.11.

CombatLog
A professional combat-tag system for PvP servers. Features accurate combat detection that respects all protection plugins, configurable 20-second combat timer displayed via XP level and action bar, blocked command list during combat, combat logging punishment with full inventory drop, configurable messages and sounds, and optimized for 200+ player servers with no memory leaks.

Maven Build Instructions

Shell
# Build the plugin
mvn clean package

# Output will be in target/CombatLog-1.0.0.jar
# Place the jar in your server's plugins/ folder and restart

Key Design Decisions

Combat Detection — Listens at MONITOR priority with ignoreCancelled=false. This is the critical hook: any protection plugin (WorldGuard, GriefPrevention, Lands, Towny, etc.) that cancels EntityDamageByEntityEvent will have already done so by MONITOR, so event.isCancelled() returns true and combat is never falsely triggered. No special API integration needed — it works automatically with any plugin that cancels PvP damage.

Timer Display — Runs once per second (20 ticks). Shows remaining seconds as the player’s XP level number with the XP bar filling down. Optionally shows an action bar countdown. When combat expires, the player’s original XP level is restored.

Combat Log Punishment — Drops the player’s entire inventory (main hand, all contents, armor, off-hand) and experience at their logout location, then kills them. The death is processed as a normal PvP death for combat logging statistics.

ConcurrentHashMap — All combat data uses ConcurrentHashMap to prevent ConcurrentModificationException when the timer task iterates while the listener adds/removes entries.

Opponent Tracking — Each CombatData tracks a Set<UUID> of opponents. When a player dies or untags, they’re removed from all opponents’ sets. If an opponent has no remaining opponents, they’re automatically untagged too. This correctly handles multi-player fights.

shadab8672

Make the following changes to the CombatLog plugin:

  1. Remove the large "COMBAT" title displayed in the center of the screen.
  • Do NOT use Titles or Subtitles.
  • Do NOT display any large text in the middle of the screen.
  1. Chat messages:
  • Send "§c⚔ You are now in combat for 20 seconds!" ONLY when the player first enters combat.
  • If the player is already combat tagged and gets hit again, DO NOT send the message again.
  • A new hit should ONLY refresh the timer back to 20 seconds without sending another chat message.
  1. Combat End:
  • When the combat timer reaches 0, send:

"§a✔ You are now out of combat."

  • Send this message only once.
  1. Re-entering Combat:
  • After a player has completely left combat, if they enter combat again later, send the red combat start message again.
  1. Timer Display:
  • Keep the Action Bar timer (e.g., "⚔ Combat: 19 seconds") updating every second.
  • Do NOT display Titles, Subtitles, BossBars, or overlays.
  • Only the Action Bar timer and the chat messages should be visible.
  1. Combat Logic:
  • While already in combat, taking another hit should only reset the timer to 20 seconds.
  • It should NOT resend the combat start chat message.
  • It should NOT replay any titles or sounds unless configured.

The final behavior should match premium combat log plugins:

  • Chat message once when combat starts.
  • Action Bar countdown while in combat.
  • Green chat message once when combat ends.
  • No giant "COMBAT" text on the screen.
  • No repeated chat spam while the player is already in combat.
Kodari AI
KodariJul 5 at 12:53 pm 3

Now I have the full code. Let me analyze what needs to change:

  1. CombatManager.tag() — Only send chat/sound on new tag (not refresh); remove all title calls

  2. CombatManager.untag() — Remove all title calls; update message wording

  3. ConfigManager — Remove all title-related methods

  4. config.yml — Remove entire titles: section; update default untag message

Let me start with the core logic changes

Now update the config.yml — remove the titles section, change the default untag message:

Let me verify the final state of all changed files:

All changes are implemented. Here’s a summary of what was modified:

CombatManager.java — The tag() method now uses playerNewTag/opponentNewTag booleans to track whether each player is entering combat for the first time. Chat messages and sounds are only sent on first entry, not on timer refresh. All title-related code (sendCombatTitle(), sendUntagTitle(), imports for Component, Title, Duration) removed. The untag() method no longer sends titles.

ConfigManager.java — All title-related methods (isTagTitleEnabled, getTagTitle, getTagSubtitle, fade-in/out/stay for both start and end, isUntagTitleEnabled, etc.) removed. Default untag message changed to "&a✔ You are now out of combat.".

config.yml — Entire titles: section removed. Default combat-end message updated to "&a✔ You are now out of combat.".

The final behavior:

  • First hit → red chat message + sound (if enabled) + both players tagged

  • Subsequent hits → only timer reset to 20s, no chat message, no sound replay

  • Every second → action bar shows ⚔ Combat: X seconds + XP level shows remaining time

  • Timer expires → green chat message "✔ You are now out of combat." + sound (if enabled) + XP level restored

  • No titles, subtitles, boss bars, or overlays at any point

shadab8672

Remove xp things

Kodari AI
KodariJul 5 at 12:56 pm 2

Read all files to find XP-related code:

XP-related code is in CombatData (originalXpLevel), CombatManager (level save/restore), CombatTimerTask (xp level display), ConfigManager (xpLevelEnabled), and config.yml. Removing all of it

One remaining javadoc reference in CombatTimerTask.java:

All XP-related code removed. Summary of changes:

  • CombatData.java — removed originalXpLevel field, constructor argument, getter/setter, and javadoc references

  • CombatManager.java — removed player.getLevel()/setLevel()/setExp() calls in tag(), untag(), and handleDeath()

  • ConfigManager.java — removed isXpLevelEnabled() method

  • CombatTimerTask.java — removed entire "Update XP level display" block (setLevel/setExp) from the tick loop

  • config.yml — removed xp-level-timer: section

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

import com.combatlog.combat.CombatManager;
import com.combatlog.config.ConfigManager;
import com.combatlog.listener.CombatListener;
import com.combatlog.listener.PlayerListener;
import com.combatlog.task.CombatTimerTask;
import org.bukkit.plugin.java.JavaPlugin;

public class CombatLogPlugin extends JavaPlugin {

    private ConfigManager configManager;
    private CombatManager combatManager;

    @Override
    public void onEnable() {
        // Save default configuration
        saveDefaultConfig();

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

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

        // Start the repeating timer task (runs every second)
        CombatTimerTask timerTask = new CombatTimerTask(this.combatManager, this.configManager);
        timerTask.runTaskTimer(this, 0L, 20L);

        getLogger().info("CombatLog v" + getDescription().getVersion() + " enabled.");
    }

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

    public ConfigManager getConfigManager() {
        return this.configManager;
    }

    public CombatManager getCombatManager() {
        return this.combatManager;
    }
}