technobladeneverdiesflyhigh
📎 1 file 1,614 chars
📄
pasted-code-1782569342215.txt
txt 21 lines
▶
Please create a complete, lightweight CombatLog plugin for a Paper/Spigot Minecraft server.

Requirements:
1. **Combat Tagging System**:
   - Listen for EntityDamageByEntityEvent. If a player damages another player, tag both players in combat for exactly 15 seconds.
   - Use a HashMap to track player UUIDs and their system time expiration (`HashMap`).
   - When tagged, send an action bar message to both players: "§cYou are now in combat! Do not log out."
   - Every second, if they check or if it updates, show them the remaining time. When the 15 seconds run out, send an action bar message: "§aYou are no longer in combat."

2. **Command Blacklist**:
   - Listen for PlayerCommandPreprocessEvent.
   - If a player is currently tagged in combat, block them from using specific escape commands: `/home`, `/spawn`, `/tp`, `/tpa`, `/warp`, or `/pay`.
   - Cancel the event and send them a message: "§cYou cannot use commands while in combat!"

3. **Log-Out Punishment**:
   - Listen for PlayerQuitEvent.
   - If a player's UUID is still present and active in the combat tag HashMap when they leave the server, forcefully execute `player.setHealth(0.0);` to kill them instantly before they disconnect, dropping all their inventory items.
   - Send a global server-wide broadcast message: "§c[CombatLog] " + player.getName() + " combat logged and was killed!"
   - Cleanly remove their UUID from the HashMap so the data doesn't leak.

Provide the complete Java code, a standard plugin.yml, and a Maven pom.xml file. Keep the data structures lightweight with zero repeating task lag.
Kodari AI
KodariJun 27 at 2:12 pm 1

I’ll create a lightweight CombatLog plugin with combat tagging, command blocking, and logout punishment.

CombatLog
A lightweight combat logging prevention plugin for Paper/Spigot servers. Tags players in combat for 15 seconds when they damage another player, blocks escape commands (/home, /spawn, /tp, /tpa, /warp, /pay) while tagged, and kills players who disconnect while in combat with a server-wide broadcast. Uses a simple HashMap-based tracking system with no repeating task lag.
Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
8 241
src/main/java/com/combatlog/CombatLogPlugin.java
package com.combatlog;

import com.combatlog.listeners.CombatTagListener;
import com.combatlog.listeners.CommandBlockerListener;
import com.combatlog.listeners.QuitPunishListener;
import com.combatlog.tasks.CombatTask;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public class CombatLogPlugin extends JavaPlugin {
    private CombatManager combatManager;

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

        Bukkit.getPluginManager().registerEvents(new CombatTagListener(combatManager), this);
        Bukkit.getPluginManager().registerEvents(new CommandBlockerListener(combatManager), this);
        Bukkit.getPluginManager().registerEvents(new QuitPunishListener(combatManager), this);

        new CombatTask(combatManager).runTaskTimer(this, 0L, 20L);
    }
}