itzsolid16

I want you to create me a minecraft plugin for 1.21.11! I want the plugin like this: if you put these items into a crafting table (see on image i sent) then you get the "God Mace". Which is instantly enchanted with these enchants: density 5, breach 4, unbreaking 3, fire aspect 2, mending. It also has abilites such as: 1st when you right click with the mace in your hand it blasts a sonic boom (what the warden does) in the direction you are lookin (dealing the same amount of damage it normally does). It has a 1 minute cooldown and the cooldown shows above your level bar (above the level counter), minecraft style. 2nd with the God Mace you can penetrate shields, so you dont have to break it first with an axe, it automaticly does the stun slam for you. 3rd when the God Mace is in your INVENTORY you gain 10+ permanent hearts, so you have 20 hearts, but only when a player has it in their inventory. 4th when you slam someone with the mace (normal attack without slam doesnt count) it summons a lightning strike, which doesnt damage you, but it does 2 hearts of damage to any player even in netherite armor. 5th only 1 mace can be crafted in a server, so when its crafted a display message shows for all players and a wither spawn sound plays also "The God Mace has been crafed". And dont let any other players craft the God Mace! 6th and last, when a player double jumps with the god mace in their hand it boosts them upwards approx. 6-10 blocks, like a windcharge would do But this also comes with danger, because players can track down the god mace (even if its in a chest): make a crafting receipe so when a player puts a compass into the middle of the crafting table and surrounds it with netherite ingots (8 total) it creates a lodestone compass which always points to the God Mace

1 image attached
Kodari AI
KodariJun 2 at 5:25 pm 38
GodMace
A Minecraft 1.21.1 plugin that adds a legendary God Mace crafted from rare materials. Features include: sonic boom right-click ability (1-min cooldown), automatic shield penetration, +10 hearts while in inventory, lightning on slam attacks, server-unique crafting with global broadcast, and a wind-charge double jump. Includes a Netherite Tracker Compass that always points to the God Mace — even when it's stored in a chest.

Analyzing the crafting image:

  • Top row: Trident, Eye of Ender, Nether Star

  • Middle row: Totem of Undying, Mace, Echo Shard

  • Bottom row: Enchanted Golden Apple, Wind Charge, Netherite Ingot

Planning all classes before writing:

  • GodMacePlugin — main, recipes, tasks

  • GodMaceManager — state, item creation, all cooldown/modifier logic

  • GodMaceListener — all event handlers

Here’s a full breakdown of every feature:


🔨 Crafting Recipe

Slot
Item
Top row
Trident · Eye of Ender · Nether Star
Middle row
Totem of Undying ·
Mace
· Echo Shard
Bottom row
Enchanted Golden Apple · Wind Charge · Netherite Ingot

Enchanted with: Density V, Breach IV, Unbreaking III, Fire Aspect II, Mending I


⚔️ Abilities

  1. Sonic Boom — Right-click fires a forward ray (15 blocks, 41° cone), dealing 10 damage + knockback. 60s cooldown shown in the action bar above the level counter.

  2. Shield Penetration — Any hit on a blocking player instantly gives their shield a 5-second stun cooldown.

  3. +10 Hearts — While the mace is anywhere in inventory, a GENERIC_MAX_HEALTH attribute modifier adds +20 HP (10 hearts). Removed on logout, re-applied by the repeating task.

  4. Lightning Slam — On a slam attack (fallDistance > 1.5), strikes visual lightning at the target and deals 4 true HP (ignores armor) to all players within 5 blocks except the attacker.

  5. Server Unique — On craft: global broadcast + Wither Spawn sound. Subsequent crafts are permanently blocked (saved to config.yml).

  6. Wind Jump — While holding the mace in creative mode flights are cancelled. In survival, double-jumping applies Y=1.2 velocity (~8–10 blocks) with cloud particles + wind burst sound. Resets on landing.

🧭 Tracking Compass

Recipe: 8 Netherite Ingots surrounding a Compass. Updates its CompassMeta lodestone every 10 ticks to the mace’s last known position — tracks it in player inventories, chests/barrels, and on the ground.

itzsolid16

do these small changes: instead of the windburst you have to put a heart of the sea. detect when the mace gets deleted, lost, burnt etc... and show a display message on players screen with the beacon deactivation sound, that the god mace has been lost - it becomes craftable again.

also add a failsafe command where if I type /godmace recover - it automaticly resets the godmace and it will become craftable again

Kodari AI
KodariJun 2 at 5:40 pm 20

3 changes to make:

  1. WIND_CHARGE → HEART_OF_THE_SEA in the recipe

  2. Mace-lost detection (item destruction, fire, void, etc.) + global title + beacon sound + reset craftable

  3. /godmace recover admin command

Now add the command executor and the mace-lost reset method to the manager, plus all the listener events:

Now add all the lost-detection events to the listener:

Now register the command in plugin.yml:

All changes applied. Here’s a summary:


Changes made

Recipe fix

  • Bottom-middle slot changed from WIND_CHARGE → HEART_OF_THE_SEA

Mace lost detection — covers every destruction scenario:

  • Lava/fire — EntityDamageEvent on the dropped Item entity; checks if it dies 1 tick later

  • Void / natural despawn (5 min) — ItemDespawnEvent fires directly

  • Both paths call broadcastMaceLost() which:

    • Sends a title screen to every player: “⚠ GOD MACE LOST — It may be forged once more…”

    • Plays BLOCK_BEACON_DEACTIVATE sound for all

    • Calls resetCrafted() to clear the crafted flag from config → mace becomes craftable again

/godmace recover command (op-only by default)

  • Permission: godmace.admin

  • Instantly resets the crafted state and clears the saved location

  • Confirms to the sender with a green message

Kodari can make mistakes. Review important code before using.
Files
src
Code
5 773
src/main/java/com/godmace/GodMacePlugin.java
package com.godmace;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.java.JavaPlugin;
import lombok.Getter;

public class GodMacePlugin extends JavaPlugin {

    @Getter
    private GodMaceManager godMaceManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        godMaceManager = new GodMaceManager(this);

        getServer().getPluginManager().registerEvents(new GodMaceListener(this), this);

        registerGodMaceRecipe();
        registerTrackingCompassRecipe();
        startTasks();

        getCommandExecutor();
        getLogger().info("GodMace enabled!");
    }

    private void getCommandExecutor() {
        getCommand("godmace").setExecutor((sender, command, label, args) -> {
            if (!sender.hasPermission("godmace.admin")) {
                sender.sendMessage(ChatColor.RED + "No permission.");
                return true;
            }
            if (args.length == 1 && args[0].equalsIgnoreCase("recover")) {
                godMaceManager.resetCrafted();
                sender.sendMessage(ChatColor.GREEN + "✔ God Mace has been reset. It can be crafted again.");
            } else {
                sender.sendMessage(ChatColor.YELLOW + "Usage: /godmace recover");
            }
            return true;
        });
    }

    @Override
    public void onDisable() {
        godMaceManager.saveData();
        getLogger().info("GodMace disabled!");
    }

    private void registerGodMaceRecipe() {
        NamespacedKey key = new NamespacedKey(this, "god_mace");
        ShapedRecipe recipe = new ShapedRecipe(key, godMaceManager.createGodMace());
        recipe.shape("abc", "def", "ghi");
        recipe.setIngredient('a', mat("TRIDENT"));
        recipe.setIngredient('b', mat("ENDER_EYE"));
        recipe.setIngredient('c', mat("NETHER_STAR"));
        recipe.setIngredient('d', mat("TOTEM_OF_UNDYING"));
        recipe.setIngredient('e', mat("MACE"));
        recipe.setIngredient('f', mat("ECHO_SHARD"));
        recipe.setIngredient('g', mat("ENCHANTED_GOLDEN_APPLE"));
        recipe.setIngredient('h', mat("HEART_OF_THE_SEA"));
        recipe.setIngredient('i', mat("NETHERITE_INGOT"));
        getServer().addRecipe(recipe);
    }

    private void registerTrackingCompassRecipe() {
        NamespacedKey key = new NamespacedKey(this, "tracking_compass");
        ShapedRecipe recipe = new ShapedRecipe(key, godMaceManager.createTrackingCompass());
        recipe.shape("nnn", "ncn", "nnn");
        recipe.setIngredient('n', mat("NETHERITE_INGOT"));
        recipe.setIngredient('c', mat("COMPASS"));
        getServer().addRecipe(recipe);
    }

    private Material mat(String name) {
        return XMaterial.matchXMaterial(name).map(XMaterial::parseMaterial).orElse(Material.AIR);
    }

    private void startTasks() {
        // Main update task: every 10 ticks
        Bukkit.getScheduler().runTaskTimer(this, () -> {
            for (Player player : Bukkit.getOnlinePlayers()) {
                godMaceManager.updateActionBar(player);
                godMaceManager.updateFlightAbility(player);
                godMaceManager.updateHealthModifier(player);
                godMaceManager.updateAirJumpReset(player);
                godMaceManager.updateMaceLocationFromPlayer(player);
                godMaceManager.updateTrackingCompasses(player);
            }
        }, 0L, 10L);

        // Periodic config save: every 5 minutes
        Bukkit.getScheduler().runTaskTimer(this, () -> godMaceManager.saveData(), 6000L, 6000L);
    }
}