Build the first version of a Minecraft server plugin for the new event weapon Eureon, targeting the project's configured environment. Inspect the existing project structure and implement within it. Weapon requirements: a unique sword named Eureon, visually styled in purple/blue with a polished Polish lore; show rarity as five stars and type “Przedmiot legendarny”; display kill count and the percent of extra damage gained from kills; start at Sharpness VII and gain exactly 0.01 Sharpness-equivalent per kill so that 100 kills reaches VIII. Since Minecraft enchantment levels are integers, implement the fractional progression as custom bonus damage while retaining/displaying integer Sharpness VII until the threshold; make lore percentage accurate to the custom extra damage mechanic. Track kills only when this weapon kills a player, persist progression safely per weapon/player across reloads/restarts, and prevent copied items from duplicating progression if practical. Right-click ability: activate a “Tryb zabójcy” that makes the wielder invisible and conceals armor for 20 seconds; each successful hit on another player while active adds one strike, and the third hit ends invisibility early. Ensure armor is restored safely on timeout, early cancellation, quit/death/disable, without losing or duplicating player gear. Use a clear configurable cooldown and prevent reactivation while active. The user also wants this ability's cooldown to be shared bidirectionally with another plugin, but the other plugin is not present in this workspace and no API/plugin name was provided. Do NOT claim automatic integration with an unknown plugin. Instead expose a small clean Bukkit-facing cooldown integration API (e.g. a public service/interface and/or documented event) that lets another plugin read/set the same per-player ability cooldown, and document the integration point and its limitation. Use Polish user-facing messages and sensible configurable defaults. Add a concise README/config documentation including commands/permissions if any and the cooldown integration contract. Do not ask the user questions; implement what can be delivered now, and clearly state in your final report that actual two-plugin synchronization requires the other plugin/API to be identified and linked later. Do not run a build.

Kodari AI
KodariOct 16 at 10:44 am 2
EureonWeapon
Bukkit plugin implementing the legendary event sword Eureon with purple/blue styling and Polish lore. Features five-star rarity display, fractional Sharpness progression (VII base, +0.01 per kill, 100 kills reaches VIII) implemented as custom bonus damage with accurate lore percentages. Tracks player kills exclusively, persists progression per weapon/player across restarts, and prevents copied-item duplication. Right-click activates "Tryb zabójcy": 20-second invisibility with concealed armor, three hits end it early, safe armor restoration on timeout/cancel/quit/death/disable. Configurable cooldown with public Bukkit integration API exposing per-player cooldown read/set methods and documented event for bidirectional synchronization with external plugins.
  1. Add the plugin entry point, weapon logic, and atomic per-weapon progression storage.

  2. Implement the 20-second ability, safe armor restoration, and shared cooldown service.

  3. Add Polish configuration, an admin give command, and concise integration documentation.

Implemented Eureon with Polish lore, Sharpness VII, persistent kill progression, and a configurable 20-second invisibility ability. Each kill adds 0.01 Sharpness-equivalent: custom damage bridges the integer levels, and every 100 kills raises the enchantment by one. Copies share a weapon UUID and progression.

The per-player cooldown is exposed through Bukkit’s EureonAbilityService and persists across restarts. Automatic synchronization with the other plugin is not possible until its name/API is identified and connected; the README documents the integration contract. Added /eureon give and /eureon reload, both requiring eureon.admin.

No build was run.

Update the existing Eureon Minecraft plugin in this project for the user's requested polish and ability fixes. Read current source before editing. Maintain existing persistence, API, commands, kill progression and cooldown integration.

Requested changes: 1) Rework the weapon's entire Polish lore to a clean, polished Anarchia.gg-style layout using only yellow/white text (use ChatColor.GOLD/YELLOW and WHITE; neutral gray only if necessary for separators, but prefer yellow/white). Use clear section hierarchy and symbols such as » / >>> / • / ▸, blank lines, consistent alignment. It should clearly show Eureon, rarity 5 stars, type "Przedmiot legendarny", kill count, accurate bonus damage percent, Sharpness progress (VII then VIII at 100 kills, retaining +0.01 Sharpness-equivalent per kill), ability details and cooldown if useful. Make all weapon lore text legible and don't use purple/blue lore anymore. Keep the configured values reflected in lore. Add Fire Aspect II to the Eureon sword as well as its current Sharpness scaling. 2) Fix ability activation on right-click reliably. Current EureonListener.onRightClick uses HIGHEST, ignoreCancelled=true, so it may be skipped if another plugin cancels interaction. Ensure main-hand right-click with the registered Eureon still triggers even if another handler cancelled the interaction (without affecting unrelated items); cancel the interaction appropriately. Keep anti-double-trigger for offhand. 3) Change default ability duration to 15 seconds. User wants the player to disappear fully regardless of armor, so remove/stash armor safely during the ability, apply invisibility, then restore gear without loss/duplication on timeout, early ending, death, quit, disable. Keep prior invisibility behavior safely restored. Add a visible activation animation using a brief burst/short sequence of fire/flame particles (and suitable sound if compatible), such that pressing right click gives clear feedback even if client potion invisibility rendering is unclear. Do not damage the player with the animation. Ensure ability activation failure does not strip armor. 4) End the stealth effect early after three successful hits on other entities, not only player victims; count successful damage hits by the active player against any other damageable entity. Preserve the existing per-player cooldown semantics. 5) Update config defaults/messages and README/help text to say 15 seconds, explain the 3-hit limit, fire animation, yellow/white lore, and Fire Aspect II where relevant. Keep messages in Polish.

Inspect APIs/version from existing project metadata; make implementation compatible. Do not run a build. Finish with a concise report listing changed files and behavior; do not claim compiled.

Kodari AI
KodariOct 16 at 11:01 am 1
  1. Odświeżę lore Eureona na żółto-biało i dodam Ognisty Aspekt II, zachowując progresję obrażeń.

  2. Poprawię obsługę prawego kliknięcia i aktywację umiejętności mimo anulowania interakcji.

  3. Ustawię 15 sekund, bezpieczne chowanie/zwracanie zbroi, animację i limit trzech trafień.

  4. Zaktualizuję domyślną konfigurację, komunikaty oraz README.

  • EureonPlugin.java — przeprojektowano lore na żółto-białe; pokazuje rzadkość, typ, zabójstwa, Ostrość i dokładną premię obrażeń względem bazowych obrażeń miecza. Eureon otrzymuje również Ognisty aspekt II.

  • EureonListener.java — PPM główną ręką aktywuje umiejętność także wtedy, gdy inny handler wcześniej anulował interakcję. Trzy udane trafienia w inne obrażalne byty kończą efekt.

  • AbilityManager.java — domyślny czas to 15 sekund; dodano krótką animację płomieni i dźwięk. Zbroja oraz wcześniejszy efekt niewidzialności są przywracane przy zakończeniu, trafieniu, śmierci, wyjściu i wyłączeniu pluginu; nieudana aktywacja nie powinna pozostawić zdjętej zbroi.

  • config.yml, README.md — zaktualizowano domyślne wartości, polskie komunikaty i opis działania.

Progresja zabójstw, trwały cooldown, komendy i usługa integracyjna cooldownu pozostały zachowane. Nie uruchamiałem kompilacji.

Modify the existing Eureon plugin in this project according to the latest user request. Read the current source before editing. Preserve existing weapon UUID/progression persistence, admin commands, cooldown API, and stealth ability unless changes are needed for the bossbar feature. User wants the tooltip much shorter and cleaner, an elegant white base with yellow highlights and neon mixed yellow/white/blue Eureon name; cooldown time displayed via a boss bar. Implement these requirements:

1) Rework Eureon weapon display name to a polished neon-style mixed GOLD/YELLOW + WHITE + AQUA/BLUE legacy color treatment, keeping the actual name exactly “Eureon” (not spaced letters). The dropped item should also visibly identify as Eureon when possible (e.g. item custom name already shows in tooltip; add entity visible custom name on drop only if safe and compatible). Keep the lore concise, not an encyclopedic weapon description. Use mostly white text with only key labels/important values in yellow, with a few blue accents, consistent » / >>> separators, clean spacing. Include only the type (Przedmiot legendarny), rarity (★★★★★), the 100-kill target and a compact kill progress display (current kills / 100 and a visually colored progress bar or percentage). Clearly say that at 100 kills Eureon unlocks +100% additional damage and Sharpness VIII. Remove unrelated ability/cooldown/Fire Aspect details and verbose technical lines from lore. Show progress clearly before unlock and completed/unlocked state at/after 100 kills.

2) Make gameplay match the explicit advertised milestone: progress should represent 1 percentage point of additional melee damage per Eureon kill, capped at +100% once 100 kills are reached; at 100 kills weapon Sharpness should be VIII. Ensure the damage mechanic is applied once per valid melee hit, derived sensibly from the existing event damage and not recursively or twice, and the displayed progress/bonus is accurate. Keep Fire Aspect II. If code architecture means bonus scaling modifies event damage, use a clear bounded formula (kills capped 0..100, multiplier 1.0 + kills/100.0); do not let damage keep growing past 100. Existing persisted kill totals should remain; counts above 100 show complete and damage capped at 100%. Update stale messages/docs that claim old progression if relevant.

3) Add a Bukkit boss bar for the ability cooldown that visibly displays remaining cooldown/time for each player, updating smoothly (e.g. once per second) and removing/hiding itself when cooldown expires, player quits, plugin disables, or cooldown gets cleared/externally changed. Create/show it after ability activation once cooldown is set. It should display remaining time in Polish, show a sensible progress fraction remaining/cooldown duration, and not interfere with boss bars from other plugins. Ensure it stays accurate across existing persistent cooldown data/restarts, and integrates with existing EureonAbilityService updates as far as practical. Clean up tasks/bars and handle offline players without leaks. Read the current AbilityManager and data store APIs; do not break other plugin cooldown integration.

Update README/config text for the concise lore, progression and cooldown bossbar. Keep messages Polish. Inspect API/version from project metadata and keep compatible. Do not run a build. Finish with a brief report of changed files and behavior; do not claim compiled.

Kodari AI
KodariOct 16 at 11:11 am 2
  • EureonPlugin.java — skrócono lore, dodano neonową biało-żółto-błękitną nazwę i pasek postępu. Premia wynosi +1% za zabójstwo, maksymalnie +100%; Ostrość VIII odblokowuje się przy 100 zabójstwach, a Ognisty aspekt II pozostaje.

  • EureonListener.java — premia skaluje obrażenia z pojedynczego trafienia Eureonem; zabójstwa nadal liczą się tylko za graczy.

  • AbilityManager.java — dodano osobny bossbar z pozostałym cooldownem, odświeżany co sekundę i aktualizowany przez usługę cooldownu; pasek znika po wygaśnięciu, wyjściu gracza lub wyłączeniu pluginu.

  • config.yml, README.md — opisują nowy tytuł bossbara, skrócone lore i ograniczoną do +100% progresję.

Zachowano UUID broni, zapis progresji, komendy i API cooldownu. Kompilacji nie uruchamiałem.

Implement the user's latest polish and cooldown UI requests in the EXISTING Eureon plugin. Read current source before editing. Current code was inspected: EureonPlugin builds display name using different colors per individual letter; lore currently has many lines and block-style progress bar; Sharpness is VII then VIII at 100 kills, Fire Aspect II; AbilityManager currently has cooldown BossBar maps/task from prior change; EureonListener sends cooldown to chat. Preserve weapon IDs/data persistence, kill progression/damage behavior, command/service API, and stealth behavior unless needed for requested changes.

Requirements: 1) Rework item display name and lore to feel polished and compact, with cohesive yellow/white/gold flowing color transitions rather than a different color for every character. Actual item name must remain exactly “Eureon”; make it bold if appropriate. Use legacy ChatColor spans in grouped word chunks (not per-character rainbow). Name should be a neon-like blend of yellow, white, and gold. Lore mainly white, key labels/values in yellow/gold, separators/» and compact punctuation. Avoid long vertical encyclopedic lore. Include concise lore indicating it is from the server-launch event, type “Przedmiot legendarny”, rarity five stars, current kill count / 100, and one simple horizontal progress line that is filled proportionally to kill progress (prefer ~20 chars with filled yellow/gold and unfilled white/gray; also show % or kills). State succinctly that at 100 kills Sharpness VIII is unlocked. At 0–99 the actual enchant remains Sharpness VII; at 100+ actual enchant is VIII. Keep Fire Aspect II. Keep prior existing damage progression behavior and accurate data, but do not clutter lore with unrelated detail. Preserve UUID progression and refresh lore on kills. 2) Hide enchantment lines in the item tooltip using ItemFlag.HIDE_ENCHANTS while retaining real Sharpness VII/VIII and Fire Aspect II enchantments. Ensure flag is applied both on creation and refresh/update. 3) Remove the cooldown bossbar UI entirely: cooldown should NOT be continuously displayed and should only be shown when the player tries to activate too early. Remove/disable the per-player BossBar maps, task, and all UI/cleanup code as appropriate, while preserving persisted cooldown semantics, read/set behavior through EureonAbilityService and external plugin integration. 4) On early click during cooldown, show a concise red action-bar message: “Do użycia pozostało {czas}” where {czas} is a readable remaining time (prefer mm:ss when over one minute, seconds otherwise). It must not appear continuously or in the lore. Do not send the cooldown message to chat. Use a Bukkit/Spigot-compatible actionbar API for this project. Keep other unrelated messages/ability activation semantics unchanged; the ability description/lore can briefly name “Tryb zabójcy” but should not mention cooldown. 5) Update README and default config messages to describe the minimal lore, proportional progress, hidden enchantment tooltip, and cooldown shown only on early use (no bossbar). Configure red action-bar message string cleanly, with a placeholder such as %time%.

Inspect target APIs/config carefully and keep code compatible. Do not run a build. Finish by reporting files/changes; do not claim compilation.

Kodari AI
KodariOct 17 at 8:49 am 1
  1. Zmienię nazwę i lore na krótkie, spójne wizualnie, z proporcjonalnym paskiem progresu i ukrytymi liniami enchantów.

  2. Usunę wyświetlanie cooldownu bossbarem i zastąpię komunikat przy przedwczesnym użyciu czerwonym actionbarem.

  3. Dostosuję domyślne wiadomości i README; zachowam zapis progresji, obrażenia, API i działanie umiejętności.

  • EureonPlugin.java — skrócono lore do informacji o evencie, typie, rzadkości, progresie i celu. Dodano 20-segmentowy pasek, ograniczony do 100/100, spójny złoto-żółto-biały gradient nazwy oraz HIDE_ENCHANTS przy tworzeniu i odświeżaniu. Rzeczywiste enchanty pozostają bez zmian.

  • AbilityManager.java — usunięto bossbar cooldownu i powiązane zadania oraz odświeżanie UI. Zapis cooldownu i integracja EureonAbilityService zostały zachowane.

  • EureonListener.java — informacja o cooldownie pojawia się wyłącznie po przedwczesnej próbie użycia, jako czerwony actionbar z czasem w sekundach lub formacie mm:ss.

  • config.yml, README.md — opisują krótkie lore, pasek progresu, ukryte linie enchantów i cooldown widoczny tylko przy próbie aktywacji.

Nie uruchamiałem kompilacji.

Extend the existing Eureon plugin for the user's newest Polish requirements. Read the current source before editing. Preserve the UUID weapon identity, durable storage, /eureon give|reload, and public cooldown service. Target current configured Bukkit/Paper API 1.16+ and existing XSeries dependencies; do not run a build.

GAME/DESIGN REQUIREMENTS 1) Redesign the weapon display name and lore, concise and polished. The actual visible name must remain “Eureon”, bold if suitable, with a cohesive yellow/white/gold blend in grouped chunks (not a different color per letter). Lore should be mostly white with highlighted yellow/gold values and neat », bullets, spacing. Follow this compact layout/content:

  • » Typ: Przedmiot legendarny
  • » Rzadkość: ★★★★★
  • short line that it is from the server launch event 2027
  • starts with Sharpness VII; at 100 kills becomes Sharpness VIII
  • a single continuous horizontal progress bar (no spaces between bar segments), proportionate from 0 to 100, with current kill count/100 or percent
  • show current nominal damage as 12 before completion and 13 at completion (the values the user specifically requested; label as nominal/base if needed), and explain succinctly that 100 kills unlock Sharpness VIII / 13 damage.
  • mention /eureon to inspect superpowers, with minimal lore only.

Keep real Sharpness VII/VIII and Fire Aspect II, but hide their tooltip enchant lines (preserve HIDE_ENCHANTS). Remove the old per-kill +1% damage multiplier: the requested milestone is Sharpness VII -> VIII / nominal 12 -> 13. Only superpower #2 adds the extra damage bonus described below. Continue persisting kills and refresh lore on kill. Counts cap for display/enchant milestone at 100.

2) Implement a persistent randomly assigned single superpower per weapon, from these exact five powers, unlocked only once that weapon reaches 100 player kills. Store it by weapon UUID in EureonDataStore so restarts/copies remain consistent; existing weapons without a saved choice must receive one safely and persist it. Choose once per weapon; all copies share it. The five powers: 1. Tryb zabójcy: on right click, invisible for 10 seconds, including armor and items held in main/off hand; cooldown 180 seconds. Safely stash/clear equipment while invisible and restore without loss/duplication on timeout, quit/death/disable. Prevent switching/re-equipping items during stealth or otherwise ensure items cannot reveal the player. Follow current inventory safety patterns, with rollback if activation fails. Latest request specifies full 10s; do not end after earlier old 3-hit rule. 2. Brutalna siła (or similarly clear Polish name): passive +10% melee damage while holding this unlocked Eureon. Apply exactly once per valid attack, bounded/simple; do not change Sharpness and avoid double application. State it as +10% additional damage in GUI. 3. Władca burz: right click while aiming at an entity hits that target with lightning visual/effect and deals exactly 3 hearts (6 health) regardless of armor. Cooldown 120 seconds. Prevent arbitrary repeated click; use existing shared per-player cooldown API for the cooldown semantics. Prefer Bukkit-compatible ray tracing to find the targeted living/damageable entity. Avoid damaging the attacker or bystanders. Implement armor-independent damage carefully (respect canceled/protected damage where feasible, do not accidentally set fire or damage nearby entities; lightning visual should be non-damaging). Provide Polish feedback on missing target/cooldown as appropriate. 4. Regeneracja: Regeneration I while the unlocked Eureon is held. 5. Siła: Strength I while the unlocked Eureon is held.

For passive powers 4/5, maintain the effect only while the owning unlocked Eureon is in either hand. Use a safe repeating/task or inventory-hand events. Do not indefinitely overwrite stronger/longer effects from potions or other plugins; clean up effects on switching/death/quit/disable and preserve pre-existing effects safely.

3) Right-click activates only the assigned power and only after 100 kills. For active powers, display its configured cooldown in a red actionbar only on attempted use before ready (not constantly, no bossbar). Power 1 uses 180s and 10s duration; power 3 uses 120s. Preserve service-based shared cooldown read/set/clear integration. Do not accidentally activate the old generic ability for all weapons; adapt AbilityManager to the assigned power. Use the existing safe armor/effect restoration patterns and clear UI/tasks on quit/death/disable.

4) Add a /eureon GUI available to ordinary players (no admin permission) showcasing all five powers, using fitting item icons including diamond, emerald and netherite-themed materials, with clear compact Polish names/descriptions. Include a Eureon sword/status panel showing kill progress and, if the player holds a Eureon, that sword's assigned superpower; mark it as locked until 100 kills and active/unlocked at 100. The five listed powers are the random choices; GUI must explain one is assigned to each sword and can be used only after 100 kills. Preserve admin commands /eureon give <gracz> and /eureon reload with eureon.admin. Ensure GUI clicks cannot take/move items and close action is safe. Keep command names case-insensitive.

5) Update config.yml and README in Polish, documenting exact unlock, damage milestone, the five random powers and their cooldowns/conditions, concise lore, GUI, and dependency limitations. Include sane Polish messages for locked weapon, cooldown, storm target, activation. Keep older cooldown integration APIs stable.

Read related files (EureonPlugin, EureonListener, AbilityManager, EureonDataStore, EureonCommand, config, plugin.yml, README) and make coordinated changes. Do not claim compile/build. Report concise summary and changed files.

Kodari AI
KodariOct 17 at 9:15 am 3
  1. Sprawdzę istniejący model broni, zapis UUID/progresji, cooldown API i obsługę umiejętności.

  2. Wdrożę pięć przypisanych do broni mocy, kamień milowy 100 zabójstw oraz zabezpieczenia efektów i wyposażenia.

  3. Dodam GUI /eureon, zwięzłe lore i polskie opisy w konfiguracji/README.

  • Broń i progresja: usunięto premię rosnącą za zabójstwa. Eureon ma Ostrość VII i nominalne 12 obrażeń; przy 100 zabójstwach odblokowuje Ostrość VIII i nominalne 13. Zachowano Ognisty aspekt II oraz ukryte linie enchantów. Moc jest losowana raz na UUID i zapisywana wraz z progresją; kopie miecza dzielą wybór i postęp.

  • Supermoce: dodano wszystkie pięć mocy. Brutalna siła daje +10% obrażeń wręcz; Regeneracja i Siła działają podczas trzymania odblokowanego miecza. Tryb zabójcy trwa 10 sekund i chowa zbroję oraz przedmioty z obu rąk; Władca burz zadaje celowi 3 serca obrażeń, a efekt błyskawicy nie rani innych bytów.

  • Cooldowny i bezpieczeństwo: aktywne moce korzystają ze wspólnego, zapisywanego cooldownu i zachowanego EureonAbilityService. Cooldown pokazuje się tylko przy przedwczesnej próbie użycia, czerwonym actionbarem. Dodano ochronę ekwipunku podczas niewidzialności oraz zarządzanie pasywnymi efektami.

  • GUI i dokumentacja: /eureon otwiera menu dla wszystkich graczy; /eureon give i /eureon reload nadal wymagają eureon.admin. Zaktualizowano README.md, config.yml i plugin.yml.

  • Zmieniono EureonPlugin.java, EureonListener.java, AbilityManager.java, EureonDataStore.java, EureonCommand.java oraz dodano EureonPower.java i EureonMenu.java. Nie uruchamiałem kompilacji.

Kodari can make mistakes. Review important code before using.
Files
src
README.md
Code
11 1,351
src/main/java/pl/kodari/eureon/EureonPlugin.java
package pl.kodari.eureon;

import com.cryptomorin.xseries.XEnchantment;
import com.cryptomorin.xseries.XItemFlag;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.ChatColor;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import java.util.UUID;

public final class EureonPlugin extends JavaPlugin {
    private NamespacedKey weaponIdKey;
    private XEnchantment sharpness;
    private XEnchantment fireAspect;
    private EureonDataStore dataStore;
    private AbilityManager abilityManager;
    private EureonMenu eureonMenu;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        weaponIdKey = new NamespacedKey(this, "weapon_id");
        sharpness = XEnchantment.matchXEnchantment("SHARPNESS")
                .orElseThrow(() -> new IllegalStateException("XSeries nie rozpoznaje enchantmentu SHARPNESS"));
        fireAspect = XEnchantment.matchXEnchantment("FIRE_ASPECT")
                .orElseThrow(() -> new IllegalStateException("XSeries nie rozpoznaje enchantmentu FIRE_ASPECT"));
        dataStore = new EureonDataStore(this);
        abilityManager = new AbilityManager(this, dataStore);
        eureonMenu = new EureonMenu(this);

        getServer().getPluginManager().registerEvents(new EureonListener(this, abilityManager), this);
        getServer().getPluginManager().registerEvents(eureonMenu, this);
        getServer().getServicesManager().register(
                EureonAbilityService.class, abilityManager, this, ServicePriority.Normal);
        EureonCommand command = new EureonCommand(this);
        getCommand("eureon").setExecutor(command);
    }

    @Override
    public void onDisable() {
        if (abilityManager != null) {
            abilityManager.shutdown();
        }
    }

    public ItemStack createWeapon() {
        ItemStack item = XMaterial.matchXMaterial("NETHERITE_SWORD")
                .map(XMaterial::parseItem)
                .orElseGet(() -> XMaterial.matchXMaterial("DIAMOND_SWORD")
                        .map(XMaterial::parseItem)
                        .orElseThrow(() -> new IllegalStateException("Brak materiału miecza dla Eureona")));
        UUID id = UUID.randomUUID();
        dataStore.registerWeapon(id);
        getOrAssignPower(id);

        ItemMeta meta = item.getItemMeta();
        setWeaponDisplayName(meta);
        meta.addEnchant(sharpness.getEnchant(), 7, true);
        meta.addEnchant(fireAspect.getEnchant(), 2, true);
        XItemFlag.of("HIDE_ENCHANTS").ifPresent(flag -> flag.set(meta));
        meta.getPersistentDataContainer().set(weaponIdKey, PersistentDataType.STRING, id.toString());
        meta.setLore(buildLore(0));
        item.setItemMeta(meta);
        return item;
    }

    public UUID getWeaponId(ItemStack item) {
        if (item == null || !item.hasItemMeta()) {
            return null;
        }
        String rawId = item.getItemMeta().getPersistentDataContainer()
                .get(weaponIdKey, PersistentDataType.STRING);
        if (rawId == null) {
            return null;
        }
        try {
            return UUID.fromString(rawId);
        } catch (IllegalArgumentException ignored) {
            return null;
        }
    }

    public boolean isWeapon(ItemStack item) {
        UUID id = getWeaponId(item);
        if (id == null || !dataStore.hasWeapon(id)) {
            return false;
        }
        getOrAssignPower(id);
        return true;
    }

    public int getKills(UUID weaponId) {
        return dataStore.getKills(weaponId);
    }

    public int recordKill(UUID weaponId, ItemStack heldItem) {
        int kills = dataStore.addKill(weaponId);
        updateWeaponLoreAndEnchantment(heldItem, weaponId, kills);
        return kills;
    }

    public synchronized EureonPower getOrAssignPower(UUID weaponId) {
        EureonPower saved = EureonPower.fromStored(dataStore.getPower(weaponId));
        if (saved != null) {
            return saved;
        }
        EureonPower[] powers = EureonPower.values();
        EureonPower selected = powers[ThreadLocalRandom.current().nextInt(powers.length)];
        dataStore.setPower(weaponId, selected.name());
        return selected;
    }

    public void refreshWeapon(ItemStack item, UUID weaponId) {
        updateWeaponLoreAndEnchantment(item, weaponId, dataStore.getKills(weaponId));
    }

    private void updateWeaponLoreAndEnchantment(ItemStack item, UUID weaponId, int kills) {
        if (item == null || !item.hasItemMeta() || !weaponId.equals(getWeaponId(item))) {
            return;
        }
        ItemMeta meta = item.getItemMeta();
        setWeaponDisplayName(meta);
        meta.addEnchant(sharpness.getEnchant(), kills >= 100 ? 8 : 7, true);
        meta.addEnchant(fireAspect.getEnchant(), 2, true);
        XItemFlag.of("HIDE_ENCHANTS").ifPresent(flag -> flag.set(meta));
        meta.setLore(buildLore(kills));
        item.setItemMeta(meta);
    }

    private void setWeaponDisplayName(ItemMeta meta) {
        meta.setDisplayName(ChatColor.GOLD.toString() + ChatColor.BOLD + "Eu"
                + ChatColor.YELLOW + ChatColor.BOLD + "re"
                + ChatColor.WHITE + ChatColor.BOLD + "on");
    }

    private List<String> buildLore(int kills) {
        int progress = Math.min(100, Math.max(0, kills));
        List<String> lore = new ArrayList<>();
        lore.add(ChatColor.DARK_GRAY + ">>> " + ChatColor.YELLOW + "EVENT STARTOWY 2027");
        lore.add(ChatColor.GOLD + "» " + ChatColor.WHITE + "Typ: " + ChatColor.YELLOW + "Przedmiot legendarny");
        lore.add(ChatColor.GOLD + "» " + ChatColor.WHITE + "Rzadkość: " + ChatColor.YELLOW + "★★★★★");
        lore.add(ChatColor.GOLD + "» " + ChatColor.WHITE + "Zabójstwa: " + ChatColor.YELLOW + progress + "/100"
                + ChatColor.DARK_GRAY + " • " + ChatColor.WHITE + "Ostrość "
                + ChatColor.YELLOW + (progress >= 100 ? "VIII" : "VII"));
        lore.add(progressBar(progress) + ChatColor.WHITE + " " + ChatColor.YELLOW + progress + "%");
        lore.add(ChatColor.GOLD + "» " + ChatColor.WHITE + "Obrażenia bazowe: "
                + ChatColor.YELLOW + (progress >= 100 ? "13" : "12"));
        if (progress >= 100) {
            lore.add(ChatColor.YELLOW + "» Ostrość VIII odblokowana" + ChatColor.DARK_GRAY
                    + " • " + ChatColor.WHITE + "13 obrażeń");
        } else {
            lore.add(ChatColor.GRAY + "100 zabójstw " + ChatColor.GOLD + "→ " + ChatColor.WHITE
                    + "Ostrość VIII " + ChatColor.DARK_GRAY + "• " + ChatColor.YELLOW + "13 obrażeń");
        }
        lore.add(ChatColor.DARK_AQUA + "» " + ChatColor.WHITE + "/eureon" + ChatColor.GRAY + " • supermoce");
        return lore;
    }

    private String progressBar(int progress) {
        int filled = progress / 5;
        StringBuilder bar = new StringBuilder();
        for (int i = 0; i < 20; i++) {
            bar.append(i < filled ? ChatColor.YELLOW + "■" : ChatColor.WHITE + "·");
        }
        return bar.toString();
    }

    public AbilityManager getAbilityManager() {
        return abilityManager;
    }

    EureonMenu getEureonMenu() {
        return eureonMenu;
    }
}