James james

Make me dash weapons freeze sword strike sword void sword and dash spear dash mace dash sword but the cooldown looks like this

1 image attached
Kodari AI
KodariSep 30 at 7:02 pm 1
DashWeaponMastery
A Minecraft plugin introducing five dash-based weapons: Freeze Sword, Strike Sword, Void Sword, Dash Spear, and Dash Mace. Each weapon triggers a unique dash ability on right-click with a shared cooldown system displayed via a visual bar. Freeze Sword slows and freezes enemies in ice, Strike Sword deals lightning damage, Void Sword teleports and damages, Dash Spear charges forward with piercing damage, and Dash Mace delivers a powerful knockback slam. Cooldowns are tracked per player with an on-screen status display.
  1. Set up the Paper plugin and /dashweapons command.

  2. Add six custom weapons with distinct right-click abilities and cooldowns.

  3. Show four color-coded ability timers above the hotbar, matching the screenshot.

Created the DashWeapons plugin with /dashweapons to receive all six weapons: Freeze Sword, Strike Sword, Void Sword, Dash Sword, Dash Spear, and Dash Mace. Their abilities share four cooldown groups, displayed above the hotbar as color-coded FREEZE | STRIKE | VOID | DASH statuses, with remaining seconds or READY.

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

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.particles.XParticle;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
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.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.RayTraceResult;
import org.bukkit.util.Vector;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public final class DashWeaponsPlugin extends JavaPlugin implements Listener, CommandExecutor {
    private static final long FREEZE_COOLDOWN = 8_000L;
    private static final long STRIKE_COOLDOWN = 5_000L;
    private static final long VOID_COOLDOWN = 7_000L;
    private static final long DASH_COOLDOWN = 3_000L;

    private final Map<UUID, Map<String, Long>> cooldowns = new HashMap<>();
    private NamespacedKey weaponKey;

    @Override
    public void onEnable() {
        weaponKey = new NamespacedKey(this, "weapon");
        getServer().getPluginManager().registerEvents(this, this);
        getCommand("dashweapons").setExecutor(this);
        getServer().getScheduler().runTaskTimer(this, this::updateCooldownHud, 0L, 5L);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage(ChatColor.RED + "Only players can receive these weapons.");
            return true;
        }

        for (ItemStack weapon : createWeapons()) {
            Map<Integer, ItemStack> overflow = player.getInventory().addItem(weapon);
            overflow.values().forEach(item -> player.getWorld().dropItemNaturally(player.getLocation(), item));
        }
        player.sendMessage(ChatColor.GREEN + "You received all six DashWeapons.");
        return true;
    }

    @EventHandler
    public void onWeaponUse(PlayerInteractEvent event) {
        if (event.getHand() != EquipmentSlot.HAND) {
            return;
        }
        if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) {
            return;
        }

        ItemStack item = event.getItem();
        if (item == null || !item.hasItemMeta()) {
            return;
        }
        String weapon = item.getItemMeta().getPersistentDataContainer().get(weaponKey, PersistentDataType.STRING);
        if (weapon == null) {
            return;
        }

        event.setCancelled(true);
        Player player = event.getPlayer();
        String cooldownKey = cooldownKey(weapon);
        if (getRemainingMillis(player.getUniqueId(), cooldownKey) > 0L) {
            return;
        }

        activate(player, weapon);
        startCooldown(player.getUniqueId(), cooldownKey, cooldownDuration(cooldownKey));
    }

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

    private void activate(Player player, String weapon) {
        switch (weapon) {
            case "freeze_sword" -> freezeStrike(player);
            case "strike_sword" -> strike(player);
            case "void_sword" -> voidStrike(player);
            case "dash_sword" -> dash(player, 1.45, 0.35);
            case "dash_spear" -> dash(player, 2.0, 0.3);
            case "dash_mace" -> {
                dash(player, 1.25, 0.9);
                for (Entity entity : player.getNearbyEntities(2.5, 1.5, 2.5)) {
                    if (entity instanceof LivingEntity target && target != player) {
                        target.damage(4.0, player);
                    }
                }
            }
            default -> {
            }
        }
    }

    private void freezeStrike(Player player) {
        LivingEntity target = getTarget(player, 12.0);
        if (target == null) {
            player.sendMessage(ChatColor.RED + "No target in range.");
            return;
        }

        XPotion.matchXPotion("SLOW").map(potion -> potion.buildPotionEffect(60, 10))
                .ifPresent(effect -> target.addPotionEffect(effect, true));
        target.damage(2.0, player);
        XParticle.of("SNOWFLAKE").ifPresent(particle -> target.getWorld().spawnParticle(particle.get(), target.getLocation().add(0, 1, 0), 20, 0.5, 0.7, 0.5, 0.02));
        XSound.matchXSound("BLOCK_GLASS_HIT").ifPresent(sound -> sound.play(target));
    }

    private void strike(Player player) {
        LivingEntity target = getTarget(player, 12.0);
        if (target == null) {
            player.sendMessage(ChatColor.RED + "No target in range.");
            return;
        }

        target.damage(7.0, player);
        target.getWorld().strikeLightningEffect(target.getLocation());
        XParticle.of("CRIT").ifPresent(particle -> target.getWorld().spawnParticle(particle.get(), target.getLocation().add(0, 1, 0), 18, 0.35, 0.5, 0.35, 0.1));
        XSound.matchXSound("ENTITY_PLAYER_ATTACK_STRONG").ifPresent(sound -> sound.play(player));
    }

    private void voidStrike(Player player) {
        LivingEntity target = getTarget(player, 14.0);
        if (target == null) {
            player.sendMessage(ChatColor.RED + "No target in range.");
            return;
        }

        Vector pull = player.getLocation().toVector().subtract(target.getLocation().toVector());
        if (pull.lengthSquared() > 0.001) {
            pull.normalize().multiply(1.15).setY(0.3);
            target.setVelocity(pull);
        }
        target.damage(5.0, player);
        XParticle.of("PORTAL").ifPresent(particle -> target.getWorld().spawnParticle(particle.get(), target.getLocation().add(0, 1, 0), 30, 0.4, 0.6, 0.4, 0.15));
        XSound.matchXSound("ENTITY_ENDERMAN_TELEPORT").ifPresent(sound -> sound.play(target));
    }

    private void dash(Player player, double horizontalPower, double verticalPower) {
        Vector direction = player.getLocation().getDirection().setY(0);
        if (direction.lengthSquared() < 0.001) {
            direction = player.getLocation().getDirection();
        }
        direction.normalize().multiply(horizontalPower).setY(verticalPower);
        player.setVelocity(direction);
        XParticle.of("CLOUD").ifPresent(particle -> player.getWorld().spawnParticle(particle.get(), player.getLocation(), 12, 0.35, 0.25, 0.35, 0.03));
        XSound.matchXSound("ENTITY_PLAYER_ATTACK_SWEEP").ifPresent(sound -> sound.play(player));
    }

    private LivingEntity getTarget(Player player, double range) {
        RayTraceResult result = player.getWorld().rayTraceEntities(
                player.getEyeLocation(), player.getEyeLocation().getDirection(), range, 0.7,
                entity -> entity instanceof LivingEntity && entity != player
        );
        return result != null && result.getHitEntity() instanceof LivingEntity target ? target : null;
    }

    private void updateCooldownHud() {
        for (Player player : Bukkit.getOnlinePlayers()) {
            String hud = formatCooldown("FREEZE", "freeze", ChatColor.RED, player.getUniqueId())
                    + ChatColor.DARK_GRAY + " | "
                    + formatCooldown("STRIKE", "strike", ChatColor.WHITE, player.getUniqueId())
                    + ChatColor.DARK_GRAY + " | "
                    + formatCooldown("VOID", "void", ChatColor.GREEN, player.getUniqueId())
                    + ChatColor.DARK_GRAY + " | "
                    + formatCooldown("DASH", "dash", ChatColor.GRAY, player.getUniqueId());
            player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(hud));
        }
    }

    private String formatCooldown(String label, String key, ChatColor color, UUID playerId) {
        long remaining = getRemainingMillis(playerId, key);