stxrzfrr

if a player is under coords y 250 and they get hit both the player that gets hit and hitted someone will be in combat and if they leave they die and drop their loot when ur in combat u cant do ANY COMMANDS if ur an op u can still do commands make it look like an bossbar but it doesnt need to be a bossbar

Kodari AI
KodariAug 30 at 3:11 pm 1
SkyCombatLock
SkyCombatLock is a Minecraft Kotlin plugin that enforces a high-altitude combat zone above Y=250. When a player attacks or is attacked above this threshold, both parties enter a combat state displayed via a bossbar-style HUD. While in combat, players cannot execute any commands unless they have operator permissions. If a combatant logs out or leaves the server, they die and drop their loot as punishment. The plugin tracks combat timers, manages command blocking, and ensures fair PvP enforcement in sky-based arenas.
  1. Create the Kotlin Paper plugin project and build configuration.

  2. Add combat tracking below Y=250, action-bar timer, command blocking, and quit-death loot drops.

  3. Register listeners and lifecycle cleanup.

Created the Kotlin Paper plugin with:

  • Combat tagging when a player below Y=250 is hit.

  • 15-second combat timer displayed through an action bar.

  • Command blocking for non-OP players during combat.

  • Combat logout punishment: the player dies and drops inventory loot.

  • Combat cleanup on death, quit, expiry, and plugin shutdown.

  • Paper 1.21.4 Gradle project configuration.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle.kts
manifest.kod
settings.gradle.kts
Code
7 178
src/main/kotlin/com/kodari/heightcombat/CombatManager.kt
package com.kodari.heightcombat

import net.kyori.adventure.text.Component
import net.kyori.adventure.text.format.NamedTextColor
import org.bukkit.Bukkit
import org.bukkit.entity.Player
import java.util.UUID

class CombatManager {
    private val combatUntil = mutableMapOf<UUID, Long>()
    private val combatDurationMillis = 15_000L

    fun tag(attacker: Player, victim: Player) {
        val expiresAt = System.currentTimeMillis() + combatDurationMillis
        combatUntil[attacker.uniqueId] = expiresAt
        combatUntil[victim.uniqueId] = expiresAt
    }

    fun isInCombat(player: Player): Boolean = isInCombat(player.uniqueId)

    private fun isInCombat(uniqueId: UUID): Boolean {
        val expiresAt = combatUntil[uniqueId] ?: return false
        if (expiresAt <= System.currentTimeMillis()) {
            combatUntil.remove(uniqueId)
            return false
        }
        return true
    }

    fun handleQuit(player: Player) {
        if (combatUntil.remove(player.uniqueId) == null) return
        if (!player.isDead) {
            player.health = 0.0
        }
    }

    fun clear(player: Player) {
        combatUntil.remove(player.uniqueId)
    }

    fun tick() {
        val now = System.currentTimeMillis()
        val iterator = combatUntil.iterator()
        while (iterator.hasNext()) {
            val entry = iterator.next()
            val remainingMillis = entry.value - now
            if (remainingMillis <= 0) {
                iterator.remove()
                continue
            }

            val player = Bukkit.getPlayer(entry.key)
            if (player == null || !player.isOnline) {
                iterator.remove()
                continue
            }

            val seconds = (remainingMillis + 999L) / 1_000L
            player.sendActionBar(
                Component.text("⚔ COMBAT  |  ${seconds}s remaining", NamedTextColor.RED)
            )
        }
    }

    fun clear() {
        combatUntil.clear()
    }
}