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.