Goho Production

ELEMENTAL MACES PLUGIN

Minecraft Paper Server 26.3

Develop a complete, production-ready Minecraft Paper plugin named "ElementalMaces" for Minecraft version 26.3.

This must be a server-side Paper plugin, NOT a Fabric, Forge, NeoForge, or client-side mod.

The plugin introduces 4 legendary elemental maces:

  • Ice Mace ❄️
  • Thunder Mace ⚡
  • Earth Mace 🌍
  • Lava Mace 🌋

Each mace has one passive ability and one custom active ability.

All maces must be uncraftable and obtainable only through administrator commands.

  1. GENERAL MACE SYSTEM
  • All 4 maces must be actual Minecraft Mace items.
  • Each mace must have a unique custom name, color, lore, and identification.
  • Use PersistentDataContainer for reliable custom-item identification.
  • Normal Minecraft maces must never receive custom abilities.
  • Custom maces must retain their identity after server restarts.
  • Players cannot craft these maces.
  • Players cannot duplicate their powers through normal gameplay exploits.
  • All abilities must work correctly in multiplayer.
  • All active abilities must have a 60-second cooldown.
  • All abilities must activate using Sneak + Left Click.
  • The plugin must correctly detect the player's main-hand mace.
  • Prevent accidental ability activation while interacting with blocks.
  • Show cooldown information through action bar messages.
  • If a player tries to activate an ability during cooldown, show the remaining time.
  1. ICE MACE ❄️

Passive Ability: Frozen Breath

  • The player holding the Ice Mace receives permanent Water Breathing.
  • The effect must remain active while the Ice Mace is held in the main hand.
  • Automatically remove the plugin-managed effect when the player stops holding the mace.
  • The effect must work after respawning and relogging.

Active Ability: Frozen Domain

Activation: Sneak + Left Click

  • Create a freezing domain around the Ice Mace user.
  • Range: 50 blocks radius.
  • Every enemy player within the radius becomes completely immobilized.
  • Affected players cannot walk, jump, sprint, or move.
  • The Ice Mace user must remain unaffected.
  • Affected players receive a visible freezing animation on their screens.
  • Use snow particles, ice particles, and freezing visual effects.
  • Add suitable freezing sound effects.
  • The freezing animation must be noticeable to affected players.
  • The ability must not place permanent ice blocks.
  • The ability must not destroy terrain.
  • Freezing duration must be configurable in config.yml.
  • Cooldown: 60 seconds.

Important implementation detail:

Use appropriate Paper/Bukkit APIs to implement immobilization and client-visible freezing effects. If the vanilla freezing effect alone does not immobilize players, implement movement restriction separately.

  1. THUNDER MACE ⚡

Passive Ability: Thunder Strength

  • The player holding the Thunder Mace receives permanent Strength I.
  • Strength must remain active indefinitely while the mace is held.
  • Remove the plugin-managed Strength effect when the player stops holding the mace.
  • Avoid unnecessary repeated potion-effect application.

Active Ability: Thunder Strike

Activation: Sneak + Left Click

  • Create a lightning attack in a straight line in the direction the player is looking.
  • Maximum range: 50 blocks.
  • Lightning must travel along the targeted direction.
  • Players hit by the attack receive exactly 7 hearts of damage.
  • 7 hearts = 14 health points.
  • Damage must be configurable.
  • Add lightning particles and thunder sound effects.
  • The Thunder Mace user must not receive damage from their own ability.
  • The attack must not destroy blocks.
  • The attack must not start fires.
  • Cooldown: 60 seconds.

Important:

Use a controlled lightning visual effect that does not accidentally cause additional vanilla lightning damage. Damage should be handled by the plugin.

  1. EARTH MACE 🌍

Passive Ability: Earth Guardian

  • The player holding the Earth Mace receives Resistance II.
  • The player receives Knockback Resistance.
  • The player receives complete Fall Damage Immunity.
  • All passive effects remain active while the Earth Mace is held.
  • Effects automatically disappear when the player stops holding the mace.
  • The ability must work after respawning and relogging.

Active Ability: Earthquake

Activation: Sneak + Left Click

  • Create an earthquake around the Earth Mace user.
  • Range: 50 blocks radius.
  • Nearby enemy players are launched into the air.
  • Every affected player receives exactly 5 hearts of damage.
  • 5 hearts = 10 health points.
  • Apply Slowness IV for 4 seconds.
  • The Earth Mace user must remain unaffected.
  • Add ground shockwave particles.
  • Add stone particles.
  • Add earthquake sound effects.
  • Create a visible shockwave effect.
  • Do not destroy actual terrain.
  • Cooldown: 60 seconds.
  1. LAVA MACE 🌋

Passive Ability: Inferno Guardian

  • The player holding the Lava Mace receives permanent Fire Resistance.
  • The player becomes immune to fire and lava damage.
  • Add subtle flame particles around the player.
  • Passive effects automatically disappear when the player stops holding the mace.
  • The effect must work after respawning and relogging.

Active Ability: Volcanic Eruption

Activation: Sneak + Left Click

  • Create a volcanic eruption around the Lava Mace user.
  • Range: 50 blocks radius.
  • All nearby enemy players receive exactly 6 hearts of damage.
  • 6 hearts = 12 health points.
  • Apply Burning Effect for exactly 20 seconds.
  • Enemies receive knockback.
  • The Lava Mace user remains completely unaffected.
  • Add lava particles.
  • Add flame particles.
  • Add explosion sound effects.
  • Create temporary lava crack visual effects using particles.
  • Never place real lava blocks.
  • Never destroy terrain.
  • Cooldown: 60 seconds.
  1. COMMANDS

Implement the following commands:

/elementalmaces give <player> ice /elementalmaces give <player> thunder /elementalmaces give <player> earth /elementalmaces give <player> lava

Additional commands:

/elementalmaces reload /elementalmaces help

Command requirements:

  • Support tab completion.
  • Validate player names.
  • Display success and error messages.
  • Support offline players where technically appropriate.
  • Prevent unauthorized users from executing administrator commands.
  1. PERMISSIONS

elementalmaces.admin

  • Permission to give custom maces.
  • Permission to reload configuration.
  • Permission to use administrator commands.

elementalmaces.use

  • Permission to activate custom mace abilities.

Make administrator permissions configurable or compatible with standard operator permissions.

  1. CONFIGURATION

Create a complete config.yml containing:

  • Ice Mace cooldown.
  • Thunder Mace cooldown.
  • Earth Mace cooldown.
  • Lava Mace cooldown.
  • Ability ranges.
  • Damage values.
  • Freezing duration.
  • Burning duration.
  • Earthquake launch strength.
  • Earthquake Slowness duration.
  • Knockback strength.
  • Particle settings.
  • Sound settings.
  • Passive ability settings.
  • Ability activation messages.
  • Cooldown messages.
  • Ability enabled/disabled settings.

Default cooldown for all 4 maces must be 60 seconds.

Default burning duration must be 20 seconds.

Default ability range must be 50 blocks.

  1. MULTIPLAYER AND PERFORMANCE
  • Optimize the plugin for SMP servers.
  • Avoid unnecessary repeating tasks.
  • Do not scan every player every tick if unnecessary.
  • Use efficient player and entity detection.
  • Prevent ability spam.
  • Prevent cooldown bypasses.
  • Prevent passive effect duplication.
  • Handle player death correctly.
  • Handle player logout correctly.
  • Handle player respawn correctly.
  • Handle item switching correctly.
  • Clean up temporary ability tasks and effects.
  • Avoid memory leaks.
  • Avoid unnecessary block updates.
  • Never modify terrain unless explicitly configured.
  • Ensure the mace user cannot damage themselves with their own abilities.
  • Ensure abilities do not accidentally affect the caster.
  1. PAPER SERVER REQUIREMENTS
  • Develop specifically for Minecraft Paper Server.
  • Target Minecraft version: 26.3.
  • Use the correct Paper API for the exact target version.
  • Use compatible Bukkit APIs wherever appropriate.
  • Do not develop a client-side mod.
  • Do not require Fabric, Forge, or NeoForge.
  • Plugin must be installable directly inside the server's "/plugins" folder.
  • Verify the exact Minecraft 26.3 Paper API and Java requirements before compiling.
  • Use the correct Maven or Gradle dependency.
  • Avoid deprecated APIs when alternatives exist.
  • Ensure compatibility with multiplayer Paper servers.
  1. REQUIRED FILES

Provide the complete project containing:

  • Java source code.
  • plugin.yml.
  • config.yml.
  • Maven pom.xml or Gradle build files.
  • Any required resource files.
  • README.md containing installation instructions.
  • All required classes and listeners.
  1. FINAL DELIVERABLES

The final output must include:

  1. Complete plugin source code.
  2. A compiled ElementalMaces.jar.
  3. Correct Paper 26.3 compatibility.
  4. Installation instructions.
  5. Command documentation.
  6. Permission documentation.
  7. Configuration documentation.
  8. Explanation of each mace's abilities.
  9. Instructions for giving maces to players.
  10. Instructions for changing cooldowns and damage.

Do not provide incomplete code, pseudocode, or placeholder methods.

Build and verify the plugin before delivering it.

The final plugin must be stable, optimized, multiplayer-compatible, and ready for installation on a Paper SMP server.

Kodari AI
KodariNov 9 at 7:40 am 4
ElementalMaces
A Paper server plugin introducing 4 legendary elemental maces (Ice, Thunder, Earth, Lava) with passive and active abilities. Features PersistentDataContainer-based item identification, 60-second cooldowns with action bar feedback, and configurable damage/ranges. Passive effects include Water Breathing, Strength I, Resistance II, and Fire Resistance. Active abilities create area-of-effect attacks with particle effects and sound. Includes admin commands with tab completion, permission system, and full configuration support.
  • Create the four PDC-tagged maces, commands, configuration, and documentation.

  • Implement their abilities, persistent cooldowns, and multiplayer cleanup.

  • Target the published Paper 26.3 API and Java 25; compilation and server testing remain necessary before installation.

Created the ElementalMaces source, configuration, commands, permissions, and README.

Verification is still required: I couldn’t compile or test it here, so there’s no verified JAR yet. The project targets a published Paper 26.3 alpha API and Java 25; compatibility with your specific server build isn’t guaranteed.

To get the JAR in Kodari, click Compile in the top bar—or ⋮ → Compile Project on mobile—then click Compile and download the successful build. Installation and configuration instructions are in README.md.

Goho Production
  1. CUSTOM RESOURCE PACK

Create a custom Minecraft Java Edition resource pack for the ElementalMaces plugin.

The resource pack must contain 4 completely unique elemental mace textures.

Ice Mace ❄️

  • Unique icy blue mace texture.
  • Frozen crystal appearance.
  • Glowing ice-inspired details.
  • Frost particles and icy visual identity.

Thunder Mace ⚡

  • Unique electric yellow and blue mace texture.
  • Lightning-inspired details.
  • Electric energy appearance.

Earth Mace 🌍

  • Unique dark brown and green mace texture.
  • Stone and ancient earth appearance.
  • Rock and crystal details.

Lava Mace 🌋

  • Unique black and red mace texture.
  • Molten lava cracks.
  • Glowing orange lava details.

Resource Pack Technical Requirements

  • Compatible with Minecraft Java Edition 26.3.
  • Use the correct resource pack format for the target Minecraft version.
  • Use custom model data or another compatible item-model identification method.
  • Ensure all 4 maces display their unique textures.
  • Normal vanilla maces must retain their original appearance.
  • Resource pack must not unnecessarily modify unrelated Minecraft items.
  • Include all required JSON model files and PNG textures.
  • Include pack.mcmeta.
  • Use proper texture resolution and transparent backgrounds where appropriate.
  • Ensure the resource pack works with the Paper plugin.

Resource Pack Delivery

Provide:

  1. Complete resource pack source files.
  2. A compiled ZIP resource pack.
  3. All 4 custom mace textures.
  4. Correct model definitions.
  5. pack.mcmeta.
  6. Installation instructions.
  7. Instructions for connecting the resource pack to the Paper plugin.

Automatic Resource Pack Support

  • Implement optional resource pack delivery through the plugin.
  • Support configurable resource pack URL.
  • Support resource pack SHA-1 hash configuration.
  • Allow administrators to enable or disable resource pack prompting.
  • Players should receive the resource pack prompt when joining.
  • Handle resource pack acceptance and rejection properly.
  • Do not force players to download an invalid resource pack.

Final Deliverable

Deliver both:

  • ElementalMaces.jar
  • ElementalMaces-ResourcePack.zip

Both must be compatible with Minecraft Java Edition 26.3.

Kodari AI
KodariNov 9 at 7:41 am 1

Kodari does not currently build Minecraft resource packs, so I can’t create or deliver the requested ElementalMaces resource pack.

Goho Production

Ye maces mujhe kaha se milenge game me

Kodari AI
KodariNov 9 at 7:43 am 1

Ye maces admin command se milenge; craft nahi hote. Game mein OP ya elementalmaces.admin permission ke saath ye commands chalayein:

  • Ice: /elementalmaces give <player> ice

  • Thunder: /elementalmaces give <player> thunder

  • Earth: /elementalmaces give <player> earth

  • Lava: /elementalmaces give <player> lava

<player> ki jagah apna ya kisi online player ka naam likhein. Plugin ko server ke plugins folder mein install karna hoga.

Goho Production

But me resource pack kaha se lau and banau

Kodari AI
KodariNov 9 at 8:09 am 1

Resource pack aap Blockbench ya kisi image editor mein bana sakte hain. Usme 4 mace textures, item model JSON files aur pack.mcmeta chahiye. Normal mace ka appearance bhi unchanged rakhna hoga.

Abhi is plugin ke liye pack tayyar nahi hai, aur Kodari resource packs generate nahi karta. Pack banane ke baad use ZIP karke players ko manually de sakte hain, ya Paper ke server.properties mein hosted pack ka URL aur SHA-1 hash set karke server se prompt bhej sakte hain.

Dhyan rahe: custom textures dikhane ke liye plugin ki mace identification aur pack ke item models ka match hona zaroori hai; sirf ZIP install karna kaafi nahi hoga.

Goho Production

resource pack ko plugin ke custom maces ke saath properly integrate kare.

Kodari AI
KodariNov 9 at 8:17 am 3
  • Maces ko alag item-model IDs dunga aur purane maces ko update karunga.

  • Resource-pack prompt optional rakhunga; URL aur SHA-1 configuration check karke hi bhejunga.

Plugin mein resource-pack integration add kar di hai:

  • Har elemental mace ka alag item-model ID hai; vanilla mace unchanged rahega.

  • Purane custom maces join par ya haath mein lene par update honge.

  • Optional pack prompt ke liye config.yml mein URL, SHA-1 aur enable setting add ki hai. Players pack decline kar sakte hain.

Compatible resource pack abhi bhi alag se banana hoga. Uske required model IDs aur setup instructions README.md mein hain. Changes compile ya in-game test nahi kiye gaye hain.

Goho Production

Create the complete compatible Minecraft 26.3 resource pack ZIP for all four Elemental Maces using the exact item-model IDs implemented in the plugin

Kodari AI
KodariNov 9 at 8:19 am 1

Kodari abhi Minecraft resource packs nahi banata, isliye main Elemental Maces resource pack ZIP create nahi kar sakta.

Goho Production

Fir me zip file tum du kese mere pass hai

Kodari AI
KodariNov 9 at 8:24 am 1

Agar aapke paas resource-pack ZIP hai, to chat ke attachment/upload button se yahan bhej dijiye. Main dekh sakta hoon ki uske item-model IDs plugin ke IDs se match karte hain ya nahi, aur zarurat par plugin integration mein madad kar sakta hoon.

Goho Production

See aya

Kodari AI
KodariNov 9 at 8:25 am 1

Mujhe abhi koi ZIP attachment nahi dikh rahi. Chat ke attachment/upload button se ZIP select karke dobara bhej dijiye.

Goho Production

attachment/upload

Kodari AI
KodariNov 9 at 8:26 am 1

Chat ke message box ke paas + ya paperclip 📎 icon par tap karein, phir apni resource-pack ZIP select karke send kar dein.

Agar icon nahi dikh raha, batayein ki aap phone par hain ya desktop par.

Goho Production

Bhai icon toh hai + pe click karke select bhi karliya 1 item added bhi agaya but tumare pass nahi aya

Kodari AI
KodariNov 9 at 8:27 am 1

Ho sakta hai file select hone ke baad message ke saath send na hui ho. 1 item added dikhne ke baad send button dabakar dobara bhejo.

Agar phir bhi nahi aati, ZIP ko Google Drive ya Dropbox par upload karke public sharing link yahan bhej do.

Goho Production

The resource pack ZIP is available in the project now. Please extract and inspect it, then complete the Minecraft 26.3 compatible resource pack using the exact custom item-model IDs from my ElementalMaces plugin. Fix any missing files, update pack.mcmeta to the correct version, verify all 4 mace textures, and provide the final downloadable ZIP. Also compile the plugin and ensure both work together.

Kodari AI
KodariNov 9 at 8:30 am 1

Bhai, ye Minecraft plugin project hai, aur Kodari abhi resource packs create ya edit nahi karta. Isliye main ZIP inspect, fix ya final resource pack deliver nahi kar sakta.

Plugin JAR ke liye Kodari mein Compile button se build chala sakte ho, lekin resource pack ke saath compatibility yahan verify nahi kar paunga.

Goho Production

Okay, complete the ElementalMaces plugin first.

Ensure all 4 custom mace item-model IDs are properly implemented and documented in README.md.

Provide:

  1. Compiled ElementalMaces.jar
  2. Exact item-model IDs for Ice, Thunder, Earth, and Lava Maces.
  3. All required resource pack model paths.
  4. Resource pack configuration instructions.
  5. Successful compilation status.

Do not claim resource pack compatibility has been tested unless actually tested.

Kodari AI
KodariNov 9 at 8:32 am 1
  • Document the four exact item-model IDs and resource-pack paths.

  • Clarify pack configuration and what has not been tested.

The plugin assigns all four item-model IDs; README.md now documents their required resource-pack paths.

Mace
Item-model ID
Item definition path
Ice
elementalmaces:ice_mace
assets/elementalmaces/items/ice_mace.json
Thunder
elementalmaces:thunder_mace
assets/elementalmaces/items/thunder_mace.json
Earth
elementalmaces:earth_mace
assets/elementalmaces/items/earth_mace.json
Lava
elementalmaces:lava_mace
assets/elementalmaces/items/lava_mace.json

The README also documents model and texture references. To prompt players to download a compatible pack, set resource-pack.enabled, url, and sha1 in config.yml, then reload the plugin.

Compilation status: not verified. I can’t provide a compiled JAR or claim a successful build from this session. In Kodari, click Compile → Compile, then download the JAR if the build succeeds. Resource-pack compatibility has not been tested.

Goho Production

Modify my existing ElementalMaces plugin to integrate the provided ElementalMaces_Complete_ResourcePack.zip.

Set these CustomModelData values when creating mace items:

ICE = 1001 THUNDER = 1002 EARTH = 1003 LAVA = 1004

Ensure these values are applied through ItemMeta and preserved alongside the existing PersistentDataContainer elementalmaces:element key.

Update the plugin's give commands and mace creation method so every newly given mace receives the correct model.

Do not change any abilities, damage, cooldowns, or permissions.

Compile the modified plugin and provide the final ElementalMaces.jar.

Also ensure the resource pack's mace.json overrides correctly map CustomModelData 1001–1004 to the four custom models.

Kodari AI
KodariNov 9 at 8:40 am 1

Kodari resource packs edit nahi karta, isliye is request mein ZIP ke mace.json overrides verify ya fix nahi kar sakta.

Goho Production

Modify my existing ElementalMaces plugin to support my custom resource pack.

Requirements:

  1. Add CustomModelData to all 4 custom maces:

- Ice Mace = 1001 - Thunder Mace = 1002 - Earth Mace = 1003 - Lava Mace = 1004

  1. Set CustomModelData using ItemMeta when creating each mace.
  1. Preserve all existing PDC data, abilities, cooldowns, damage, effects, and permissions.
  1. Do not change any existing gameplay mechanics.
  1. Make sure the CustomModelData is correctly applied when using "/elementalmaces give".
  1. Compile the modified plugin into a working ".jar".
  1. Provide the final compiled plugin download.

My resource pack already contains models using CustomModelData 1001–1004.

Kodari AI
KodariNov 9 at 8:41 am 1
  • Har mace par requested CustomModelData set karunga, PDC aur gameplay unchanged rakhta hua.

  • Purane custom maces ke item-model IDs bhi migrate karunga, taaki vanilla mace overrides use ho sakein.

CustomModelData set kar diya hai: Ice 1001, Thunder 1002, Earth 1003, Lava 1004. Give command se naye maces par values lagenge; PDC identification aur gameplay mechanics unchanged hain. Purane custom maces bhi update honge.

JAR abhi compile ya verify nahi hua hai. Kodari mein Compile → Compile dabayein; build successful hone par Download se JAR le sakte hain.

Kodari can make mistakes. Review important code before using.
Files
assets
src
build.gradle
ElementalMaces_Vanilla_ResourcePack.zip
pack.mcmeta
README.md
README.txt
settings.gradle
Code
13 626
src/main/java/com/kodari/elementalmaces/ElementalMaces.java
package com.kodari.elementalmaces;

import com.cryptomorin.xseries.XAttribute;
import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.particles.XParticle;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.Particle;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerResourcePackStatusEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scoreboard.Team;
import org.bukkit.util.RayTraceResult;
import org.bukkit.util.Vector;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HexFormat;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

public final class ElementalMaces extends JavaPlugin implements Listener, CommandExecutor, TabCompleter {
    private enum Element { ICE, THUNDER, EARTH, LAVA }
    private NamespacedKey itemKey;
    private NamespacedKey knockbackKey;
    private File cooldownFile;
    private YamlConfiguration cooldowns;
    private final Map<UUID, Long> frozen = new HashMap<>();
    private final Map<UUID, Element> passive = new HashMap<>();
    private final Set<UUID> abilityDamage = new HashSet<>();

    @Override
    public void onEnable() {
        saveDefaultConfig();
        itemKey = new NamespacedKey(this, "element");
        knockbackKey = new NamespacedKey(this, "earth_knockback");
        cooldownFile = new File(getDataFolder(), "cooldowns.yml");
        cooldowns = YamlConfiguration.loadConfiguration(cooldownFile);
        getServer().getPluginManager().registerEvents(this, this);
        getCommand("elementalmaces").setExecutor(this);
        getCommand("elementalmaces").setTabCompleter(this);
        getServer().getScheduler().runTaskTimer(this, this::tick, 1L, 20L);
    }

    @Override
    public void onDisable() {
        for (Player player : Bukkit.getOnlinePlayers()) {
            clearPassive(player);
            if (frozen.containsKey(player.getUniqueId())) player.setFreezeTicks(0);
        }
        frozen.clear();
        saveCooldowns();
    }

    private Component text(String value) {
        return LegacyComponentSerializer.legacyAmpersand().deserialize(value);
    }

    private String id(Element element) { return element.name().toLowerCase(Locale.ROOT); }

    private Element held(Player player) {
        ItemStack item = player.getInventory().getItemInMainHand();
        Element element = elementOf(item);
        if (element != null && updateModel(item, element)) player.getInventory().setItemInMainHand(item);
        return element;
    }

    private Element elementOf(ItemStack item) {
        if (item == null) return null;
        if (item.getType() != XMaterial.matchXMaterial("MACE").map(XMaterial::parseMaterial).orElse(null)) return null;
        ItemMeta meta = item.getItemMeta();
        if (meta == null) return null;
        String value = meta.getPersistentDataContainer().get(itemKey, PersistentDataType.STRING);
        if (value == null) return null;
        try { return Element.valueOf(value); } catch (IllegalArgumentException ignored) { return null; }
    }

    private boolean updateModel(ItemStack item, Element element) {
        ItemMeta meta = item.getItemMeta();
        int modelData = modelData(element);
        if (!meta.hasItemModel() && meta.hasCustomModelData() && meta.getCustomModelData() == modelData) return false;
        meta.setItemModel(null);
        meta.setCustomModelData(modelData);
        item.setItemMeta(meta);
        return true;
    }

    private int modelData(Element element) {
        return switch (element) {
            case ICE -> 1001;
            case THUNDER -> 1002;
            case EARTH -> 1003;
            case LAVA -> 1004;
        };
    }

    private ItemStack mace(Element element) {
        ItemStack item = XMaterial.matchXMaterial("MACE").map(XMaterial::parseItem).orElseThrow();
        ItemMeta meta = item.getItemMeta();
        String color = switch (element) { case ICE -> "&b"; case THUNDER -> "&e"; case EARTH -> "&2"; case LAVA -> "&c"; };
        String name = id(element);
        name = name.substring(0, 1).toUpperCase(Locale.ROOT) + name.substring(1);
        meta.displayName(text(color + name + " Mace"));
        String description = switch (element) {
            case ICE -> "&7Water breathing | Frozen Domain";
            case THUNDER -> "&7Strength I | Thunder Strike";
            case EARTH -> "&7Resistance II, knockback and fall protection | Earthquake";
            case LAVA -> "&7Fire resistance | Volcanic Eruption";
        };
        meta.lore(List.of(text(description), text("&8Sneak + left click in the air to activate")));
        meta.getPersistentDataContainer().set(itemKey, PersistentDataType.STRING, element.name());
        meta.setCustomModelData(modelData(element));
        item.setItemMeta(meta);
        return item;
    }

    private void tick() {
        long now = System.currentTimeMillis();
        for (Player p : Bukkit.getOnlinePlayers()) {
            UUID uuid = p.getUniqueId();
            Long until = frozen.get(uuid);
            if (until != null) {
                if (until <= now || p.isDead()) {
                    frozen.remove(uuid);
                    p.setFreezeTicks(0);
                } else {
                    p.setFreezeTicks(Math.max(p.getFreezeTicks(), p.getMaxFreezeTicks()));
                    particles(p.getLocation().add(0, 1, 0), "SNOWFLAKE", 8, 0.5);
                }
            }
            Element element = held(p);
            if (p.isDead() || element == null || !getConfig().getBoolean(id(element) + ".passive", true)) element = null;
            if (passive.get(uuid) != element) {
                clearPassive(p);
                if (element != null) passive.put(uuid, element);
            }
            if (element != null) {
                switch (element) {
                    case ICE -> maintainPotion(p, "WATER_BREATHING", 0);
                    case THUNDER -> maintainPotion(p, "STRENGTH", 0);
                    case EARTH -> { maintainPotion(p, "RESISTANCE", 1); addKnockback(p); }
                    case LAVA -> {
                        maintainPotion(p, "FIRE_RESISTANCE", 0);
                        if (getConfig().getBoolean("particles.passive-flames", true)) particles(p.getLocation().add(0, 0.7, 0), "FLAME", 3, 0.3);
                    }
                }
            }
        }
    }

    private PotionEffectType effect(String name) {
        return XPotion.matchXPotion(name).map(p -> p.getPotionEffectType()).orElse(null);
    }

    private void maintainPotion(Player p, String name, int amplifier) {
        PotionEffectType type = effect(name);
        if (type == null) return;
        PotionEffect current = p.getPotionEffect(type);
        if (current == null || (current.getAmplifier() == amplifier && !current.isAmbient() && !current.hasParticles() && current.getDuration() < 40)) {
            p.addPotionEffect(new PotionEffect(type, 100, amplifier, false, false, true));
        }
    }