foxiak_gg

make light weigth apple plugin (makes recipe for golden apples that uses 4 gold instead of 8)

Kodari AI
KodariJul 25 at 8:53 pm 3

I’ll create a lightweight plugin that adds a four-gold golden apple recipe.

GoldenAppleRecipe
GoldenAppleRecipe adds an alternative golden apple crafting recipe that uses four gold ingots instead of the vanilla eight. The recipe places an apple in the center with gold ingots on the four cardinal sides, creating a balanced cross-shaped crafting layout. It is lightweight, requires no configuration, integrates with standard Bukkit crafting, and supports modern Minecraft versions through XSeries material compatibility.
Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 86
src/main/java/com/kodari/goldenapplerecipe/GoldenAppleRecipePlugin.java
package com.kodari.goldenapplerecipe;

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 class GoldenAppleRecipePlugin extends JavaPlugin {

    private NamespacedKey recipeKey;

    @Override
    public void onEnable() {
        recipeKey = new NamespacedKey(this, "four_gold_golden_apple");

        ItemStack goldenApple = XMaterial.matchXMaterial("GOLDEN_APPLE")
                .map(XMaterial::parseItem)
                .orElse(null);
        Material goldIngot = XMaterial.matchXMaterial("GOLD_INGOT")
                .map(XMaterial::parseMaterial)
                .orElse(null);
        Material apple = XMaterial.matchXMaterial("APPLE")
                .map(XMaterial::parseMaterial)
                .orElse(null);

        if (goldenApple == null || goldIngot == null || apple == null) {
            getLogger().severe("Unable to load the golden apple recipe materials.");
            return;
        }

        ShapedRecipe recipe = new ShapedRecipe(recipeKey, goldenApple);
        recipe.shape(" G ", "GAG", " G ");
        recipe.setIngredient('G', goldIngot);
        recipe.setIngredient('A', apple);

        Bukkit.addRecipe(recipe);
    }

    @Override
    public void onDisable() {
        if (recipeKey != null) {
            Bukkit.removeRecipe(recipeKey);
        }
    }
}