Poludnie

make me a plugin for 1.21.11 called Mango it adds a orange dye mango item called &6Mango whenever you right click it you get 1 positive effect from this list: strength, speed, regen, resistance, absorption, luck, haste, dolhpin grace, fire resistance, health boost and you can spam click it to stack effects each time you click you get 1 effect for 5 seconds (the seconds stack no the level) and a burp sounds plays every time and cool particles

Kodari AI
KodariNov 9 at 2:12 am 1
MangoEffects
A Minecraft 1.21.11 plugin adding a custom orange dye item named &6Mango. When right-clicked, it grants one random positive effect from a list including strength, speed, regeneration, resistance, absorption, luck, haste, dolphin grace, fire resistance, and health boost. Spam-clicking stacks duration (5 seconds per click, not amplifier level). Each use plays a burp sound and spawns cool particles, creating an engaging and interactive gameplay mechanic.
  • Add a reusable Mango item and a /mango command to obtain it.

  • Apply random five-second effects, stacking duration on repeat clicks, with a burp and particles.

Created Mango for Minecraft 1.21.11. Use /mango as an operator to get the reusable item; right-clicking adds five seconds to a random listed effect and plays a burp with particles.

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

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.particles.XParticle;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.ChatColor;
import org.bukkit.NamespacedKey;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
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.potion.PotionEffect;

public final class MangoPlugin extends JavaPlugin implements Listener {
    private static final List<String> EFFECTS = List.of(
            "STRENGTH", "SPEED", "REGENERATION", "RESISTANCE", "ABSORPTION",
            "LUCK", "HASTE", "DOLPHINS_GRACE", "FIRE_RESISTANCE", "HEALTH_BOOST"
    );
    private NamespacedKey mangoKey;

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

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage("Only players can use this command.");
            return true;
        }
        ItemStack mango = XMaterial.matchXMaterial("ORANGE_DYE").map(XMaterial::parseItem).orElse(null);
        if (mango == null) {
            player.sendMessage(ChatColor.RED + "The Mango item is unavailable on this server.");
            return true;
        }
        ItemMeta meta = mango.getItemMeta();
        meta.setDisplayName(ChatColor.GOLD + "Mango");
        meta.getPersistentDataContainer().set(mangoKey, PersistentDataType.BYTE, (byte) 1);
        mango.setItemMeta(meta);
        player.getInventory().addItem(mango).values().forEach(item ->
                player.getWorld().dropItemNaturally(player.getLocation(), item));
        player.sendMessage(ChatColor.GOLD + "You received a Mango!");
        return true;
    }

    @EventHandler
    public void onInteract(PlayerInteractEvent event) {
        if (event.getHand() != EquipmentSlot.HAND && event.getHand() != EquipmentSlot.OFF_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;
        Byte marker = item.getItemMeta().getPersistentDataContainer().get(mangoKey, PersistentDataType.BYTE);
        if (marker == null || marker != 1) return;

        event.setCancelled(true);
        Player player = event.getPlayer();
        String effectName = EFFECTS.get(ThreadLocalRandom.current().nextInt(EFFECTS.size()));
        XPotion.matchXPotion(effectName).ifPresent(effect -> {
            PotionEffect fresh = effect.buildPotionEffect(100, 0);
            PotionEffect existing = player.getPotionEffect(fresh.getType());
            if (existing != null && existing.getDuration() < 0) return;
            int remaining = existing == null ? 0 : existing.getDuration();
            int duration = (int) Math.min((long) remaining + 100, Integer.MAX_VALUE);
            player.addPotionEffect(effect.buildPotionEffect(duration, 0), true);
        });
        XSound.matchXSound("ENTITY_PLAYER_BURP").ifPresent(sound -> sound.play(player));
        XParticle.of("HAPPY_VILLAGER").ifPresent(particle ->
                player.getWorld().spawnParticle(particle.get(), player.getLocation().add(0, 1, 0), 20, 0.4, 0.5, 0.4, 0.05));
    }
}