Gopal Kumar

resource pack

๐Ÿ“Ž 1 file 12,067 chars
๐Ÿ“„
pasted-code-1794288829217.txt
txt 138 lines
โ–ถ
Create a complete, working Paper plugin named "InfernoWeapons" for Minecraft 1.21.11 (Paper API only, no NMS), Java 21, Maven, with three custom weapons, an admin command system, a config-driven crafting system, and an admin-only in-game recipe editor GUI. Output must compile with no pseudo-code and no "..." placeholders.

==================================================
1. WEAPONS (custom items, based on Material.STICK)
==================================================
Identify weapons ONLY by a PersistentDataContainer STRING tag, key "weapon_type", values "lightning", "flame", "tnt". NEVER identify a weapon by its name, lore or material, so renaming a normal stick in an anvil must never give it abilities or a custom texture.

Create a WeaponType enum with: id, display name, color, item_model key, config key.
- lightning -> "INF Lightning Stick", yellow, item_model inferno:lightning_stick
- flame     -> "INF Flame Stick",     red,    item_model inferno:flame_stick
- tnt       -> "THE TNT BLASTER",     dark purple, item_model inferno:tnt_blaster

Every weapon item must set: custom name (non-italic), lore (ability + cooldown, read from config), PDC tag, and ItemMeta#setItemModel(new NamespacedKey("inferno", "")) so the resource pack texture shows. The resource pack (namespace "inferno", files lightning_stick / flame_stick / tnt_blaster) already exists, so the item_model keys must match exactly.

WeaponManager class:
- ItemStack create(WeaponType type)
- WeaponType getType(ItemStack item)   // null if not a custom weapon
- boolean isWeapon(ItemStack item, String typeOrAll)   // "all" matches any weapon

Exploit protection: in PrepareItemCraftEvent, if ANY ingredient in the grid is a custom weapon (has the PDC tag), set the result to null. This stops players from using a custom stick as a plain Stick ingredient in any recipe (including the weapon recipes themselves).

==================================================
2. ABILITIES (right-click, main hand only, PlayerInteractEvent RIGHT_CLICK_AIR / RIGHT_CLICK_BLOCK)
==================================================
Cancel the interact event when a weapon ability fires. Ignore the off hand and ignore if the item is not a custom weapon.

LIGHTNING: find the living entity the player is looking at (Player#getTargetEntity or ray trace, max range from config, default 50). If none, send "No target in sight" and do NOT start the cooldown. Otherwise strike lightning on it 5 times (strikes and interval in config, default interval 5 ticks = 0.25s) with a BukkitRunnable. Stop early if the target dies or becomes invalid. Default cooldown 90s.

FLAME: expanding 360 degree fire ring starting at the caster, growing every tick until max radius (config, default 30; the original design value was 80). Draw the ring with FLAME particles. When the ring reaches an entity's distance, deal true damage (default 12 HP, ignores armor) once per entity: first call damage(0.001, caster) for kill credit, then reduce health directly with setHealth(max(0, health - damage)). Never damage the caster. Ignite flammable blocks along the ring (config toggle, plus a hard cap "max-fire-blocks-per-tick") only if the block above is air. Default cooldown 165s.

TNT BLASTER: spawn many TNTPrimed around the caster in batches. NEVER spawn them all in one tick. A BukkitRunnable spawns "batch-size" TNT per tick (default 50) until "count" is reached (default 300; the original design value was 5000, only increase if the server can handle it). Random positions within "radius" (default 60; original design 180) at "spawn-height" above the caster, fuse from config (default 80 ticks), setSource(caster). Keep a "safe-radius" (default 8) around the caster where no TNT spawns. Add a hard cap "max-tnt-alive" so the task pauses if too many primed TNT already exist. Default cooldown 720s.

COOLDOWNS:
- CooldownManager with Map> (expiry timestamps).
- If on cooldown: cancel the ability and show remaining time on the Action Bar (format "1m 30s").
- A repeating task (every 10 ticks) shows "READY" or the remaining time on the Action Bar for any online player holding a weapon.
- Optional (config "persist-cooldowns", default true): save cooldowns to cooldowns.yml in onDisable and load them in onEnable, so restarts do not reset them.

==================================================
3. CONFIG-DRIVEN RECIPES
==================================================
All three recipes are ShapedRecipes registered with NamespacedKey(plugin, "_recipe") and the weapon item (with PDC tag and item_model) as result. config.yml format (the plugin must read and write exactly this format):

    recipes:
      lightning:
        shape: ["NNN", "CSC", "GGG"]
        ingredients:
          N: NETHERITE_INGOT
          C: COPPER_INGOT
          S: STICK
          G: GOLD_BLOCK
      flame:
        shape: [" F ", "FNF", " F "]
        ingredients:
          F: FLINT
          N: NETHERITE_BLOCK
      tnt:
        shape: ["NNN", "FTF", "DDD"]
        ingredients:
          N: NETHERITE_BLOCK
          F: FLINT
          T: TNT
          D: DIAMOND_BLOCK

Rules:
- Spaces in shape mean empty slots. Shape may be 1x1 up to 3x3 (trimmed, rows of equal width).
- Validate every material with Material.matchMaterial(). If a recipe in config is invalid, log a clear warning and fall back to the built-in default recipe for that weapon (never crash).
- RecipeManager: registerAll(), register(type), unregister(type) (Bukkit.removeRecipe), and reload from config. After any recipe change call Bukkit.updateRecipes() so clients refresh.
- The same config.yml also holds ALL ability numbers (radius, damage, counts, batch size, cooldowns, ranges, strikes, interval, persist-cooldowns) and a "messages" section for every player-facing message (use & color codes). Provide a full default config.yml.

==================================================
4. COMMANDS (permission "inferno.admin", default op, works from console where noted)
==================================================
Base command /inferno. The word "weapon" and "weapons" must both work.

/inferno weapons give   [amount]      (console OK)
/inferno weapons clear                (console OK)
/inferno weapons recipe                               (PLAYER ONLY, opens the recipe editor GUI)
/inferno weapons recipe reset                 (restore the built-in default recipe, console OK)
/inferno reload                                       (reload config.yml, re-register recipes, console OK)

- : exact player name, @a, @p, @r, or "random" (one random online player). Use Bukkit.selectEntities(sender, selector) for @ selectors and keep only Player entities.
- : lightning | flame | tnt | all
- give: amount 1-64 (default 1); if the inventory is full, drop leftovers at the player's feet.
- clear: remove only custom weapons (PDC check) from the full inventory including offhand and armor slots; never remove normal sticks.
- Clear red error messages for unknown player, unknown weapon, bad amount, no permission, and console using the GUI command. Green summary message with the number of players affected.
- Full TabCompleter for every argument.
- Register in plugin.yml with usage, permission and aliases.

==================================================
5. ADMIN RECIPE EDITOR GUI (only players with inferno.admin; re-check the permission on every click)
==================================================
Command: /inferno weapons recipe

STEP A - Weapon selection menu (27 slots, title "Weapon Recipes"):
- Fill with gray stained glass panes (name " ").
- Slot 11 = Lightning Stick, slot 13 = Flame Stick, slot 15 = TNT Blaster, shown as the real weapon items (with their item_model texture).
- Lore on each: "Click to edit recipe" plus the current recipe printed as 3 text rows using material names.
- Clicking one opens the editor for that weapon. All items in this menu are non-takeable.

STEP B - Recipe editor (54 slots, 6 rows, title "Edit Recipe: "):
Slot numbers = row*9 + column.

    Row 0: filler
    Row 1: filler filler filler [12] [13] [14] filler filler filler
    Row 2: filler filler filler [21] [22] [23] arrow(24) RESULT(25) filler
    Row 3: filler filler filler [30] [31] [32] filler filler filler
    Row 4: filler
    Row 5: filler filler filler GREEN DYE(48) info(49) RED DYE(50) filler filler filler

- The 3x3 EDIT SLOTS are 12,13,14,21,22,23,30,31,32 (left to right, top to bottom). They start pre-filled with the CURRENT recipe materials (amount 1) and empty (air) where the recipe is empty.
- Slot 24 = arrow item (decoration). Slot 25 = RESULT preview, the real weapon item, non-editable.
- Slot 48 = LIME_DYE named "&aSave Recipe". Slot 50 = RED_DYE named "&cDon't Save / Cancel". Slot 49 = a paper item showing the weapon name.
- Filler everywhere else (gray glass panes), none of it can be taken.

Click behaviour (InventoryClickEvent, InventoryDragEvent, InventoryCloseEvent, use a custom InventoryHolder to recognise the GUIs):
- Cancel EVERY click and drag in the top inventory by default, and cancel shift-clicks that would move items into it. Items must never be duplicated or lost.
- GHOST SLOTS: clicking an edit slot while holding an item on the cursor copies that item's MATERIAL (amount 1, no meta) into the slot; the cursor item stays untouched. Clicking an edit slot with an empty cursor (or right-click) clears that slot.
- Clicking an item in the admin's OWN inventory (bottom inventory) while the editor is open copies its material into the first empty edit slot (again no item is consumed).
- Custom weapons are NOT allowed as ingredients: if the clicked item is a custom weapon, reject with a red message.
- GREEN DYE (Save): read the 9 slots, build the shape. Reject with a red message if all 9 slots are empty. Trim empty outer rows/columns, assign letters A-I to distinct materials, create the shape and ingredient map, then: unregister the old recipe, register the new one, write it to config.yml (same format as section 3, compute on the main thread, write the file asynchronously), call Bukkit.updateRecipes(), close the GUI, send a green success message and play a success sound.
- RED DYE (Don't save): close the GUI, change nothing, send "Recipe change cancelled" and play a cancel sound.
- Closing the GUI any other way (ESC, opening another menu, disconnect) counts as cancel and saves nothing. Use a flag so programmatically switching from menu A to menu B does not trigger the cancel message.

==================================================
6. TECHNICAL REQUIREMENTS
==================================================
- Project layout: pom.xml (Paper API dependency, Java 21, maven-shade not required), src/main/resources/plugin.yml (api-version 1.21), config.yml, and Java packages for: main class, weapon (WeaponType, WeaponManager), ability (LightningAbility, FlameAbility, TntAbility, CooldownManager, AbilityListener), recipe (RecipeManager), gui (RecipeEditorGUI, RecipeEditorListener), command (InfernoCommand + TabCompleter).
- Use Adventure Components for text where convenient. Paper API only.
- Nothing heavy on the main thread; only file IO may be async. All Bukkit world/entity calls on the main thread.
- Handle plugin disable cleanly (cancel running tasks, save cooldowns).

==================================================
7. OUTPUT FORMAT
==================================================
1) Show the complete file tree first.
2) Then give the full code of EVERY file: pom.xml, plugin.yml, config.yml (full defaults), and every Java class.
3) End with short build steps (mvn clean package) and a test checklist covering: /inferno weapons give/clear with a name, @a and random, recipe crafting, the GUI save, the GUI cancel, an invalid recipe in config.yml, the anvil rename exploit, and a cooldown after restart.
Kodari AI
KodariNov 10 at 5:34 am 1

This is a Java plugin project, but youโ€™re asking for a resource pack; Kodari canโ€™t create resource packs.

Gopal Kumar

dont create resouce pack create plugin

Kodari AI
KodariNov 10 at 5:41 am 4
  • Inspect the existing project layout and preserve any established structure.

  • Implement the weapons, cooldowns, recipes, command system, and admin recipe GUI.

  • Add Maven and plugin resources with the requested defaults.

Plain Text
pom.xml
src/main/resources/
โ”œโ”€โ”€ config.yml
โ””โ”€โ”€ plugin.yml
src/main/java/com/inferno/weapons/
โ”œโ”€โ”€ InfernoWeaponsPlugin.java
โ”œโ”€โ”€ ability/
โ”‚   โ”œโ”€โ”€ AbilityListener.java
โ”‚   โ”œโ”€โ”€ CooldownManager.java
โ”‚   โ”œโ”€โ”€ FlameAbility.java
โ”‚   โ”œโ”€โ”€ LightningAbility.java
โ”‚   โ””โ”€โ”€ TntAbility.java
โ”œโ”€โ”€ command/
โ”‚   โ””โ”€โ”€ InfernoCommand.java
โ”œโ”€โ”€ gui/
โ”‚   โ”œโ”€โ”€ RecipeEditorGUI.java
โ”‚   โ””โ”€โ”€ RecipeEditorListener.java
โ”œโ”€โ”€ recipe/
โ”‚   โ””โ”€โ”€ RecipeManager.java
โ””โ”€โ”€ weapon/
    โ”œโ”€โ”€ WeaponCraftListener.java
    โ”œโ”€โ”€ WeaponManager.java
    โ””โ”€โ”€ WeaponType.java

Implemented the Paper plugin and left the existing resource-pack files untouched.

Build and download: Click Compile in the top bar (on mobile: โ‹ฎ โ†’ Compile Project), click Compile in the build window, then Download when it succeeds.

Test checklist: /inferno weapons give/clear with a player name, @a, and random; craft each weapon; save and cancel in the recipe GUI; load an invalid recipe and confirm default fallback; rename a normal stick in an anvil; restart during a cooldown and confirm it persists.

Kodari can make mistakes. Review important code before using.
Files
assets
src
pack.mcmeta
pack.png
pom.xml
Code
27 1,779
src/main/java/com/inferno/weapons/InfernoWeaponsPlugin.java
package com.inferno.weapons;

import com.inferno.weapons.ability.AbilityListener;
import com.inferno.weapons.ability.CooldownManager;
import com.inferno.weapons.ability.FlameAbility;
import com.inferno.weapons.ability.LightningAbility;
import com.inferno.weapons.ability.TntAbility;
import com.inferno.weapons.command.InfernoCommand;
import com.inferno.weapons.gui.RecipeEditorListener;
import com.inferno.weapons.recipe.RecipeManager;
import com.inferno.weapons.weapon.WeaponCraftListener;
import com.inferno.weapons.weapon.WeaponManager;
import com.inferno.weapons.weapon.WeaponType;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Map;

public final class InfernoWeaponsPlugin extends JavaPlugin {
    private WeaponManager weaponManager;
    private CooldownManager cooldownManager;
    private RecipeManager recipeManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        weaponManager = new WeaponManager(this);
        cooldownManager = new CooldownManager(this);
        cooldownManager.load();
        recipeManager = new RecipeManager(this, weaponManager);
        recipeManager.registerAll();

        Bukkit.getPluginManager().registerEvents(new AbilityListener(
                this,
                weaponManager,
                cooldownManager,
                new LightningAbility(this, cooldownManager),
                new FlameAbility(this, cooldownManager),
                new TntAbility(this, cooldownManager)
        ), this);
        Bukkit.getPluginManager().registerEvents(new WeaponCraftListener(weaponManager), this);
        Bukkit.getPluginManager().registerEvents(new RecipeEditorListener(this, weaponManager, recipeManager), this);

        InfernoCommand infernoCommand = new InfernoCommand(this, weaponManager, cooldownManager, recipeManager);
        PluginCommand command = getCommand("inferno");
        if (command == null) {
            throw new IllegalStateException("The inferno command is missing from plugin.yml");
        }
        command.setExecutor(infernoCommand);
        command.setTabCompleter(infernoCommand);

        Bukkit.getScheduler().runTaskTimer(this, () -> {
            for (Player player : Bukkit.getOnlinePlayers()) {
                WeaponType type = weaponManager.getType(player.getInventory().getItemInMainHand());
                if (type == null) {
                    type = weaponManager.getType(player.getInventory().getItemInOffHand());
                }
                if (type == null) {
                    continue;
                }
                long remaining = cooldownManager.getRemainingMillis(player.getUniqueId(), type);
                if (remaining > 0) {
                    player.sendActionBar(text("actionbar-cooldown", Map.of("time", CooldownManager.formatRemaining(remaining))));
                } else {
                    player.sendActionBar(text("actionbar-ready", Map.of()));
                }
            }
        }, 0L, 10L);
    }

    @Override
    public void onDisable() {
        if (cooldownManager != null) {
            cooldownManager.save();
        }
        Bukkit.getScheduler().cancelTasks(this);
    }

    public WeaponManager getWeaponManager() {
        return weaponManager;
    }

    public CooldownManager getCooldownManager() {
        return cooldownManager;
    }

    public RecipeManager getRecipeManager() {
        return recipeManager;
    }

    public Component text(String key, Map<String, String> placeholders) {
        String raw = getConfig().getString("messages." + key, "&cMissing message: " + key);
        for (Map.Entry<String, String> entry : placeholders.entrySet()) {
            raw = raw.replace("{" + entry.getKey() + "}", entry.getValue());
        }
        return LegacyComponentSerializer.legacyAmpersand().deserialize(raw);
    }

    public void sendMessage(CommandSender sender, String key, Map<String, String> placeholders) {
        String prefix = getConfig().getString("messages.prefix", "");
        sender.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(prefix)
                .append(text(key, placeholders)));
    }

    public void sendMessage(CommandSender sender, String key) {
        sendMessage(sender, key, Map.of());
    }
}