Noah Matos

make me a plugin that if i do /givs <potion> it gives me a shalker with the potion

Kodari AI
KodariYesterday at 2:42 pm 1
PotionShulkerGive
A Minecraft plugin that provides a /givs command allowing players to receive a shulker box filled with a specified potion. When a player executes /givs &lt;potion&gt;, the plugin validates the potion type, creates a shulker box containing 27 stacks of that potion, and places it in the player's inventory or drops it at their location if inventory is full. Supports all vanilla potion types including splash and lingering variants, with proper permission checks and configurable messages. Includes tab completion for potion names and handles invalid inputs gracefully with clear feedback.

I’ll make /givs <potion> give you a shulker box filled with 27 of that potion, with tab completion for potion types.

Created /givs <potion>, which gives you a shulker filled with 27 potions. Use tab completion to see available types, such as /givs strength.

The command requires potionshulkers.givs, granted to operators by default.

Noah Matos

make it so i can also do /givs <potion> <splash yes no> <color of shulker box>

Kodari AI
KodariYesterday at 2:46 pm 1

I’ll keep the existing one-argument command and add optional splash and shulker-color arguments, with tab completion.

Updated /givs with optional splash and shulker color arguments.

Example: /givs strength yes blue

Use no for regular potions and default for an uncolored shulker. The original /givs strength still works.

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

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.block.ShulkerBox;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionType;

public final class PotionShulkers extends JavaPlugin implements TabExecutor {
    @Override
    public void onEnable() {
        getCommand("givs").setExecutor(this);
        getCommand("givs").setTabCompleter(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;
        }
        if (args.length < 1 || args.length > 3) {
            sender.sendMessage(ChatColor.RED + "Usage: /givs <potion> [splash: yes|no] [shulker color]");
            return true;
        }

        PotionType type;
        try {
            type = PotionType.valueOf(args[0].toUpperCase(Locale.ROOT));
        } catch (IllegalArgumentException ex) {
            sender.sendMessage(ChatColor.RED + "Unknown potion type. Use tab completion to see available types.");
            return true;
        }

        boolean splash = false;
        if (args.length >= 2) {
            if (!args[1].equalsIgnoreCase("yes") && !args[1].equalsIgnoreCase("no")) {
                sender.sendMessage(ChatColor.RED + "Splash must be yes or no.");
                return true;
            }
            splash = args[1].equalsIgnoreCase("yes");
        }

        String boxMaterial = "SHULKER_BOX";
        if (args.length == 3 && !args[2].equalsIgnoreCase("default")) {
            try {
                boxMaterial = DyeColor.valueOf(args[2].toUpperCase(Locale.ROOT)).name() + "_SHULKER_BOX";
            } catch (IllegalArgumentException ex) {
                sender.sendMessage(ChatColor.RED + "Unknown shulker color. Use tab completion to see available colors.");
                return true;
            }
        }

        ItemStack potion = XMaterial.matchXMaterial(splash ? "SPLASH_POTION" : "POTION")
                .map(XMaterial::parseItem).orElse(null);
        ItemStack box = XMaterial.matchXMaterial(boxMaterial).map(XMaterial::parseItem).orElse(null);
        if (potion == null || box == null) {
            sender.sendMessage(ChatColor.RED + "That potion or shulker box is not available on this server.");
            return true;
        }
        PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
        potionMeta.setBasePotionType(type);
        potion.setItemMeta(potionMeta);

        BlockStateMeta boxMeta = (BlockStateMeta) box.getItemMeta();
        ShulkerBox shulker = (ShulkerBox) boxMeta.getBlockState();
        for (int slot = 0; slot < shulker.getInventory().getSize(); slot++) {
            shulker.getInventory().setItem(slot, potion.clone());
        }
        boxMeta.setBlockState(shulker);
        box.setItemMeta(boxMeta);

        Player player = (Player) sender;
        if (player.getInventory().firstEmpty() == -1) {
            player.sendMessage(ChatColor.RED + "You need an empty inventory slot.");
            return true;
        }
        player.getInventory().addItem(box);
        player.sendMessage(ChatColor.GREEN + "You received a shulker box filled with "
                + type.name().toLowerCase(Locale.ROOT).replace('_', ' ') + " potions.");
        return true;
    }

    @Override
    public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
        List<String> matches = new ArrayList<>();
        if (args.length == 1) {
            String prefix = args[0].toLowerCase(Locale.ROOT);
            for (PotionType type : PotionType.values()) {
                String name = type.name().toLowerCase(Locale.ROOT);
                if (name.startsWith(prefix)) {
                    matches.add(name);
                }
            }
        } else if (args.length == 2) {
            String prefix = args[1].toLowerCase(Locale.ROOT);
            for (String option : new String[] {"yes", "no"}) {
                if (option.startsWith(prefix)) {
                    matches.add(option);
                }
            }
        } else if (args.length == 3) {
            String prefix = args[2].toLowerCase(Locale.ROOT);
            if ("default".startsWith(prefix)) {
                matches.add("default");
            }
            for (DyeColor color : DyeColor.values()) {
                String name = color.name().toLowerCase(Locale.ROOT);
                if (name.startsWith(prefix)) {
                    matches.add(name);
                }
            }
        }
        return matches;
    }
}