nolefv

โ„๏ธ Frostbite โ€” Final Custom Sword Specification

Rarity: ๐Ÿ”ต Epic Type: Sword Playstyle: Crowd Control / PvP

๐Ÿ” Obtaining Frostbite

Only OP players can obtain Frostbite.

Command

text
/frostbite

The command gives the player the custom Frostbite sword.

OP Permission

text
op

If the player is OP:

text
โ„ You received Frostbite!

If the player is not OP:

text
โŒ You don't have permission to use Frostbite.

Frostbite cannot be obtained through normal gameplay, crafting, or other methods.

โš”๏ธ Passive โ€” Frost Touch

Every hit has a 15% chance to apply:

* ๐ŸŒ Slowness I * โฑ๏ธ Duration: 2 seconds

The passive only applies Slowness I.

โ„๏ธ Ability โ€” Frozen Ground

Cooldown: 45 seconds Duration: 6 seconds Radius: 5 blocks

When activated, Frostbite creates a frozen area around the player.

Every player inside the 5-block radius receives:

* ๐ŸŒ Slowness II * โ›๏ธ Mining Fatigue I * โ„๏ธ Snow/ice particles * ๐ŸงŠ Frost visual effects

The effects remain active while the player is inside the zone.

When they leave the radius, the effects are removed.

When the 6-second ability ends, all Frozen Ground effects are removed.

Important

There is no actual immobilization.

Frozen Ground = Slowness II + Mining Fatigue I

โฑ๏ธ Action Bar Cooldown

Display the remaining cooldown:

text
โ„ Frozen Ground: 44s
โ„ Frozen Ground: 30s
โ„ Frozen Ground: 15s
โ„ Frozen Ground: 5s
โ„ Frozen Ground: 1s

When ready:

text
โ„ Frozen Ground: READY

If the player tries to activate it while on cooldown:

text
โ„ Frozen Ground: 27s remaining

โš–๏ธ Final Stats

* Frost Touch: 15% chance * Frost Touch: Slowness I for 2 seconds * Frozen Ground: 6 seconds * Radius: 5 blocks * Frozen Ground: Slowness II + Mining Fatigue I * Cooldown: 45 seconds * Effects: Every player within 5 blocks * No actual immobilization * Obtaining: OP only * Command: /frostbite

Kodari AI
KodariSep 24 at 7:16 pm 1
FrostbiteSword
FrostbiteSword is a Minecraft plugin that introduces a custom Epic sword obtainable only by OP players via the /frostbite command. The sword features Frost Touch passive, granting a 15% chance to apply Slowness I for 2 seconds on hit. Its active ability, Frozen Ground, creates a 5-block radius zone for 6 seconds, applying Slowness II and Mining Fatigue I to all players inside, with snow and ice particle effects. A 45-second cooldown is displayed via action bar messages showing remaining time and READY status. The plugin handles permission checks, cooldown management, zone effect tracking, and particle rendering.

Iโ€™ll create:

  • A Paper plugin entry point with /frostbite restricted to OP players.

  • A tagged custom sword, 15% Frost Touch passive, and right-click Frozen Ground activation.

  • Cooldown action-bar updates, zone effects/particles, and effect cleanup.

Created the Frostbite plugin with OP-only /frostbite, a tagged custom sword, 15% Slowness I on hit, and right-click Frozen Ground with its 45-second cooldown, action-bar status, particles, and timed effect cleanup.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 319
src/main/java/com/kodari/frostbite/FrostbitePlugin.java
package com.kodari.frostbite;

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import com.cryptomorin.xseries.particles.XParticle;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
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.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.NamespacedKey;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

public final class FrostbitePlugin extends JavaPlugin implements Listener, CommandExecutor {
    private static final long ABILITY_DURATION_MILLIS = 6_000L;
    private static final long COOLDOWN_MILLIS = 45_000L;
    private static final double ZONE_RADIUS_SQUARED = 25.0;

    private final Map<UUID, Long> cooldowns = new HashMap<>();
    private final List<FrozenZone> zones = new ArrayList<>();
    private final Set<UUID> zoneAffectedPlayers = new HashSet<>();

    private NamespacedKey frostbiteKey;
    private BlockData packedIceData;
    private XParticle snowParticle;
    private XParticle blockParticle;
    private BukkitTask zoneTask;
    private BukkitTask actionBarTask;
    private long ticks;

    @Override
    public void onEnable() {
        frostbiteKey = new NamespacedKey(this, "frostbite");
        packedIceData = XMaterial.matchXMaterial("PACKED_ICE")
                .map(XMaterial::parseMaterial)
                .map(material -> Bukkit.createBlockData(material))
                .orElse(null);
        snowParticle = XParticle.of("SNOWFLAKE").orElse(null);
        blockParticle = XParticle.of("BLOCK").orElse(null);

        getServer().getPluginManager().registerEvents(this, this);
        getCommand("frostbite").setExecutor(this);
        zoneTask = Bukkit.getScheduler().runTaskTimer(this, this::tickZones, 1L, 1L);
        actionBarTask = Bukkit.getScheduler().runTaskTimer(this, this::updateActionBars, 20L, 20L);
    }

    @Override
    public void onDisable() {
        if (zoneTask != null) {
            zoneTask.cancel();
        }
        if (actionBarTask != null) {
            actionBarTask.cancel();
        }
        for (UUID uuid : zoneAffectedPlayers) {
            Player player = Bukkit.getPlayer(uuid);
            if (player != null) {
                removeFrozenEffects(player);
            }
        }
        zones.clear();
        zoneAffectedPlayers.clear();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage("Only a player can receive Frostbite.");
            return true;
        }
        if (!player.isOp()) {
            player.sendMessage(ChatColor.RED + "โŒ You don't have permission to use Frostbite.");
            return true;
        }

        ItemStack sword = createFrostbite();
        if (sword == null) {
            player.sendMessage(ChatColor.RED + "Frostbite could not be created on this server.");
            return true;
        }
        for (ItemStack leftover : player.getInventory().addItem(sword).values()) {
            player.getWorld().dropItemNaturally(player.getLocation(), leftover);
        }
        player.sendMessage(ChatColor.AQUA + "โ„ You received Frostbite!");
        return true;
    }

    @EventHandler(ignoreCancelled = true)
    public void onPlayerInteract(PlayerInteractEvent event) {
        if (event.getHand() != org.bukkit.inventory.EquipmentSlot.HAND || !isFrostbite(event.getItem())) {
            return;
        }
        activateFrozenGround(event.getPlayer());
    }

    @EventHandler(ignoreCancelled = true)
    public void onPlayerDamage(EntityDamageByEntityEvent event) {
        Entity attacker = event.getDamager();
        Entity victim = event.getEntity();
        if (!(attacker instanceof Player player) || !(victim instanceof Player target)
                || !isFrostbite(player.getInventory().getItemInMainHand())) {
            return;
        }
        if (ThreadLocalRandom.current().nextDouble() < 0.15) {
            XPotion.matchXPotion("SLOWNESS")
                    .map(potion -> potion.buildPotionEffect(40, 0))
                    .ifPresent(effect -> target.addPotionEffect(effect, true));
        }
    }

    private ItemStack createFrostbite() {
        ItemStack sword = XMaterial.matchXMaterial("DIAMOND_SWORD")
                .map(XMaterial::parseItem)
                .orElse(null);
        if (sword == null) {
            return null;
        }
        ItemMeta meta = sword.getItemMeta();
        if (meta == null) {
            return null;
        }
        meta.setDisplayName(ChatColor.BLUE + "โ„ Frostbite");
        meta.setLore(List.of(
                ChatColor.LIGHT_PURPLE + "Epic Sword",
                ChatColor.GRAY + "Frost Touch: 15% chance to slow",
                ChatColor.GRAY + "Right-click: Frozen Ground"
        ));
        meta.setUnbreakable(true);
        meta.getPersistentDataContainer().set(frostbiteKey, PersistentDataType.BYTE, (byte) 1);
        sword.setItemMeta(meta);
        return sword;
    }

    private boolean isFrostbite(ItemStack item) {
        if (item == null || !item.hasItemMeta()) {
            return false;
        }
        Byte marker = item.getItemMeta().getPersistentDataContainer().get(frostbiteKey, PersistentDataType.BYTE);
        return marker != null && marker == (byte) 1;
    }

    private void activateFrozenGround(Player player) {
        long now = System.currentTimeMillis();
        long cooldownEnd = cooldowns.getOrDefault(player.getUniqueId(), 0L);
        if (cooldownEnd > now) {
            long secondsRemaining = (cooldownEnd - now + 999L) / 1_000L;
            sendActionBar(player, "โ„ Frozen Ground: " + secondsRemaining + "s remaining");
            return;
        }

        cooldowns.put(player.getUniqueId(), now + COOLDOWN_MILLIS);
        zones.add(new FrozenZone(player.getLocation().clone(), now + ABILITY_DURATION_MILLIS));
    }

    private void tickZones() {
        ticks++;
        long now = System.currentTimeMillis();
        Set<UUID> affectedNow = new HashSet<>();
        Iterator<FrozenZone> iterator = zones.iterator();
        while (iterator.hasNext()) {
            FrozenZone zone = iterator.next();
            if (now >= zone.endsAt) {
                iterator.remove();
                continue;
            }

            if (ticks % 5 == 0) {
                renderZone(zone.center);
            }
            World world = zone.center.getWorld();
            if (world == null) {
                continue;
            }
            for (Player player : world.getPlayers()) {