A.B challenge show

i want a plugin in which if admin type /super [any tool/any armour] so admin recive super legend enchanted tools and legend enchanted armours

Kodari AI
KodariOct 18 at 1:41 pm 1
SuperLegendEnchanter
A Minecraft plugin that grants administrators super legendary enchanted tools and armor via a simple command. When an admin types /super followed by any tool or armor name, the plugin instantly provides that item with maximum enchantment levels, including sharpness, protection, efficiency, unbreaking, and more. The plugin validates item names, checks player permissions, and delivers the fully enchanted legendary gear directly to the admin's inventory. Supports all vanilla tools, swords, bows, and armor pieces with optimized enchantment combinations for each item type, ensuring peak performance and durability for gameplay.
  1. Add the /super <item> command with admin-only access and material validation.

  2. Apply powerful legendary enchantments suited to the selected tool or armor.

  3. Add the plugin descriptor and command permission.

Created the SuperLegend plugin. Admins can use /super <item>, for example /super diamond_sword or /super netherite_chestplate. It gives the item with powerful, type-appropriate enchantments; the command is op-only by default.

Kodari can make mistakes. Review important code before using.
Files
src
Code
2 156
src/main/java/com/kodari/superlegend/SuperLegendPlugin.java
package com.kodari.superlegend;

import com.cryptomorin.xseries.XEnchantment;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Optional;

public final class SuperLegendPlugin extends JavaPlugin implements CommandExecutor {

    @Override
    public void onEnable() {
        getCommand("super").setExecutor(this);
    }

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

        Player player = (Player) sender;
        if (!player.hasPermission("superlegend.use")) {
            player.sendMessage(ChatColor.RED + "You do not have permission to use this command.");
            return true;
        }

        if (args.length != 1) {
            player.sendMessage(ChatColor.YELLOW + "Usage: /super <item> (for example: diamond_sword or netherite_chestplate)");
            return true;
        }

        String requestedMaterial = args[0].replace(' ', '_').toUpperCase(Locale.ROOT);
        Optional<XMaterial> matchedMaterial = XMaterial.matchXMaterial(requestedMaterial);
        if (!matchedMaterial.isPresent()) {
            player.sendMessage(ChatColor.RED + "Unknown item: " + args[0]);
            return true;
        }

        ItemStack item = matchedMaterial.get().parseItem();
        if (item == null || !isToolOrArmor(item.getType())) {
            player.sendMessage(ChatColor.RED + "Choose a tool, weapon, or armor piece.");
            return true;
        }

        enchant(item);
        ItemMeta meta = item.getItemMeta();
        if (meta != null) {
            String displayName = item.getType().name().replace('_', ' ');
            meta.setDisplayName(ChatColor.GOLD + "§lSUPER LEGEND " + ChatColor.YELLOW + displayName);
            List<String> lore = new ArrayList<>();
            lore.add(ChatColor.LIGHT_PURPLE + "Legendary equipment");
            meta.setLore(lore);
            item.setItemMeta(meta);
        }

        player.getInventory().addItem(item).values().forEach(leftover ->
                player.getWorld().dropItemNaturally(player.getLocation(), leftover));
        player.sendMessage(ChatColor.GREEN + "You received a super legend " + item.getType().name().toLowerCase(Locale.ROOT).replace('_', ' ') + "!");
        return true;
    }

    private boolean isToolOrArmor(Material material) {
        String name = material.name();
        return name.endsWith("_SWORD")
                || name.endsWith("_PICKAXE")
                || name.endsWith("_AXE")
                || name.endsWith("_SHOVEL")
                || name.endsWith("_HOE")
                || name.endsWith("_HELMET")
                || name.endsWith("_CHESTPLATE")
                || name.endsWith("_LEGGINGS")
                || name.endsWith("_BOOTS")
                || name.equals("TURTLE_HELMET")
                || name.equals("BOW")
                || name.equals("CROSSBOW")
                || name.equals("TRIDENT")
                || name.equals("FISHING_ROD")
                || name.equals("SHEARS")
                || name.equals("FLINT_AND_STEEL");
    }

    private void enchant(ItemStack item) {
        String name = item.getType().name();
        addEnchantment(item, "UNBREAKING", 10);
        addEnchantment(item, "MENDING", 1);

        if (name.endsWith("_SWORD")) {
            addEnchantment(item, "SHARPNESS", 10);
            addEnchantment(item, "FIRE_ASPECT", 3);
            addEnchantment(item, "LOOTING", 5);
            addEnchantment(item, "SWEEPING_EDGE", 5);
        } else if (name.endsWith("_PICKAXE") || name.endsWith("_AXE") || name.endsWith("_SHOVEL") || name.endsWith("_HOE")) {
            addEnchantment(item, "EFFICIENCY", 10);
            addEnchantment(item, "FORTUNE", 5);
        } else if (name.endsWith("_HELMET") || name.endsWith("_CHESTPLATE") || name.endsWith("_LEGGINGS") || name.endsWith("_BOOTS")) {
            addEnchantment(item, "PROTECTION", 10);
            addEnchantment(item, "THORNS", 5);
            if (name.endsWith("_HELMET")) {
                addEnchantment(item, "RESPIRATION", 5);
                addEnchantment(item, "AQUA_AFFINITY", 1);
            }
            if (name.endsWith("_BOOTS")) {
                addEnchantment(item, "FEATHER_FALLING", 10);
                addEnchantment(item, "DEPTH_STRIDER", 5);
            }
        } else if (name.equals("BOW")) {
            addEnchantment(item, "POWER", 10);
            addEnchantment(item, "FLAME", 1);
            addEnchantment(item, "PUNCH", 3);
            addEnchantment(item, "INFINITY", 1);
        } else if (name.equals("CROSSBOW")) {
            addEnchantment(item, "QUICK_CHARGE", 5);
            addEnchantment(item, "MULTISHOT", 1);
        } else if (name.equals("TRIDENT")) {
            addEnchantment(item, "LOYALTY", 5);
            addEnchantment(item, "IMPALING", 10);
            addEnchantment(item, "CHANNELING", 1);
        } else if (name.equals("FISHING_ROD")) {
            addEnchantment(item, "LUCK_OF_THE_SEA", 5);
            addEnchantment(item, "LURE", 5);
        } else if (name.equals("SHEARS")) {
            addEnchantment(item, "EFFICIENCY", 10);
        }
    }

    private void addEnchantment(ItemStack item, String name, int level) {
        XEnchantment.matchXEnchantment(name).ifPresent(enchantment ->
                item.addUnsafeEnchantment(enchantment.getEnchant(), level));
    }
}