its_saiyanplayz

Give me a combat plugin where, if a player is in combat, a 15-second combat timer is displayed above their hotbar (inventory). Also, if two players are fighting, a third player should not be able to hit them; instead, a message should appear saying those two players are already in combat, followed by their remaining combat time (similar to the system on MCFleet). for 1.21+

Kodari AI
KodariApr 16 at 3:29 pm 10,798 (v2)

I’ll create a combat timer plugin with third-party intervention protection.

CombatTimer
A combat management plugin that displays a 15-second timer above the hotbar when players engage in PvP. Prevents third-party intervention during active fights by blocking uninvolved players from attacking combatants. Shows remaining combat time when interference is attempted. Features configurable messages, automatic combat tracking, clean action bar displays, and handles player disconnections and deaths gracefully.

All files created! The plugin features:

  • 15-second combat timer displayed above hotbar using action bars

  • Third-party protection: If players A and B are fighting, player C cannot hit either of them

  • Time display: Blocked players see remaining combat time

  • Smart tracking: Combat only between two players at a time

  • Edge case handling: Handles player disconnects, deaths

  • Configurable: All messages and duration customizable

  • Bypass permission: combattimer.bypass for admins

  • Reload command: /combattimer reload

The combat system ensures clean 1v1 fights without interference!

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
10 480
src/main/java/com/example/combattimer/CombatTimer.java
package com.example.combattimer;

import com.example.combattimer.listener.CombatListener;
import com.example.combattimer.manager.CombatManager;
import com.example.combattimer.manager.ConfigManager;
import lombok.Getter;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class CombatTimer extends JavaPlugin {
    
    private ConfigManager configManager;
    private CombatManager combatManager;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        this.combatManager = new CombatManager(this);
        
        getServer().getPluginManager().registerEvents(new CombatListener(this), this);
        
        this.combatManager.startUpdateTask();
        
        getLogger().info("CombatTimer has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (this.combatManager != null) {
            this.combatManager.shutdown();
        }
        
        getLogger().info("CombatTimer has been disabled!");
    }
    
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (command.getName().equalsIgnoreCase("combattimer")) {
            if (args.length > 0 && args[0].equalsIgnoreCase("reload")) {
                if (!sender.hasPermission("combattimer.reload")) {
                    sender.sendMessage("§cYou don't have permission to use this command.");
                    return true;
                }
                
                reloadConfig();
                this.configManager.reload();
                sender.sendMessage(this.configManager.getMessage("config-reloaded"));
                return true;
            }
            
            sender.sendMessage("§6CombatTimer v" + getDescription().getVersion());
            sender.sendMessage("§e/combattimer reload §7- Reload configuration");
            return true;
        }
        
        return false;
    }
}