leaffsr

Spear SMP

Supported Minecraft Version

  • Minecraft: 1.21.11+
  • Server Software: Paper 1.21.11+ (Spigot compatible)
  • Java Version: 21

About

This plugin uses the official Spear weapon introduced in Minecraft Java Edition 1.21.11. It is designed for PvP progression and does not add a custom Spear item.

First Join

  • Every player automatically receives a Wood Spear on their first join.
  • No command is required.
  • This reward is given only once per player.

One Spear Rule

  • A player can own only one Spear at a time.
  • Duplicate Spears are not allowed.
  • Upgrading transforms the current Spear into the next tier automatically.

Spear Tiers

  1. Wood Spear
  2. Stone Spear
  3. Copper Spear
  4. Gold Spear
  5. Iron Spear
  6. Diamond Spear
  7. Netherite Spear

Enchantment Progression

Tier| Enchantments Wood Spear| None Stone Spear| Sharpness I Copper Spear| Sharpness II, Lunge I Gold Spear| Sharpness III, Lunge II Iron Spear| Sharpness IV, Lunge III, Fire Aspect I Diamond Spear| Sharpness V, Lunge IV, Fire Aspect II Netherite Spear| Sharpness VI, Lunge V, Fire Aspect II

PvP Progression

  • Only player kills made with the Spear count.
  • Every 1 PvP kill instantly updates the Spear's progression.
  • Every 1 PvP death removes 1 progression point.
  • Progress never goes below 0.
  • The Spear never downgrades.

Unlock Effects

  • 3-second spinning animation.
  • Golden & white particles.
  • Upgrade sound.
  • Title and subtitle notification.
  • New Spear automatically replaces the old one.

Admin Command

/spear reset <player>

Resets the player's entire Spear progression and gives a fresh Wood Spear.

Plugin Features

  • Uses the official Minecraft 1.21.11 Spear.
  • No custom resource pack required.
  • Unbreakable.
  • Non-Craftable.
  • Plugin-controlled progression.
  • PvP-focused gameplay.
  • Paper 1.21.11+ compatible.
Kodari AI
KodariAug 2 at 5:33 pm 2
SpearProgression
SpearProgression is a Paper plugin for Minecraft 1.21.11+ that adds PvP-focused progression to the official Spear weapon. Players receive one unbreakable Wood Spear on their first join, earn progression from player kills made with a Spear, lose one point on PvP death, and automatically unlock stronger material tiers with improved enchantments. The plugin prevents duplicate Spears, blocks crafting, displays upgrade titles and sounds, plays a three-second golden and white particle animation, and provides an admin reset command.
  1. Create the Gradle Kotlin project and plugin metadata.

  2. Implement Spear tiers, item metadata, progression, upgrades, deaths, and one-Spear enforcement.

  3. Add join rewards, PvP listeners, upgrade effects, crafting prevention, and /spear reset.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle.kts
manifest.kod
settings.gradle.kts
Code
11 574
src/main/kotlin/com/kodari/spearprogression/SpearListener.kt
package com.kodari.spearprogression

import net.kyori.adventure.text.Component
import net.kyori.adventure.text.format.NamedTextColor
import org.bukkit.Bukkit
import org.bukkit.Color
import org.bukkit.Particle
import org.bukkit.Sound
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
import org.bukkit.event.Listener
import org.bukkit.event.entity.EntityPickupItemEvent
import org.bukkit.event.entity.PlayerDeathEvent
import org.bukkit.event.inventory.CraftItemEvent
import org.bukkit.event.inventory.InventoryClickEvent
import org.bukkit.event.inventory.InventoryDragEvent
import org.bukkit.event.player.PlayerJoinEvent
import org.bukkit.inventory.ItemStack
import org.bukkit.scheduler.BukkitRunnable
import kotlin.math.cos
import kotlin.math.sin

class SpearListener(
    private val plugin: SpearProgressionPlugin,
    private val itemFactory: SpearItemFactory,
    private val progressionService: SpearProgressionService
) : Listener {
    @EventHandler
    fun onJoin(event: PlayerJoinEvent) {
        val player = event.player

        if (!player.hasPlayedBefore() && !progressionService.hasSpear(player)) {
            progressionService.giveFreshWood(player)
        }

        progressionService.normalize(player)
    }

    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    fun onPlayerDeath(event: PlayerDeathEvent) {
        val victim = event.entity
        val killer = victim.killer

        if (killer != null && killer != victim) {
            progressionService.recordPvPDeath(victim)
        }

        if (killer == null) {
            return
        }

        val weapon = killer.inventory.itemInMainHand
        if (!itemFactory.isSpear(weapon)) {
            return
        }

        val result = progressionService.recordKill(killer) ?: return
        if (result.upgraded) {
            playUpgradeEffects(killer, result.newTier)
        }
    }

    @EventHandler(ignoreCancelled = true)
    fun onPickup(event: EntityPickupItemEvent) {
        val player = event.entity as? Player ?: return
        val pickedItem = event.item.itemStack

        if (itemFactory.isSpear(pickedItem) && progressionService.hasSpear(player)) {
            event.isCancelled = true
            return
        }

        scheduleNormalize(player)
    }

    @EventHandler(ignoreCancelled = true)
    fun onInventoryClick(event: InventoryClickEvent) {
        scheduleNormalize(event.whoClicked as? Player ?: return)
    }

    @EventHandler(ignoreCancelled = true)
    fun onInventoryDrag(event: InventoryDragEvent) {
        scheduleNormalize(event.whoClicked as? Player ?: return)
    }

    @EventHandler(ignoreCancelled = true)
    fun onCraft(event: CraftItemEvent) {
        if (itemFactory.isSpear(event.recipe.result)) {
            event.isCancelled = true
        }
    }

    private fun scheduleNormalize(player: Player) {
        Bukkit.getScheduler().runTask(plugin, Runnable {
            if (player.isOnline) {
                progressionService.normalize(player)
            }
        })
    }

    private fun playUpgradeEffects(player: Player, tier: SpearTier) {
        player.playSound(player.location, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 1.15f)
        player.sendTitle(
            "§6Spear Upgraded!",
            "§f${tier.displayName} Spear",
            10,
            40,
            10
        )

        object : BukkitRunnable() {
            private var elapsed = 0

            override fun run() {
                if (!player.isOnline || elapsed >= 60) {
                    cancel()
                    return
                }

                val location = player.location.clone().add(0.0, 1.0, 0.0)
                val angleOffset = elapsed / 60.0 * Math.PI * 4.0
                val gold = Particle.DustOptions(Color.fromRGB(255, 196, 0), 1.2f)
                val white = Particle.DustOptions(Color.WHITE, 1.2f)

                repeat(8) { index ->
                    val angle = angleOffset + index * Math.PI / 4.0
                    val x = cos(angle) * 0.9
                    val z = sin(angle) * 0.9

                    player.world.spawnParticle(
                        Particle.DUST,
                        location.clone().add(x, 0.25, z),
                        1,
                        gold
                    )
                    player.world.spawnParticle(
                        Particle.DUST,
                        location.clone().add(x * 0.65, 0.65, z * 0.65),
                        1,
                        white
                    )
                }

                elapsed += 2
            }
        }.runTaskTimer(plugin, 0L, 2L)
    }
}