.bencito

A mod with cat ears, and maid outfits. There should be 6 full maid outfits in different colour with headbands. The headbands and catears should be able to be crafted into 1 item wich can be put on, ALL items should be able to be put on. there should also be tails wich can also be put on, and the tails should be able to be crafted together with the leggings to craft a leggingtail. There also should be some skirts wich can also be put on as pants.

Kodari AI
KodariOct 3 at 7:40 am 1
MaidCatCosmetics
A Minecraft plugin adding wearable cat ears, maid outfits, and tails. Six full maid outfits in different colors with matching headbands are included. Cat ears and headbands can be crafted together into a combined wearable head item. Tails are wearable and can be crafted with leggings to create a legging-tail hybrid. Skirts are also provided and worn in the pants slot. All items are equippable armor pieces with custom textures and crafting recipes.
  1. Create the Paper plugin scaffold and wearable item metadata.

  2. Add recipes for six color-matched maid sets, skirts, tails, and cat-ear/headband combinations.

  3. Validate the two combination recipes so only the custom wearable ingredients work.

Created the MaidWearables Paper plugin with recipes for six colored maid sets, matching headbands, wearable cat ears, tails, skirts, and the cat-ear headband and leggingtail combinations. Combination recipes only accept the custom wearable items.

The items use dyed vanilla leather armor, so they’re wearable but won’t have custom 3D ear or tail models without a resource pack.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 234
src/main/java/com/kodari/maidwearables/MaidWearablesPlugin.java
package com.kodari.maidwearables;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Color;
import org.bukkit.Keyed;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.List;
import java.util.Map;

public final class MaidWearablesPlugin extends JavaPlugin implements Listener {
    private NamespacedKey wearableIdKey;
    private List<Palette> palettes;

    @Override
    public void onEnable() {
        wearableIdKey = new NamespacedKey(this, "wearable_id");
        palettes = List.of(
                new Palette("black", "Black", "BLACK_DYE", 0x29242B),
                new Palette("white", "White", "WHITE_DYE", 0xF2EEE7),
                new Palette("pink", "Pink", "PINK_DYE", 0xF08DB7),
                new Palette("blue", "Blue", "LIGHT_BLUE_DYE", 0x65B9E8),
                new Palette("red", "Red", "RED_DYE", 0xC83D43),
                new Palette("purple", "Purple", "PURPLE_DYE", 0x9957C8)
        );
        getServer().getPluginManager().registerEvents(this, this);
        registerRecipes();
    }

    private void registerRecipes() {
        for (Palette palette : palettes) {
            Color color = Color.fromRGB(palette.rgb());
            ItemStack headband = wearable("headband_" + palette.id(), palette.label() + " Maid Headband", "LEATHER_HELMET", color);
            shapeless("headband_" + palette.id(), headband, "LEATHER", palette.dye());

            ItemStack chestplate = wearable("maid_" + palette.id() + "_chestplate", palette.label() + " Maid Bodice", "LEATHER_CHESTPLATE", color);
            shaped("maid_" + palette.id() + "_chestplate", chestplate,
                    new String[]{"L L", "LDL", "LLL"}, Map.of('L', "LEATHER", 'D', palette.dye()));

            ItemStack leggings = wearable("maid_" + palette.id() + "_leggings", palette.label() + " Maid Leggings", "LEATHER_LEGGINGS", color);
            shaped("maid_" + palette.id() + "_leggings", leggings,
                    new String[]{"LLL", "L L", "LDL"}, Map.of('L', "LEATHER", 'D', palette.dye()));

            ItemStack boots = wearable("maid_" + palette.id() + "_boots", palette.label() + " Maid Boots", "LEATHER_BOOTS", color);
            shaped("maid_" + palette.id() + "_boots", boots,
                    new String[]{"L L", "LDL"}, Map.of('L', "LEATHER", 'D', palette.dye()));

            ItemStack skirt = wearable("skirt_" + palette.id(), palette.label() + " Maid Skirt", "LEATHER_LEGGINGS", color);
            shaped("skirt_" + palette.id(), skirt,
                    new String[]{"LLL", "L L", "D  "}, Map.of('L', "LEATHER", 'D', palette.dye()));

            ItemStack tail = wearable("tail_" + palette.id(), palette.label() + " Cat Tail", "LEATHER_LEGGINGS", color);
            shaped("tail_" + palette.id(), tail,
                    new String[]{"SDS", " H "}, Map.of('S', "STRING", 'D', palette.dye(), 'H', "RABBIT_HIDE"));
        }

        ItemStack catEars = wearable("cat_ears", "Cat Ears", "LEATHER_HELMET", Color.fromRGB(0x29242B));
        shaped("cat_ears", catEars,
                new String[]{"W W", " H "}, Map.of('W', "BLACK_WOOL", 'H', "RABBIT_HIDE"));

        shapeless("craft_cat_maid_headband",
                wearable("cat_maid_headband", "Cat-Ear Maid Headband", "LEATHER_HELMET", Color.WHITE),
                "LEATHER_HELMET", "LEATHER_HELMET");
        shapeless("craft_leggingtail",
                wearable("leggingtail", "Leggingtail", "LEATHER_LEGGINGS", Color.WHITE),
                "LEATHER_LEGGINGS", "LEATHER_LEGGINGS");
    }

    private ItemStack wearable(String id, String name, String materialName, Color color) {
        ItemStack item = new ItemStack(material(materialName));
        ItemMeta meta = item.getItemMeta();
        if (meta instanceof LeatherArmorMeta leatherMeta) {
            leatherMeta.setColor(color);
        }
        meta.setDisplayName("§f" + name);
        meta.setLore(List.of("§7Wearable cosmetic item"));
        meta.getPersistentDataContainer().set(wearableIdKey, PersistentDataType.STRING, id);
        item.setItemMeta(meta);
        return item;
    }

    private void shaped(String key, ItemStack result, String[] shape, Map<Character, String> ingredients) {
        ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(this, key), result);
        recipe.shape(shape);
        ingredients.forEach((character, materialName) -> recipe.setIngredient(character, material(materialName)));
        getServer().addRecipe(recipe);
    }

    private void shapeless(String key, ItemStack result, String... ingredients) {
        ShapelessRecipe recipe = new ShapelessRecipe(new NamespacedKey(this, key), result);
        for (String ingredient : ingredients) {
            recipe.addIngredient(material(ingredient));
        }
        getServer().addRecipe(recipe);
    }

    private Material material(String name) {
        return XMaterial.matchXMaterial(name)
                .map(XMaterial::parseMaterial)
                .orElseThrow(() -> new IllegalStateException("Unsupported material: " + name));
    }

    @EventHandler
    public void onPrepareCraft(PrepareItemCraftEvent event) {
        String recipeKey = recipeKey(event.getRecipe());
        if (!isCombinationRecipe(recipeKey)) {
            return;
        }
        ItemStack result = combinationResult(recipeKey, event.getInventory().getMatrix());
        event.getInventory().setResult(result);
    }

    @EventHandler
    public void onCraft(CraftItemEvent event) {
        String recipeKey = recipeKey(event.getRecipe());
        if (isCombinationRecipe(recipeKey)
                && combinationResult(recipeKey, ((CraftingInventory) event.getInventory()).getMatrix()) == null) {
            event.setCancelled(true);
        }
    }

    private String recipeKey(org.bukkit.inventory.Recipe recipe) {
        return recipe instanceof Keyed keyed ? keyed.getKey().getKey() : "";
    }

    private boolean isCombinationRecipe(String key) {
        return key.equals("craft_cat_maid_headband") || key.equals("craft_leggingtail");
    }

    private ItemStack combinationResult(String recipeKey, ItemStack[] matrix) {
        ItemStack first = null;
        ItemStack second = null;
        String firstId = null;
        String secondId = null;

        for (ItemStack item : matrix) {
            String id = wearableId(item);
            if (id == null) {
                continue;
            }
            if (first == null) {
                first = item;
                firstId = id;
            } else if (second == null) {
                second = item;
                secondId = id;
            }
        }
        if (first == null || second == null) {
            return null;
        }

        if (recipeKey.equals("craft_cat_maid_headband")) {
            ItemStack band = firstId.startsWith("headband_") ? first : secondId.startsWith("headband_") ? second : null;
            String otherId = band == first ? secondId : band == second ? firstId : "";
            if (band == null || !otherId.equals("cat_ears")) {
                return null;
            }
            return wearable("cat_maid_headband", "Cat-Ear Maid Headband", "LEATHER_HELMET", armorColor(band));
        }

        if (recipeKey.equals("craft_leggingtail")) {
            String pantsId = isPants(firstId) ? firstId : isPants(secondId) ? secondId : null;
            String tailId = firstId.startsWith("tail_") ? firstId : secondId.startsWith("tail_") ? secondId : null;
            ItemStack pants = isPants(firstId) ? first : isPants(secondId) ? second : null;
            if (pantsId == null || tailId == null || pants == null) {
                return null;
            }
            return wearable("leggingtail", "Leggingtail", "LEATHER_LEGGINGS", armorColor(pants));
        }
        return null;
    }

    private boolean isPants(String id) {
        return id.startsWith("maid_") && id.endsWith("_leggings") || id.startsWith("skirt_");
    }

    private String wearableId(ItemStack item) {
        if (item == null || item.getType().isAir() || !item.hasItemMeta()) {
            return null;
        }
        return item.getItemMeta().getPersistentDataContainer().get(wearableIdKey, PersistentDataType.STRING);
    }

    private Color armorColor(ItemStack item) {
        if (item.hasItemMeta() && item.getItemMeta() instanceof LeatherArmorMeta leatherMeta) {
            return leatherMeta.getColor();