Gagan Das

Minecraft server plugin based on 1.21.x l Its basically a super abilities spear smp plugin ,player will get a wooden spear which have a unique ability which the spear will upgrade on each kills wooden spear to netherite spear PLAYER CANT drop it player can't break it on dying the spear will not drop other all inventory will drop netherite spear have more abilities and the damage is higher than the all combined super abilities will be used on the press of f key when the spear will on the hand the off hand feature will stop working the ability will work add effect and visuals on the super ability use time too

Kodari AI
KodariSep 25 at 12:05 pm 1
EvolvingSpearSMP
A Minecraft 1.21 SMP plugin featuring a unique unbreakable, undroppable spear that evolves from wood to netherite through player kills. Each tier increases damage and unlocks new super abilities triggered by pressing the F key while holding the spear. Super abilities include powerful effects, particle visuals, and cooldown management. The spear persists through death while other inventory drops normally. Off-hand functionality is disabled when the spear is equipped, ensuring focused combat. The plugin implements a custom GUI for ability selection and upgrade tracking, with configurable progression paths and ability parameters.
  1. Create the Paper 1.21.x plugin scaffold.

  2. Add six kill-upgrade spear tiers, protected death/drop handling, and F-key abilities with effects and visuals.

  3. Register the plugin events and keep a full inventory from forcing the spear to drop.

Created the SuperSpearSMP plugin scaffold with six spear tiers that upgrade on kills, bonus damage, and tier-specific F-key abilities with visual effects. Spear drops are blocked, the spear is restored after death, and offhand actions are disabled while it’s held in the main hand.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 365
src/main/java/com/kodari/superspearsmp/SuperSpearSmpPlugin.java
package com.kodari.superspearsmp;

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.particles.XParticle;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
import org.bukkit.plugin.java.JavaPlugin;

public final class SuperSpearSmpPlugin extends JavaPlugin implements Listener {
    private static final String[] TIER_NAMES = {"Wooden", "Stone", "Iron", "Golden", "Diamond", "Netherite"};
    private static final String[] ABILITY_NAMES = {"Spear Dash", "Shockwave", "Vault Strike", "Battle Focus", "Rift Charge", "Nether Quake"};
    private static final double[] BONUS_DAMAGE = {2.0, 3.0, 4.0, 5.0, 7.0, 10.0};

    private final Map<UUID, Long> cooldowns = new HashMap<>();
    private final Map<UUID, Integer> respawnTiers = new HashMap<>();
    private final Map<UUID, BukkitTask> pendingDeliveries = new HashMap<>();
    private NamespacedKey spearKey;
    private NamespacedKey tierKey;

    @Override
    public void onEnable() {
        spearKey = new NamespacedKey(this, "super_spear");
        tierKey = new NamespacedKey(this, "spear_tier");
        getServer().getPluginManager().registerEvents(this, this);
    }

    @Override
    public void onDisable() {
        pendingDeliveries.values().forEach(BukkitTask::cancel);
        pendingDeliveries.clear();
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        if (!hasSpear(player)) {
            giveWhenSpace(player, 0);
        }
    }

    @EventHandler
    public void onQuit(PlayerQuitEvent event) {
        cancelPendingDelivery(event.getPlayer().getUniqueId());
    }

    @EventHandler
    public void onDrop(PlayerDropItemEvent event) {
        if (isSpear(event.getItemDrop().getItemStack())) {
            event.setCancelled(true);
        }
    }

    @EventHandler
    public void onSwapHands(PlayerSwapHandItemsEvent event) {
        if (isSpear(event.getPlayer().getInventory().getItemInMainHand())) {
            event.setCancelled(true);
            useAbility(event.getPlayer());
        }
    }

    @EventHandler
    public void onInteract(PlayerInteractEvent event) {
        if (event.getHand() == EquipmentSlot.OFF_HAND
                && isSpear(event.getPlayer().getInventory().getItemInMainHand())) {
            event.setCancelled(true);
        }
    }

    @EventHandler
    public void onInventoryClick(InventoryClickEvent event) {
        if (event.getWhoClicked() instanceof Player player
                && isSpear(event.getCurrentItem())
                && event.getClick().isKeyboardClick()) {
            event.setCancelled(true);
        }
    }

    @EventHandler
    public void onDamage(EntityDamageByEntityEvent event) {
        if (event.getDamager() instanceof Player player) {
            int tier = getTier(player.getInventory().getItemInMainHand());
            if (tier >= 0) {
                event.setDamage(event.getDamage() + BONUS_DAMAGE[tier]);
            }
        }
    }

    @EventHandler
    public void onKill(EntityDeathEvent event) {
        Player killer = event.getEntity().getKiller();
        if (killer == null) {
            return;
        }

        ItemStack held = killer.getInventory().getItemInMainHand();
        int tier = getTier(held);
        if (tier < 0 || tier >= TIER_NAMES.length - 1) {
            return;
        }

        ItemStack upgraded = createSpear(tier + 1);
        killer.getInventory().setItemInMainHand(upgraded);
        killer.sendMessage(ChatColor.GOLD + "Your spear upgraded to " + ChatColor.LIGHT_PURPLE
                + TIER_NAMES[tier + 1] + " Spear" + ChatColor.GOLD + "!");
        XSound.matchXSound("ENTITY_PLAYER_LEVELUP").ifPresent(sound -> sound.play(killer));
        spawnParticles(killer, "HAPPY_VILLAGER", killer.getLocation().add(0, 1, 0), 18, 0.6, 0.7, 0.6, 0.05);
    }

    @EventHandler
    public void onDeath(PlayerDeathEvent event) {
        Player player = event.getEntity();
        int tier = highestTier(player.getInventory());
        for (ItemStack drop : event.getDrops()) {
            tier = Math.max(tier, getTier(drop));
        }
        if (tier < 0) {
            return;
        }

        int savedTier = tier;
        event.getDrops().removeIf(this::isSpear);
        respawnTiers.put(player.getUniqueId(), savedTier);
    }

    @EventHandler
    public void onRespawn(PlayerRespawnEvent event) {
        Integer tier = respawnTiers.remove(event.getPlayer().getUniqueId());
        if (tier != null && !hasSpear(event.getPlayer())) {
            giveWhenSpace(event.getPlayer(), tier);
        }
    }

    private void useAbility(Player player) {
        ItemStack held = player.getInventory().getItemInMainHand();
        int tier = getTier(held);
        if (tier < 0) {
            return;
        }

        long now = System.currentTimeMillis();
        long cooldownMillis = tier == 5 ? 30_000L : tier >= 3 ? 20_000L : 12_000L;
        long readyAt = cooldowns.getOrDefault(player.getUniqueId(), 0L);
        if (readyAt > now) {
            long seconds = (readyAt - now + 999L) / 1000L;
            player.sendMessage(ChatColor.RED + "Ability cooldown: " + seconds + "s");
            return;
        }

        cooldowns.put(player.getUniqueId(), now + cooldownMillis);
        player.sendMessage(ChatColor.AQUA + "Used " + ChatColor.WHITE + ABILITY_NAMES[tier] + ChatColor.AQUA + "!");
        Location location = player.getLocation();

        switch (tier) {
            case 0 -> {
                dash(player, 1.25, 0.35);
                spawnParticles(player, "CLOUD", location, 24, 0.7, 0.4, 0.7, 0.08);
                playSound(player, "ENTITY_PLAYER_ATTACK_SWEEP");
            }
            case 1 -> {
                damageNearby(player, location, 4.5, 4.0, 0.85, false);
                spawnParticles(player, "CRIT", location, 36, 2.0, 0.8, 2.0, 0.15);
                playSound(player, "ENTITY_GENERIC_EXPLODE");
            }
            case 2 -> {
                dash(player, 0.9, 0.9);
                damageNearby(player, location, 3.5, 5.0, 0.7, false);
                spawnParticles(player, "SWEEP_ATTACK", location, 12, 1.2, 0.8, 1.2, 0.1);
                playSound(player, "ENTITY_PLAYER_ATTACK_KNOCKBACK");
            }