Killua

hello can you make an a plugin for minecraft spigot 1.21.5 ?

Kodari AI
KodariSep 4 at 2:32 pm 1
VoidChest
VoidChest is a Minecraft Spigot 1.21.5 plugin that adds a unique storage mechanic where players can create a personal void-linked chest. When a player places a chest and uses a special command, the chest becomes bound to their inventory, allowing items placed inside to be instantly accessible from anywhere via a portable void inventory interface. The plugin features per-player storage limits, configurable item stacking, secure binding to prevent theft, and a command system for opening the void inventory, checking storage usage, and unbinding chests. It includes full configuration for storage capacity, cooldowns, and permission-based access, with seamless integration into the vanilla Minecraft experience.

Yes. I can build a Spigot 1.21.5 plugin from scratch.

Tell me:

  • Plugin name

  • Features and commands

  • Permissions

  • Configuration requirements

  • Whether it should support other plugins such as Vault, PlaceholderAPI, or WorldGuard

Describe what you want the plugin to do, and I’ll create the complete project.

Killua

i want a sword in my plugin when i do right click shoot a fire ball and has a cooldown

Kodari AI
KodariSep 4 at 2:39 pm 1

I’ll create a FireSword Spigot 1.21.5 plugin with /firesword give, a configurable sword item, fireball launching on right-click, cooldown handling, permissions, and messages.

Created the FireSword Spigot 1.21.5 plugin.

Features:

  • /firesword give gives the player a Fire Sword.

  • /firesword give <player> gives another online player a Fire Sword.

  • Right-clicking with the sword launches a fireball.

  • Configurable cooldown, explosion yield, incendiary behavior, sword material, name, lore, and messages.

  • Custom sword identification using persistent item data.

  • Permission: firesword.give

  • Alias: /fsword

The project includes Gradle configuration, plugin.yml, config.yml, and the Java plugin/listener classes.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
6 254
src/main/java/com/kodari/firesword/FireSwordPlugin.java
package com.kodari.firesword;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
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.NamespacedKey;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public final class FireSwordPlugin extends JavaPlugin implements CommandExecutor, TabCompleter {

    private NamespacedKey swordKey;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        swordKey = new NamespacedKey(this, "fire_sword");

        getServer().getPluginManager().registerEvents(new FireSwordListener(this), this);
        if (getCommand("firesword") != null) {
            getCommand("firesword").setExecutor(this);
            getCommand("firesword").setTabCompleter(this);
        }
    }

    public ItemStack createFireSword() {
        String materialName = getConfig().getString("sword.material", "NETHERITE_SWORD");
        ItemStack item = XMaterial.matchXMaterial(materialName)
                .map(XMaterial::parseItem)
                .orElseThrow(() -> new IllegalStateException("Invalid sword material: " + materialName));

        ItemMeta meta = item.getItemMeta();
        if (meta == null) {
            throw new IllegalStateException("The configured sword material does not support item metadata.");
        }

        double cooldown = getConfig().getDouble("fireball.cooldown-seconds", 5.0);
        meta.setDisplayName(color(getConfig().getString("sword.name", "&c&lFire Sword")));
        meta.setLore(getConfig().getStringList("sword.lore").stream()
                .map(line -> color(line.replace("{cooldown}", formatSeconds(cooldown))))
                .toList());
        meta.getPersistentDataContainer().set(swordKey, PersistentDataType.BYTE, (byte) 1);
        item.setItemMeta(meta);
        return item;
    }

    public boolean isFireSword(ItemStack item) {
        if (item == null || !item.hasItemMeta() || item.getItemMeta() == null) {
            return false;
        }
        Byte value = item.getItemMeta().getPersistentDataContainer().get(swordKey, PersistentDataType.BYTE);
        return value != null && value == (byte) 1;
    }

    public long cooldownMillis() {
        return Math.max(0L, (long) (getConfig().getDouble("fireball.cooldown-seconds", 5.0) * 1000.0));
    }

    public String formatSeconds(double seconds) {
        if (seconds == Math.rint(seconds)) {
            return String.valueOf((long) seconds);
        }
        return String.valueOf(seconds);
    }

    public String message(String path, String... replacements) {
        String message = getConfig().getString("messages." + path, "");
        for (int i = 0; i + 1 < replacements.length; i += 2) {
            message = message.replace(replacements[i], replacements[i + 1]);
        }
        return color(getConfig().getString("messages.prefix", "") + message);
    }

    private String color(String text) {
        return ChatColor.translateAlternateColorCodes('&', text == null ? "" : text);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length == 0 || !args[0].equalsIgnoreCase("give")) {
            sender.sendMessage(message("help"));
            return true;
        }

        if (!sender.hasPermission("firesword.give")) {
            sender.sendMessage(message("no-permission"));
            return true;
        }

        Player target;
        if (args.length >= 2) {
            target = getServer().getPlayerExact(args[1]);
            if (target == null) {
                sender.sendMessage(message("player-not-found"));
                return true;
            }
        } else if (sender instanceof Player player) {
            target = player;
        } else {
            sender.sendMessage(message("player-only"));
            return true;
        }

        target.getInventory().addItem(createFireSword());
        target.sendMessage(message("sword-received"));
        if (sender != target) {
            sender.sendMessage(message("sword-given", "{player}", target.getName()));
        }
        return true;
    }

    @Override
    public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
        if (args.length == 1) {
            return Collections.singletonList("give");
        }
        if (args.length == 2 && args[0].equalsIgnoreCase("give")) {
            List<String> names = new ArrayList<>();
            for (Player player : getServer().getOnlinePlayers()) {
                names.add(player.getName());
            }
            return names;
        }
        return Collections.emptyList();
    }
}