keyton mccray

A Minecraft dragon Scythe that shoots dragon fireballs and that has an AOE that stunned the opponent and it has a cool animation for the charge beam and then I want another weapon called the Icebreaker that freezes anyone in a 30 block radius and rains ice spikes from sky

Kodari AI
KodariNov 2 at 8:21 pm 4
DragonFrostArsenal
Adds two legendary weapons to Minecraft. The Dragon Scythe fires dragon fireballs, charges a beam with a visual animation that stuns opponents in an area of effect. The Icebreaker freezes all entities within a 30-block radius and summons ice spikes raining from the sky, dealing damage and immobilizing targets. Both weapons have custom cooldowns, particle effects, and sound cues for immersive combat.
  • Add two obtainable weapons with separate cooldowns.

  • Give the scythe a charging fireball and stunning area attack.

  • Give Icebreaker a 30-block freeze and falling ice-spike effects.

Created both weapons. Use /dragonweapon scythe or /dragonweapon icebreaker to obtain them.

  • Dragon Scythe: Right-click to charge and launch a fireball; left-click to stun nearby enemies.

  • Icebreaker: Right-click to freeze enemies within 30 blocks and rain damaging ice spikes on them.

Kodari can make mistakes. Review important code before using.
Files
src
Code
2 224
src/main/java/com/kodari/dragonweapons/DragonWeapons.java
package com.kodari.dragonweapons;

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import com.cryptomorin.xseries.particles.XParticle;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.Particle;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Fireball;
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.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.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;

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

public final class DragonWeapons extends JavaPlugin implements Listener {
    private NamespacedKey weaponKey;
    private final Map<String, Long> cooldowns = new HashMap<>();

    @Override
    public void onEnable() {
        weaponKey = new NamespacedKey(this, "weapon");
        getServer().getPluginManager().registerEvents(this, this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("Only players can receive weapons.");
            return true;
        }
        if (!sender.hasPermission("dragonweapons.give")) {
            sender.sendMessage(ChatColor.RED + "You do not have permission to use this command.");
            return true;
        }
        if (args.length != 1 || !(args[0].equalsIgnoreCase("scythe") || args[0].equalsIgnoreCase("icebreaker"))) {
            sender.sendMessage(ChatColor.YELLOW + "Usage: /dragonweapon <scythe|icebreaker>");
            return true;
        }
        Player player = (Player) sender;
        String type = args[0].toLowerCase(java.util.Locale.ROOT);
        ItemStack item = createWeapon(type);
        if (item == null) {
            player.sendMessage(ChatColor.RED + "This weapon's material is unavailable on this server.");
            return true;
        }
        player.getInventory().addItem(item).values().forEach(leftover -> player.getWorld().dropItemNaturally(player.getLocation(), leftover));
        player.sendMessage(ChatColor.GREEN + "Weapon received!");
        return true;
    }

    private ItemStack createWeapon(String type) {
        boolean scythe = type.equals("scythe");
        ItemStack item = XMaterial.matchXMaterial(scythe ? "NETHERITE_HOE" : "DIAMOND_AXE")
                .map(XMaterial::parseItem).orElse(null);
        if (item == null) return null;
        ItemMeta meta = item.getItemMeta();
        if (meta == null) return null;
        meta.setDisplayName(scythe ? ChatColor.DARK_PURPLE + "Dragon Scythe" : ChatColor.AQUA + "Icebreaker");
        meta.setLore(scythe
                ? Arrays.asList(ChatColor.GRAY + "Right-click: charge a dragon fireball", ChatColor.GRAY + "Left-click: stun nearby enemies")
                : Arrays.asList(ChatColor.GRAY + "Right-click: freeze nearby enemies and rain ice spikes"));
        meta.getPersistentDataContainer().set(weaponKey, PersistentDataType.STRING, type);
        item.setItemMeta(meta);
        return item;
    }

    @EventHandler
    public void onInteract(PlayerInteractEvent event) {
        if (event.getHand() != EquipmentSlot.HAND || event.getItem() == null || !event.getItem().hasItemMeta()) return;
        ItemMeta meta = event.getItem().getItemMeta();
        String type = meta.getPersistentDataContainer().get(weaponKey, PersistentDataType.STRING);
        if (type == null) return;
        Action action = event.getAction();
        boolean right = action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK;
        boolean left = action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK;
        Player player = event.getPlayer();
        if (type.equals("scythe") && right) {
            event.setCancelled(true);
            if (ready(player, "fireball", 10000)) chargeFireball(player);
        } else if (type.equals("scythe") && left) {
            event.setCancelled(true);
            if (ready(player, "stun", 15000)) stun(player);
        } else if (type.equals("icebreaker") && right) {
            event.setCancelled(true);
            if (ready(player, "ice", 30000)) icebreaker(player);
        }
    }

    private boolean ready(Player player, String ability, long duration) {
        String key = player.getUniqueId() + ":" + ability;
        long now = System.currentTimeMillis();
        long remaining = cooldowns.getOrDefault(key, 0L) - now;
        if (remaining > 0) {
            player.sendMessage(ChatColor.RED + "Ability ready in " + ((remaining + 999) / 1000) + "s.");
            return false;
        }
        cooldowns.put(key, now + duration);
        return true;
    }

    private void chargeFireball(Player player) {
        new BukkitRunnable() {
            int tick;
            @Override
            public void run() {
                if (!player.isOnline() || player.isDead()) {
                    cancel();
                    return;
                }
                Location eye = player.getEyeLocation();
                Vector direction = eye.getDirection().normalize();
                for (int i = 0; i < 12; i++) {
                    double angle = tick * 0.3 + i * Math.PI / 6;
                    double distance = 0.4 + i * 0.16;
                    Location point = eye.clone().add(direction.clone().multiply(distance))
                            .add(Math.cos(angle) * 0.35, Math.sin(angle) * 0.35, 0);
                    particle("DRAGON_BREATH", point, 1, 0, 0, 0, 0);
                    particle("PORTAL", point, 1, 0, 0, 0, 0);
                }
                if (++tick >= 30) {
                    Location launch = eye.clone().add(direction.clone().multiply(1.5));
                    Fireball fireball = player.getWorld().spawn(launch, Fireball.class);
                    fireball.setShooter(player);
                    fireball.setDirection(direction);
                    fireball.setYield(2.0f);
                    fireball.setIsIncendiary(false);
                    cancel();
                }
            }
        }.runTaskTimer(this, 0L, 1L);
    }

    private void stun(Player player) {
        Location center = player.getLocation();
        for (Entity entity : player.getWorld().getNearbyEntities(center, 6, 6, 6)) {
            if (!(entity instanceof LivingEntity) || entity.equals(player) || entity.getLocation().distanceSquared(center) > 36) continue;
            LivingEntity target = (LivingEntity) entity;
            effect(target, "SLOWNESS", 60, 10);
            effect(target, "JUMP_BOOST", 60, 128);
        }
        for (int i = 0; i < 48; i++) {
            double angle = i * Math.PI * 2 / 48;
            particle("DRAGON_BREATH", center.clone().add(Math.cos(angle) * 6, 0.5, Math.sin(angle) * 6), 3, 0.1, 0.2, 0.1, 0);
        }
    }

    private void icebreaker(Player player) {
        Location center = player.getLocation().clone();
        for (Entity entity : player.getWorld().getNearbyEntities(center, 30, 30, 30)) {
            if (!(entity instanceof LivingEntity) || entity.equals(player) || entity.getLocation().distanceSquared(center) > 900) continue;
            LivingEntity target = (LivingEntity) entity;
            effect(target, "SLOWNESS", 100, 10);
            effect(target, "JUMP_BOOST", 100, 128);
            rainSpike(player, target.getLocation().clone());
        }
        for (int i = 0; i < 72; i++) {
            double angle = i * Math.PI * 2 / 72;
            particle("SNOWFLAKE", center.clone().add(Math.cos(angle) * 30, 1, Math.sin(angle) * 30), 5, 0.2, 0.3, 0.2, 0);
        }
    }

    private void rainSpike(Player caster, Location impact) {
        new BukkitRunnable() {
            double height = 15;
            @Override
            public void run() {
                for (int i = 0; i < 5; i++) {
                    Location point = impact.clone().add(0, height + i * 0.35, 0);
                    particle("SNOWFLAKE", point, 5, 0.12, 0.1, 0.12, 0);
                    particle("END_ROD", point, 1, 0.05, 0.05, 0.05, 0);
                }
                height -= 1.5;
                if (height <= 0) {
                    particle("SNOWFLAKE", impact.clone().add(0, 1, 0), 30, 0.5, 0.5, 0.5, 0.05);
                    for (Entity entity : impact.getWorld().getNearbyEntities(impact, 1.5, 2, 1.5)) {
                        if (entity instanceof LivingEntity && !entity.equals(caster)) {
                            ((LivingEntity) entity).damage(6.0, caster);
                        }
                    }
                    cancel();
                }
            }