Nightreaper800
📎 1 file 4,937 chars
📄
pasted-code-1787079798983.txt
txt 182 lines
▶
Create a **Paper 1.21.11 Minecraft plugin** called **ReaperRecipe** that allows server admins to create, manage, edit, delete, and view completely custom crafting recipes through an easy INVENTORY GUI system.

### Main Command

* `/reaperrecipe` — Opens the main recipe INVENTORY GUI.
* `/reaperrecipe create` — Opens the recipe creation INVENTORY GUI.
* `/reaperrecipe reload` — Reloads all recipe data/configuration.
* Add proper permission support, for example:

  * `reaperrecipe.admin`
  * `reaperrecipe.use`

### Recipe Creation INVENTORY GUI

Create a clean chest-style INVENTORY GUI where the admin can visually create a recipe.

The INVENTORY GUI should contain:

* A **3x3 crafting grid** where the admin places the required ingredients.
* An **output slot** where the admin places the item that should be crafted.
* A **Save Recipe** button.
* A **Cancel** button.
* A **Clear Grid** button.

When the admin clicks **Save Recipe**:

1. Validate that ingredients and output exist.
2. Ask the admin for a unique recipe ID/name through chat or an anvil INVENTORY GUI.
3. Save the recipe permanently.
4. Register the recipe with the server.
5. Send a confirmation message.

### `/reaperrecipe` Main INVENTORY GUI

When `/reaperrecipe` is executed, open a INVENTORY GUI displaying all custom recipes.

Each recipe should show:

* Recipe output item
* Recipe name/ID
* Ingredients
* Custom item name/lore/enchantments if applicable

Add navigation:

* Previous Page
* Next Page
* Search Recipe
* Create Recipe
* Edit Recipe
* Delete Recipe
* Close

### Edit Recipe

Admins should be able to click an existing recipe and choose **Edit**.

The plugin should open the same 3x3 recipe editor with the existing recipe already loaded.

The admin can:

* Change ingredients
* Change output
* Change item amounts
* Replace items
* Clear slots
* Save changes
* Cancel changes

After saving, unregister the old recipe and register the updated recipe.

### Delete Recipe

When an admin selects **Delete Recipe**:

* Show a confirmation INVENTORY GUI.
* Display the recipe being deleted.
* Add **Confirm Delete** and **Cancel** buttons.
* After confirmation, remove the recipe permanently and unregister it from the server.

### Custom Item Support

Recipes should support:

* Normal Minecraft items
* Item amounts
* Custom item names
* Custom lore
* Enchantments
* CustomModelData
* Potion items
* Player heads
* Items with NBT/PersistentDataContainer data where possible

The recipe system should preferably identify custom ingredients by their relevant item data rather than only checking the material type.

### Recipe Storage

Store recipes in a clear configuration/data file such as:

`plugins/ReaperRecipe/recipes.yml`

Each recipe should have:

* Unique ID
* Ingredients
* Ingredient slots
* Output item
* Amount
* Custom item data
* Enabled/disabled status

Make the storage system easy to edit manually as well.

### Recipe Registration

Use Bukkit/Paper's recipe API properly.

Support:

* Shaped recipes
* Different ingredient combinations
* Multiple custom recipes
* Unique recipe keys/namespaces

Prevent recipe-key conflicts and handle invalid recipes safely.

### Permissions

Implement:

* `reaperrecipe.use` — Allows players to use `/reaperrecipe` to view recipes.
* `reaperrecipe.admin` — Allows creating, editing, deleting, and managing recipes.

Admins should also have access to all management commands.

### Security / INVENTORY GUI Protection

Players must not be able to:

* Take items from protected INVENTORY GUI slots.
* Move INVENTORY GUI items using shift-click.
* Drag items into protected INVENTORY GUI slots.
* Duplicate ingredients or outputs.
* Exploit the recipe editor to obtain items.
* Access admin functions without permission.

Properly handle inventory close events and return any temporary ingredients safely to the admin.

### User Experience

Make the INVENTORY GUI professional and easy to understand.

Use configurable:

* INVENTORY GUI titles
* Item names
* Item lore
* Sounds
* Messages
* INVENTORY GUI size
* Pagination size

All messages should be configurable in `messages.yml`.

### Additional Features

Add:

* `/reaperrecipe list`
* `/reaperrecipe info `
* `/reaperrecipe delete `
* `/reaperrecipe edit `
* `/reaperrecipe enable `
* `/reaperrecipe disable `

Add tab completion for all commands and recipe IDs.

The plugin should be optimized for a production SMP server, use proper event handling, avoid unnecessary tasks, and be compatible with **Paper 1.21.11**.

Provide the complete source code, `plugin.yml`, default configuration files, permissions, commands, INVENTORY GUI system, recipe manager, recipe serializer/deserializer, and installation instructions.
Kodari AI
KodariAug 18 at 7:09 pm 4
ReaperRecipe
A comprehensive Paper 1.21.11 plugin providing an intuitive inventory GUI system for server admins to visually create, edit, delete, and manage custom crafting recipes. Features include a 3x3 crafting grid editor with save/cancel/clear buttons, paginated recipe browser with search functionality, confirmation dialogs for deletions, full custom item support including enchantments, custom model data, potions, and player heads, persistent YAML storage, and proper recipe registration with unique namespaced keys. Includes configurable messages, sounds, permissions, tab completion, and robust inventory protection against item duplication exploits.
  1. Create the Gradle/Paper project metadata and default YAML configuration.

  2. Add recipe models, YAML persistence, server registration, and exact-item craft validation.

  3. Add the protected inventory GUI framework and recipe management screens.

  4. Add command handling, tab completion, chat input, permissions, and plugin bootstrap.

  1. Built the complete Paper 1.21.11 ReaperRecipe project with Gradle setup, plugin metadata, permissions, and default configuration files.

  2. Added YAML recipe persistence supporting full ItemStack data, including custom names, lore, enchantments, model data, potion data, player heads, and persistent data.

  3. Added shaped recipe registration with exact-item matching, enable/disable support, conflict-safe namespaced keys, and crafting validation.

  4. Added protected inventory GUIs for browsing, pagination, searching, creating, editing, deleting, confirming deletion, and safely returning editor items.

  5. Added /reaperrecipe commands, tab completion, chat-based recipe ID/search input, configurable messages, and installation documentation.

Nightreaper800

i can not create recipe

Kodari AI
KodariAug 18 at 7:20 pm 1
  1. Fix the editor save flow so it validates the grid before requesting the recipe ID.

  2. Make recipe registration failures visible instead of silently appearing as a failed save.

  3. Allow /reaperrecipe create <id> as a reliable alternative to chat ID entry.

Fixed the recipe creation flow:

  • The Save Recipe button now checks that both an output and at least one ingredient exist before asking for an ID.

  • Added a reliable command format:

    Plain Text
    /reaperrecipe create my_recipe
    

    This lets you enter the ID directly without using chat input.

  • Improved recipe registration logging so server rejection errors are visible in console.

  • Updated the recipe ID prompt.

Use this flow:

  1. Give yourself permission:

    Plain Text
    /lp user YOUR_NAME permission set reaperrecipe.admin true
    
  2. Open the editor:

    Plain Text
    /reaperrecipe create my_recipe
    
  3. Place ingredients in the 3×3 grid.

  4. Place the result item in the output slot.

  5. Click the green Save Recipe button.

If you use only:

Plain Text
/reaperrecipe create

then click Save Recipe, type the recipe ID in chat, and keep the editor inventory open while entering it.

Nightreaper800

nhi ho rhi

Kodari AI
KodariAug 18 at 7:23 pm 1
  1. Editor के save/click flow को सीधे ठीक करूँगा ताकि बटन हर स्थिति में काम करे।

  2. Recipe register होने में error आए तो recipe data न बिगड़े और सही message मिले।

  3. /reaperrecipe create <id> और GUI save के लिए स्पष्ट feedback जोड़ूँगा।

समस्या का असली कारण recipe registration flow में है: असफल registration के बाद recipe memory में रह जाती थी, और edge slots वाली 3×3 shape Paper reject कर सकता था। इसे atomic save और trimmed shape से ठीक कर रहा हूँ।

अब save flow ठीक कर दिया है।

मुख्य समस्या यह थी कि 3×3 grid में बीच या किनारे वाले slots इस्तेमाल करने पर Paper recipe reject कर रहा था। अब recipe grid अपने-आप सही आकार में trim होकर register होगी। साथ ही:

  • Admin permission अपने-आप reaperrecipe.use भी देगी।

  • Recipe save fail होने पर data खराब नहीं होगी।

  • Server console में असली error दिखाई देगा।

  • Save button पर स्पष्ट error message आएगा।

Plugin को दोबारा build करके server में नया .jar डालें और server restart करें।

फिर यह command चलाएँ:

Plain Text
/reaperrecipe create test_recipe

इसके बाद:

  1. 3×3 grid में ingredient रखें।

  2. Output slot में result item रखें।

  3. Green Save Recipe button दबाएँ।

अगर फिर भी save नहीं होती, server console में आने वाली यह line भेजें:

Plain Text
Could not register recipe

और यह भी सुनिश्चित करें कि permission हो:

Plain Text
/lp user YOUR_NAME permission set reaperrecipe.admin true
Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
README.md
settings.gradle
Code
21 1,475
src/main/java/com/kodari/reaperrecipe/ReaperRecipePlugin.java
package com.kodari.reaperrecipe;

import com.kodari.reaperrecipe.command.ReaperRecipeCommand;
import com.kodari.reaperrecipe.gui.EditorGUI;
import com.kodari.reaperrecipe.gui.GUIListener;
import com.kodari.reaperrecipe.gui.GUIManager;
import com.kodari.reaperrecipe.gui.MainGUI;
import com.kodari.reaperrecipe.recipe.RecipeListener;
import com.kodari.reaperrecipe.recipe.RecipeManager;
import com.kodari.reaperrecipe.util.ItemUtil;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;

import java.io.File;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

public class ReaperRecipePlugin extends JavaPlugin implements Listener {
    private GUIManager guiManager;
    private RecipeManager recipeManager;
    private FileConfiguration messages;
    private final Map<UUID, PendingRequest> pending = new ConcurrentHashMap<>();

    @Override
    public void onEnable() {
        saveDefaultConfig();
        saveResourceIfMissing("messages.yml");
        saveResourceIfMissing("recipes.yml");
        messages = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "messages.yml"));
        guiManager = new GUIManager();
        recipeManager = new RecipeManager(this);
        recipeManager.reload();
        Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
        Bukkit.getPluginManager().registerEvents(new RecipeListener(recipeManager), this);
        Bukkit.getPluginManager().registerEvents(this, this);
        ReaperRecipeCommand command = new ReaperRecipeCommand(this);
        getCommand("reaperrecipe").setExecutor(command);
        getCommand("reaperrecipe").setTabCompleter(command);
    }

    public void reloadPlugin() {
        reloadConfig();
        messages = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "messages.yml"));
        recipeManager.reload();
    }

    public GUIManager getGuiManager() {
        return guiManager;
    }

    public RecipeManager getRecipeManager() {
        return recipeManager;
    }

    public String msgRaw(String path) {
        return messages.getString(path, path);
    }

    public String color(String message) {
        return ItemUtil.translate(message);
    }

    public void send(CommandSender sender, String path, String... replacements) {
        String message = msgRaw(path);
        for (int index = 0; index + 1 < replacements.length; index += 2) {
            message = message.replace(replacements[index], replacements[index + 1]);
        }
        sender.sendMessage(color(msgRaw("prefix") + message));
    }

    public void sendRaw(CommandSender sender, String path, String... replacements) {
        String message = msgRaw(path);
        for (int index = 0; index + 1 < replacements.length; index += 2) {
            message = message.replace(replacements[index], replacements[index + 1]);
        }
        sender.sendMessage(color(message));
    }

    public void requestRecipeId(Player player, EditorGUI editor) {
        pending.put(player.getUniqueId(), PendingRequest.naming(editor));
        send(player, "prompt-recipe-id");
    }

    public void requestSearch(Player player, MainGUI gui) {
        pending.put(player.getUniqueId(), PendingRequest.search());
        send(player, "prompt-search");
    }

    public void cancelPending(UUID uuid) {
        pending.remove(uuid);
    }

    @EventHandler
    public void onChat(AsyncPlayerChatEvent event) {
        PendingRequest request = pending.get(event.getPlayer().getUniqueId());
        if (request == null) {
            return;
        }
        event.setCancelled(true);
        String input = event.getMessage().trim();
        Bukkit.getScheduler().runTask(this, () -> {
            pending.remove(event.getPlayer().getUniqueId());
            if (input.equalsIgnoreCase("cancel")) {
                send(event.getPlayer(), "search-cancelled");
            } else if (request.naming) {
                request.editor.saveWithId(event.getPlayer(), input);
            } else {
                getGuiManager().open(new MainGUI(this, 0, input), event.getPlayer());
            }
        });
    }

    private void saveResourceIfMissing(String resource) {
        File file = new File(getDataFolder(), resource);
        if (!file.exists()) {
            saveResource(resource, false);
        }
    }

    private static class PendingRequest {
        private final boolean naming;
        private final EditorGUI editor;

        private PendingRequest(boolean naming, EditorGUI editor) {
            this.naming = naming;
            this.editor = editor;
        }

        private static PendingRequest naming(EditorGUI editor) {
            return new PendingRequest(true, editor);
        }

        private static PendingRequest search() {
            return new PendingRequest(false, null);
        }
    }
}