cqy9

Make me a plugin named kzvxlyEzAnvils that when like an iron is put in the middle top of the crafting table and iron block at the center middle like row 2 and below 1 iron make an anvil and remove the original vanilla recipe and make kzvxly the author

Kodari AI
KodariNov 10 at 2:10 pm 1
KzvxlyEzAnvils
A Minecraft plugin that replaces the vanilla anvil recipe with a custom crafting recipe. Players craft an anvil by placing an iron ingot in the top-center slot, an iron block in the center-middle slot, and one iron ingot directly below the iron block. The plugin removes the original vanilla anvil recipe entirely and registers the new custom recipe, with kzvxly set as the plugin author.
  1. Add the plugin descriptor with kzvxly as author.

  2. Register the three-slot iron recipe and remove vanilla’s anvil recipe on startup.

Created kzvxlyEzAnvils with kzvxly as the author. It removes the vanilla anvil recipe and adds a shaped recipe: iron ingot in the top center, iron block in the middle center, and iron ingot in the bottom center.

Kodari can make mistakes. Review important code before using.
Files
src
Code
2 42
src/main/java/com/kzvxlyezanvils/KzvxlyEzAnvils.java
package com.kzvxlyezanvils;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.java.JavaPlugin;

public final class KzvxlyEzAnvils extends JavaPlugin {
    @Override
    public void onEnable() {
        Bukkit.removeRecipe(new NamespacedKey("minecraft", "anvil"));

        Material ironIngot = XMaterial.matchXMaterial("IRON_INGOT")
                .map(XMaterial::parseMaterial)
                .orElse(null);
        Material ironBlock = XMaterial.matchXMaterial("IRON_BLOCK")
                .map(XMaterial::parseMaterial)
                .orElse(null);
        Material anvil = XMaterial.matchXMaterial("ANVIL")
                .map(XMaterial::parseMaterial)
                .orElse(null);

        if (ironIngot == null || ironBlock == null || anvil == null) {
            getLogger().severe("Could not resolve the materials required for the anvil recipe.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(this, "anvil"), new ItemStack(anvil));
        recipe.shape(" I ", " B ", " I ");
        recipe.setIngredient('I', ironIngot);
        recipe.setIngredient('B', ironBlock);
        Bukkit.addRecipe(recipe);
    }
}