B
๐Ÿ“Ž 1 file 4,712 chars
๐Ÿ“„
pasted-code-1779884970899.txt
txt 244 lines
โ–ถ
Create a COMPLETE Minecraft system called "Forge System" for my GenPvP server.

IMPORTANT:
- Use CLEAN modular code
- Use TEXT FORMAT ONLY (NO base64)
- Java 21
- Paper 1.21+
- Modern clean INVENTORY GUI system
- Fully configurable
- All messages configurable
- Sounds configurable
- Particles configurable
- Support custom items from my plugin
- INVENTORY GUI must look VERY VANILLA and CLEAN

====================================================
FORGE SYSTEM OVERVIEW
====================================================

Players use /forge to open a custom forging INVENTORY GUI.

The forge is used to UPGRADE T1 swords into T2 swords.

Recipe format:
[T1 Sword] + [Core] = [T2 Sword]

Example:
Strength Sword T1 + Strength Core = Strength Sword T2

====================================================
INVENTORY GUI REQUIREMENTS
====================================================

INVENTORY GUI SIZE:
- MUST be 3 rows (3x9)
- Title:
"&8โš’ Forge"

INVENTORY GUI STYLE:
- Vanilla styled
- Minimal
- Clean
- Inspired by vanilla smithing/anvil tables

LAYOUT:

TOP ROW:
Gray stained glass panes

MIDDLE ROW:
Slot 11 = Sword Input
Slot 13 = Decorative barrier/anvil icon
Slot 15 = Core Input

BOTTOM ROW:
Red stained glass panes

Result slot:
Slot 22 = Result item preview

Decorative items:
- Gray panes
- Red panes
- Black panes
- Anvil icon center

IMPORTANT:
- Prevent players from placing items in decorative slots
- Only slot 11 and slot 15 accept items

====================================================
FORGE FUNCTIONALITY
====================================================

Players place:
- T1 sword in slot 11
- Matching core in slot 15

Then:
- Result appears in slot 22

When clicked:
- Remove ingredients
- Give T2 sword
- Play upgrade effects
- Broadcast configurable message

====================================================
SETCORE COMMAND
====================================================

Create admin command:

/setcore 

Purpose:
- Saves the item in player's hand as a forge core

Example:
- Strength Core
- Zeus Core
- Frost Core

Store:
- Display name
- Lore
- Enchants
- Custom model data
- NBT if possible

Save to:
cores.yml

====================================================
FORGE RECIPES
====================================================

Create forge_recipes.yml

Example format:

strength:
  t1: "StrengthSword_T1"
  core: "Strength Core"
  result: "StrengthSword_T2"

zeus:
  t1: "ZeusSword_T1"
  core: "Zeus Core"
  result: "ZeusSword_T2"

frost:
  t1: "FrostSword_T1"
  core: "Frost Core"
  result: "FrostSword_T2"

====================================================
VALIDATION
====================================================

Make sure:
- Wrong core = no recipe
- Wrong sword = no recipe
- Only matching recipes work
- INVENTORY GUI updates instantly
- Shift click protected
- Dupes impossible
- Inventory exploits impossible

====================================================
FORGE EFFECTS
====================================================

When forging succeeds:

PLAY:
- Anvil use sound
- Beacon activate sound
- Level up sound

SPAWN PARTICLES:
- ENCHANT
- FIREWORK
- ELECTRIC_SPARK
- GLOW

Visual sequence:
1. Flash particles
2. Circular enchant swirl
3. Explosion pulse
4. Item upgraded

====================================================
SUCCESS TITLE
====================================================

Title:
"&6โš’ FORGED โš’"

Subtitle:
"&eYour weapon has ascended."

====================================================
FAILURE EFFECTS
====================================================

If invalid recipe:
- Play villager no sound
- Red particles
- Message:
"&cInvalid forge recipe."

====================================================
CONFIGURATION
====================================================

config.yml:
- sounds
- particles
- INVENTORY GUI title
- success messages
- forge cooldown
- broadcast toggle

====================================================
EXTRA FEATURES
====================================================

ADD:
- /reloadforge command
- Permission system
- Recipe manager
- Core manager
- INVENTORY GUI listener
- Async-safe saving
- Clean code comments

Permissions:
forge.use
forge.admin
forge.reload

====================================================
IMPORTANT
====================================================

Make the INVENTORY GUI feel EXTREMELY polished and smooth.

I want:
- Vanilla style
- Professional feel
- Smooth animations
- Clean forge logic
- Stable code
- No duplication bugs
- Instant recipe updating

Use proper object-oriented structure:
- managers
- listeners
- INVENTORY GUI classes
- recipe classes

The entire system should feel like a REAL RPG progression forge.
Kodari AI
KodariMay 27 at 12:47 pm 80,310 (v2)

Now I have a full picture of the project. Let me plan and build the entire Forge System:

  • New managers: ForgeManager, CoreManager, RecipeManager

  • New GUI: ForgeGui (inventory GUI class)

  • New listeners: ForgeGuiListener

  • New commands: ForgeCommand, SetCoreCommand, ReloadForgeCommand

  • New config files: forge_config.yml, cores.yml, forge_recipes.yml

  • Wire everything into DovySwordsPlugin

Now update DovySwordsPlugin to wire everything in, add forge_config.yml, forge_recipes.yml, cores.yml, and update plugin.yml.

Now create all the forge system files:

Now create the config files and update plugin.yml:

Now create all the Java source files and resource files:

The ForgeCommand needs a direct reference to ForgeGuiListener โ€” let me fix the architecture so the listener is stored on the plugin directly:

Now create all the actual Java source files:

Now create the resource files:

Now I need to fix the ForgeManager.getSwordId() method โ€” the PDC stores the raw SwordType.name() (e.g. STRENGTH) and tier as integer, so the ID should be STRENGTH_T1 style matching the recipe format. Let me align the recipe format with what the PDC actually stores:

All files look correct. Now I need to verify the buildResult method in ForgeManager โ€” the recipe result ID format is STRENGTHSword_T2 (uppercase enum name), and the method checks type.name() + "Sword_T2" which would produce STRENGTHSword_T2. That matches. The getSwordId method produces STRENGTHSword_T1 from PDC data. The recipe t1 is STRENGTHSword_T1. โœ…

Now I need to add the missing import for For

Everything looks clean. Now let me write all the actual Java source files that were โ€œcreatedโ€ but need real content:

Hereโ€™s a full breakdown of everything built:


Forge System โ€” Complete

Architecture

Layer
Class
Purpose
Data
ForgeRecipe
Immutable recipe POJO (id, t1, core, result)
Manager
RecipeManager
Loads/reloads
forge_recipes.yml
Manager
CoreManager
Saves/loads/matches cores from
cores.yml
Manager
ForgeManager
Cooldowns, recipe resolution, result building, effects
GUI
ForgeGui
Builds the 3-row inventory, decorative frame, result preview
Listener
ForgeGuiListener
All click/drag/close events, forge execution, fail effects
Command
ForgeCommand
/forge
โ€” opens GUI
Command
SetCoreCommand
/setcore <id>
โ€” saves held item as a core
Command
ReloadForgeCommand
/reloadforge
โ€” hot-reloads all forge configs

GUI Layout (3ร—9)

Plain Text
[G][G][G][G][G][G][G][G][G]   โ† Gray panes (row 1)
[G][G][โš”][G][โš’][G][โš”][G][G]   โ† Sword(11) | Anvil(13) | Core(15)
[R][R][R][R][โ– ][R][R][R][R]   โ† Red panes + Result(22, black pane/preview)

Key anti-exploit protections

  • All shift-clicks cancelled unconditionally

  • Drag events blocked on decorative + result slots

  • Result slot only accepts empty-cursor clicks (pickup = forge trigger)

  • Items returned to player on close, dropped if inventory full

  • Cooldown enforced before any forge execution

ID format

Sword PDC stores sword_type = "STRENGTH" + sword_tier = 1, so the resolved ID is STRENGTHSword_T1 โ€” matching exactly what forge_recipes.yml expects.

B

1st it should use the tier one swords automatically + there's only going to be one core that will be used for all to upgrade them, also remove that ugly red stained glass at the bottom, make the anvil at the middle bottom and make the middle middle slot barrier when there's nothing made, but when clicking the anvil it will craft the t2 if the right recipe which would be the /setcore item & a tier 1 sword

B

1st it should use the tier one swords automatically + there's only going to be one core that will be used for all to upgrade them, also remove that ugly red stained glass at the bottom, make the anvil at the middle bottom and make the middle middle slot barrier when there's nothing made, but when clicking the anvil it will craft the t2 if the right recipe which would be the /setcore item & a tier 1 sword

B

1st it should use the tier one swords automatically + there's only going to be one core that will be used for all to upgrade them, also remove that ugly red stained glass at the bottom, make the anvil at the middle bottom and make the middle middle slot barrier when there's nothing made, but when clicking the anvil it will craft the t2 if the right recipe which would be the /setcore item & a tier 1 sword

B

The compilation failed with this error:

code
Compilation failed with 17 error(s):

ERROR in src/main/java/com/dovyswords/forge/commands/SetPotsOfCoinsForgeCommand.java at line 9: class SetPotOfCoinsForgeCommand is public, should be declared in a file named SetPotOfCoinsForgeCommand.java
public class SetPotOfCoinsForgeCommand implements CommandExecutor {
       ^

ERROR in src/main/java/com/dovyswords/forge/managers/PotsOfCoinsManager.java at line 6: class PotOfCoinsManager is public, should be declared in a file named PotOfCoinsManager.java
public class PotOfCoinsManager {
       ^

ERROR in src/main/java/com/dovyswords/DovySwordsPlugin.java at line 24: cannot find symbol
import com.dovyswords.forge.commands.SetPotsOfCoinsForgeCommand;
                                    ^
  symbol: class SetPotsOfCoinsForgeCommand
  location: package com.dovyswords.forge.commands

ERROR in src/main/java/com/dovyswords/DovySwordsPlugin.java at line 35: cannot find symbol
    private PotOfCoinsManager potOfCoinsManager;
            ^
  symbol: class PotOfCoinsManager
  location: class DovySwordsPlugin

ERROR in src/main/java/com/dovyswords/forge/managers/ForgeManager.java at line 72: cannot find symbol
        if (!plugin.getPotOfCoinsManager().isValid(coins)) return false;
                   ^
  symbol: method getPotOfCoinsManager()
  location: variable plugin of type DovySwordsPlugin

ERROR in src/main/java/com/dovyswords/forge/listeners/ForgeGuiListener.java at line 48: cannot find symbol
            if (plugin.getForgeManager().isT1Sword(item)) {
                                        ^
  symbol: method isT1Sword(ItemStack)
  location: class ForgeManager

ERROR in src/main/java/com/dovyswords/forge/listeners/ForgeGuiListener.java at line 60: cannot find symbol
            if (plugin.getCoreManager().isAnyCore(item)) {
                                       ^
  symbol: method isAnyCore(ItemStack)
  location: class CoreManager

ERROR in src/main/java/com/dovyswords/forge/listeners/ForgeGuiListener.java at line 96: cannot find symbol
            if (rawSlot == ForgeGui.SLOT_PREVIEW) {
                                   ^
  symbol: variable SLOT_PREVIEW
  location: class ForgeGui

ERROR in src/main/java/com/dovyswords/forge/listeners/ForgeGuiListener.java at line 121: cannot find symbol
                    || slot == ForgeGui.SLOT_PREVIEW
                                       ^
  symbol: variable SLOT_PREVIEW
  location: class ForgeGui

ERROR in src/main/java/com/dovyswords/forge/INVENTORY GUI/ForgeGui.java at line 51: cannot find symbol
        inventory.setItem(SLOT_PREVIEW, makeBarrierSlot());
                          ^
  symbol: variable SLOT_PREVIEW
  location: class ForgeGui

ERROR in src/main/java/com/dovyswords/forge/INVENTORY GUI/ForgeGui.java at line 74: cannot find symbol
        ForgeRecipe recipe = forgeManager.resolveRecipe(sword, core);
                                         ^
  symbol: method resolveRecipe(ItemStack,ItemStack)
  location: variable forgeManager of type ForgeManager

ERROR in src/main/java/com/dovyswords/forge/INVENTORY GUI/ForgeGui.java at line 77: incompatible types: ForgeRecipe cannot be converted to String
            ItemStack result = forgeManager.buildResult(recipe);
                                                        ^

ERROR in src/main/java/com/dovyswords/forge/INVENTORY GUI/ForgeGui.java at line 79: cannot find symbol
                inventory.setItem(SLOT_PREVIEW, makeResultPreview(result));
                                  ^
  symbol: variable SLOT_PREVIEW
  location: class ForgeGui

ERROR in src/main/java/com/dovyswords/forge/INVENTORY GUI/ForgeGui.java at line 83: cannot find symbol
        inventory.setItem(SLOT_PREVIEW, makeBarrierSlot());
                          ^
  symbol: variable SLOT_PREVIEW
  location: class ForgeGui

ERROR in src/main/java/com/dovyswords/forge/INVENTORY GUI/ForgeGui.java at line 89: cannot find symbol
                && slot != SLOT_PREVIEW && slot != SLOT_FORGE;
                           ^
  symbol: variable SLOT_PREVIEW
  location: class ForgeGui

ERROR in src/main/java/com/dovyswords/forge/commands/SetCoreCommand.java at line 52: cannot find symbol
        plugin.getCoreManager().saveCore(coreId, held);
                               ^
  symbol: method saveCore(String,ItemStack)
  location: class CoreManager

ERROR in src/main/java/com/dovyswords/forge/commands/SetPotsOfCoinsForgeCommand.java at line 29: cannot find symbol
        plugin.getPotOfCoinsManager().setTemplate(item);
              ^
  symbol: method getPotOfCoinsManager()
  location: variable plugin of type DovySwordsPlugin


=== COMPILATION ERROR ANALYSIS ===

MISSING CLASSES:
  - SetPotsOfCoinsForgeCommand
  - PotOfCoinsManager
ACTION: Create these classes or check imports

MISSING METHODS:
  - getPotOfCoinsManager()
  - isT1Sword(ItemStack)
  - isAnyCore(ItemStack)
  - resolveRecipe(ItemStack,ItemStack)
  - saveCore(String,ItemStack)
ACTION: Check method names and signatures

TYPE MISMATCHES:
  - incompatible types: ForgeRecipe cannot be converted to String
ACTION: Fix variable types or casting

FILES TO INVESTIGATE:
  - src/main/java/com/dovyswords/forge/commands/SetPotsOfCoinsForgeCommand.java
  - src/main/java/com/dovyswords/forge/managers/PotsOfCoinsManager.java
  - src/main/java/com/dovyswords/DovySwordsPlugin.java
  - src/main/java/com/dovyswords/forge/managers/ForgeManager.java
  - src/main/java/com/dovyswords/forge/listeners/ForgeGuiListener.java
  - src/main/java/com/dovyswords/forge/INVENTORY GUI/ForgeGui.java
  - src/main/java/com/dovyswords/forge/commands/SetCoreCommand.java

Please fix this error by creating a new artifact with the corrected code.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle.kts
manifest.kod
README.md
settings.gradle.kts
Code
31 2,998
src/main/java/com/dovyswords/DovySwordsPlugin.java
package com.dovyswords;

import com.dovyswords.commands.GiveSwordCommand;
import com.dovyswords.commands.ReloadSwordConfigCommand;
import com.dovyswords.forge.commands.ForgeCommand;
import com.dovyswords.forge.commands.ReloadForgeCommand;
import com.dovyswords.forge.commands.SetCoreCommand;
import com.dovyswords.forge.listeners.ForgeGuiListener;
import com.dovyswords.forge.managers.CoreManager;
import com.dovyswords.forge.managers.ForgeManager;
import com.dovyswords.forge.managers.RecipeManager;
import com.dovyswords.listeners.SwordListener;
import com.dovyswords.managers.AuraManager;
import com.dovyswords.managers.CooldownManager;
import com.dovyswords.managers.SwordManager;
import com.dovyswords.utils.CustomFlags;
import com.dovyswords.utils.WorldGuardUtil;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import com.dovyswords.forge.commands.SetPotsOfCoinsForgeCommand;

import java.io.File;

public class DovySwordsPlugin extends JavaPlugin {

    private static DovySwordsPlugin instance;
    private SwordManager swordManager;
    private CooldownManager cooldownManager;
    private WorldGuardUtil worldGuardUtil;
    private AuraManager auraManager;
    private PotOfCoinsManager potOfCoinsManager;
    private RecipeManager recipeManager;
    private CoreManager coreManager;
    private ForgeManager forgeManager;
    private ForgeGuiListener forgeGuiListener;
    private FileConfiguration forgeConfig;

    @Override
    public void onLoad() {
        FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
        try {
            registry.register(CustomFlags.SWORD_ABILITIES);
        } catch (FlagConflictException e) {
            getLogger().warning("sword-abilities flag already registered");
        }
    }

    @Override
    public void onEnable() {
        instance = this;

        saveDefaultConfig();

        this.cooldownManager = new CooldownManager();
        this.swordManager = new SwordManager(this);
        this.worldGuardUtil = new WorldGuardUtil();
        this.auraManager = new AuraManager(this);

        loadForgeConfig();
        this.recipeManager = new RecipeManager(this);
        this.coreManager = new CoreManager(this);
        this.forgeManager = new ForgeManager(this, recipeManager, coreManager);

        this.forgeGuiListener = new ForgeGuiListener(this);
        getServer().getPluginManager().registerEvents(new SwordListener(this), this);
        getServer().getPluginManager().registerEvents(forgeGuiListener, this);

        getCommand("givesword").setExecutor(new GiveSwordCommand(this));
        getCommand("reloadswordconfig").setExecutor(new ReloadSwordConfigCommand(this));
        getCommand("forge").setExecutor(new ForgeCommand(this));
        getCommand("setcore").setExecutor(new SetCoreCommand(this));
        getCommand("reloadforge").setExecutor(new ReloadForgeCommand(this));

        getLogger().info("DovySwords has been enabled!");
    }

    @Override
    public void onDisable() {
        getLogger().info("DovySwords has been disabled!");
    }

    public void reloadConfiguration() {
        reloadConfig();
        swordManager.reload();
    }

    public void reloadForge() {
        loadForgeConfig();
        recipeManager.load();
        coreManager.load();
    }

    private void loadForgeConfig() {
        File file = new File(getDataFolder(), "forge_config.yml");
        if (!file.exists()) {
            saveResource("forge_config.yml", false);
        }
        forgeConfig = YamlConfiguration.loadConfiguration(file);
    }

    public static DovySwordsPlugin getInstance() {
        return instance;
    }

    public SwordManager getSwordManager() {
        return swordManager;
    }

    public CooldownManager getCooldownManager() {
        return cooldownManager;
    }

    public WorldGuardUtil getWorldGuardUtil() {
        return worldGuardUtil;
    }

    public AuraManager getAuraManager() {
        return auraManager;
    }

    public ForgeGuiListener getForgeGuiListener() {
        return forgeGuiListener;
    }

    public RecipeManager getRecipeManager() {
        return recipeManager;
    }

    public CoreManager getCoreManager() {
        return coreManager;
    }

    public ForgeManager getForgeManager() {
        return forgeManager;
    }

    public FileConfiguration getForgeConfig() {
        return forgeConfig;
    }
}