Hubert Kusiak

Make a plugin that strikes the player at death and blocks the end with a simple command

Kodari AI
KodariSep 21 at 8:22 pm 1
DeathStrikeEndBlocker
DeathStrikeEndBlocker is a Minecraft plugin that strikes the player with lightning upon death and blocks access to the End dimension. When a player dies, a lightning bolt strikes their death location for dramatic effect. The plugin also prevents players from entering the End by canceling End portal and End gateway teleportation events. A simple command allows server administrators to toggle the End-blocking feature on or off, providing flexible control over dimension access while maintaining the death strike mechanic at all times.

I’ll create a Kotlin Paper plugin with:

  1. Lightning strikes on every player death.

  2. End-entry blocking for portals and End gateways.

  3. /endblock on|off|status with persisted state and permission control.

  4. Gradle, plugin metadata, and default configuration.

Created the EndBlock Kotlin Paper plugin.

  • Strikes players with lightning effects on death.

  • Blocks End portal and End gateway entry by default.

  • Adds /endblock on|off|status.

  • Persists the End access setting in config.yml.

  • Restricts command usage to endblock.admin.

  • Added Gradle setup, plugin.yml, and manifest.kod.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle.kts
manifest.kod
settings.gradle.kts
Code
6 139
src/main/kotlin/com/kodari/endblock/EndBlockPlugin.kt
package com.kodari.endblock

import org.bukkit.ChatColor
import org.bukkit.World
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
import org.bukkit.event.Listener
import org.bukkit.event.entity.PlayerDeathEvent
import org.bukkit.event.player.PlayerPortalEvent
import org.bukkit.event.player.PlayerTeleportEvent
import org.bukkit.plugin.java.JavaPlugin

class EndBlockPlugin : JavaPlugin(), Listener {
    private var endBlocked = true

    override fun onEnable() {
        saveDefaultConfig()
        endBlocked = config.getBoolean("end-blocked", true)
        server.pluginManager.registerEvents(this, this)
        getCommand("endblock")?.setExecutor { sender, _, _, args ->
            handleCommand(sender, args)
        }
    }

    @EventHandler(priority = EventPriority.NORMAL)
    fun onPlayerDeath(event: PlayerDeathEvent) {
        event.player.world.strikeLightningEffect(event.player.location)
    }

    @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
    fun onPlayerPortal(event: PlayerPortalEvent) {
        if (endBlocked && event.to?.world?.environment == World.Environment.THE_END) {
            event.isCancelled = true
            event.player.sendMessage("${ChatColor.RED}Access to the End is currently blocked.")
        }
    }

    @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
    fun onPlayerTeleport(event: PlayerTeleportEvent) {
        val enteringEnd = event.to?.world?.environment == World.Environment.THE_END
        val endTeleport = event.cause == PlayerTeleportEvent.TeleportCause.END_PORTAL ||
            event.cause == PlayerTeleportEvent.TeleportCause.END_GATEWAY

        if (endBlocked && enteringEnd && endTeleport) {
            event.isCancelled = true
            event.player.sendMessage("${ChatColor.RED}Access to the End is currently blocked.")
        }
    }

    private fun handleCommand(sender: org.bukkit.command.CommandSender, args: Array<out String>): Boolean {
        if (!sender.hasPermission("endblock.admin")) {
            sender.sendMessage("${ChatColor.RED}You do not have permission to use this command.")
            return true
        }

        when (args.firstOrNull()?.lowercase()) {
            "on" -> setEndBlocked(sender, true)
            "off" -> setEndBlocked(sender, false)
            "status" -> sender.sendMessage(statusMessage())
            else -> sender.sendMessage("${ChatColor.YELLOW}Usage: /endblock <on|off|status>")
        }
        return true
    }

    private fun setEndBlocked(sender: org.bukkit.command.CommandSender, blocked: Boolean) {
        endBlocked = blocked
        config.set("end-blocked", blocked)
        saveConfig()
        sender.sendMessage(statusMessage())
    }

    private fun statusMessage(): String = if (endBlocked) {
        "${ChatColor.GREEN}End access is blocked."
    } else {
        "${ChatColor.GREEN}End access is allowed."
    }
}