Build the new, currently empty Bukkit plugin project named EXACTLY "AFK + Spawn 2-1" (public display name, documentation, GUI branding). Use a valid machine plugin name AFKSpawn21 if Bukkit plugin.yml requires a sanitized name. User explicitly requests Paper AND Spigot, targeting the release range 1.21 through 26.3. Use baseline Bukkit/Spigot 1.21 API, api-version '1.21', no NMS, no Paper-only mandatory APIs or internal version checks; retain forward-compatible material/sound handling. Do not assert runtime testing for future/new server releases. Inspect whatever starter/build environment exists, implement feature code and resources only; do not write tests or run builds. I handle compile. Provide a concise implementation summary and paths afterward.

FEATURES (faithfully implement, do not substitute automatic inactivity detection): 1) /afk is available to EVERY player, OP or not, and opens configurable AFK destinations inventory GUI. Left click selects an existing area, closes the GUI, and teleports player there with configurable teleport countdown/sounds (allow zero); NO teleport cooldown anywhere in this plugin. No automatic inactivity/AFK detection. Players may stand or walk inside an AFK area and earn rewards based on continuous time inside it; area detection is geometric, not inactivity. /setafk <name> OP ONLY saves player's destination, adds it immediately to GUI, and persists across restart. Safe default area boundary configurable radius e.g. 10 blocks around set location, with a clearly editable radius/bounds for each destination. Area selection must not require installing integrations. Per-player timers, world/boundary/online checks, no earning outside area or offline, no simultaneous duplicate reward in overlapping areas. Award interval is separately configurable in hours/minutes/seconds, DEFAULT 0h 1m 0s; every interval in area awards default 1 shard. This is a reward countdown, not a teleport cooldown. Stop/reset progress when leaving area, teleporting out, death, quitting; re-entering starts fresh. Configurable teleport countdown for AFK is separate and clearly labeled. 2) Shards: material AMETHYST_SHARD (user called it an amethyst crystal). Make configurable display name/lore/material/amount and PDC-mark these reward items so ordinary amethyst shards cannot impersonate currency. %shard% internal placeholder = player's current count of marked shards; document semantics. Count marker, not display name. Do not build an unsolicited shop; user will configure special rewards later. Provide a clean reward/currency service and documented optional reward-console-command list so future reward integration is possible. No loss when inventory is full: persist pending shard rewards and deliver when inventory space becomes available or on join. Avoid unbounded repeated task scheduling; persist only changed data. Keep balance semantics clear (inventory-held marked shards vs pending) in docs/placeholder list. 3) /spawn is universally available for players and opens configurable Lobby GUI. Left click a configured spawn icon, close menu, then start its configurable teleport countdown; once done teleport to selected location. Show countdown messages/actionbar if configured, configurable sounds. No cooldown in command or menus. Movement/damage cancellation configurable and correctly cancel old countdown when selecting another target. /setspawn <name> OP ONLY records location and creates/updates menu destination immediately with editable name/icon/lore. /spawn delete <name> OP ONLY deletes it and persists, refreshes open GUIs/cancels invalid pending teleports as necessary. Ops can use all player commands. Non-OPs must not access any administrative subcommand, including via direct commands or spoofed GUI clicks. Use isOp for user-requested OP-only enforcement; normal /afk and /spawn do not require permissions. Provide OP reload capability if useful, document commands; don't allow reserved subcommand names as destinations. 4) In /spawn GUI, OP right click on a spawn icon opens a 9-slot deletion confirmation GUI for that particular destination. Slot layout exactly: 0,1,2 filler; 3 Cancel Delete; 4 filler; 5 Confirm Delete; 6,7,8 filler. Cancel returns to Lobby, confirm removes the selected destination safely (revalidate OP and identity on click), plays configured sound, returns/refreshes menu. Non-OP right click must never delete or open admin confirmation. All GUI titles, sizes (confirmation exactly 9), slots, names, icons, lore, filler enabled/material/name/lore, and sounds for open/select/cancel/confirm/delete configurable within sane layout rules. Prevent GUI item theft, shift transfers, double clicks, drag/hotbar/offhand exploits using InventoryHolder/session ownership, not title matching; still permit normal player inventory behavior outside plugin GUIs. Support enough destinations via configurable pagination rather than silently dropping extras. Fully configurable lore/messages with color support and placeholders. 5) Public/editable data folder layout under plugins/AFKSpawn21 (or clearly documented actual data-folder name): gui/spawn/<name>.yml holds each spawn location (world UUID+name, coordinates/yaw/pitch), icon, lore, display name and per-location override settings; gui/afk/<name>.yml same for AFK destinations plus boundary/reward configuration; gui/config/config.yml for all settings/sounds and gui/config/menus.yml for menu layouts; gui/lang/en.yml (or messages.yml) for support messages and documented placeholder list. Generate defaults without overwriting edits; validation with usable warnings and fallbacks, atomic/safe persistence where practical, reject path traversal names, handle unloaded/missing worlds gracefully without breaking all destinations. Place docs explaining files, all commands, configuration, placeholders, how to define AFK areas and later rewards. 6) Teleport-on-death: configurable mode BED or SPAWN, configurable destination name e.g. spawn1; BED honors player's valid bed/respawn point and falls back to configured spawn when no valid bed/respawn exists, SPAWN prefers configured spawn. Handle respawn events at correct time, no death-event teleport hack; gracefully keep server vanilla respawn if named destination is missing/unloaded. Include explicit readable config setting teleport-on-death and ability disable. first-join: spawn1 (named spawn setting, disable option) teleports genuinely new players only after join; no forced teleport for returning players. Missing spawn1 warns gracefully and does not create fake locations. 7) softdepend on WorldGuard, WorldEdit (the user wrote 'worldguardedit', intending WorldEdit), PlaceholderAPI. Core functionality must work with none installed. Real optional integrations, guarded/lazy initialization, no hard classloading dependency: WorldEdit selections may optionally supply cuboid bounds during /setafk if a valid selection exists (otherwise configurable radius); WorldGuard region IDs may optionally define/validate AFK boundaries and respect relevant teleport/entry protection rather than bypassing protection; gracefully fall back/disable optional behavior with warnings if hook unavailable. Be explicit in docs about what each hook does; do not just claim integration from softdepend alone. Use official provided/compile-only APIs where available through project manifest/build setup; no bundling these plugins. PlaceholderAPI expansion identifier afkspawn with useful %afkspawn_shard%, destination count/current area/reward countdown values, correct persistence flag, null/offline safety. Internal %shard% etc work WITHOUT PAPI. Other installed PAPI placeholders can expand in messages/lore safely when present. No inventory currency exploit or unauthorized administrative path.

ARCHITECTURE/QUALITY: Modular destination/config persistence, inventory listeners, teleport manager, shard/AFK reward scheduler, isolated optional hooks, placeholder formatting. Clean cancellation on disable/reload, no cross-thread Bukkit calls or per-tick disk IO; robust handling quit/death/world changes/reload/deleted targets and stale GUIs. Appropriate console errors for player-only commands. Defaults should be immediately usable once OP sets destinations; provide helpful empty-menu messages. Deliver functioning plugin plus resource defaults/documentation, not just scaffold. Scope is this single combined plugin, no other plugins/projects needed.

Kodari AI
KodariNov 8 at 6:11 am 22
AFKSpawn21
A comprehensive Bukkit/Spigot/Paper plugin for Minecraft 1.21+ that provides AFK destination management and spawn point systems. Players can use /afk to open a GUI with configurable AFK areas, earn amethyst shard rewards for continuous time spent inside geometric boundaries, and use /spawn to teleport to configured lobby locations. Features include per-player timers, configurable teleport countdowns, PDC-marked currency items, pending reward persistence, OP-only administrative commands (/setafk, /setspawn, /spawn delete), a deletion confirmation GUI, teleport-on-death and first-join options, pagination support, and optional WorldGuard/WorldEdit/PlaceholderAPI integrations. All GUI layouts, messages, sounds, and settings are fully configurable through YAML files with atomic persistence.
  1. Create destination persistence, editable configuration, and safe paginated menus.

  2. Add cancellable teleport countdowns, geometric AFK rewards, and persistent pending shards.

  3. Add respawn/first-join handling and isolated optional integrations.

  4. Document commands, placeholders, configuration, and compatibility limits.

Implemented AFK + Spawn 2-1 with:

  • Safe paginated AFK/Lobby menus and OP-only destination management.

  • Separate teleport countdowns, geometric AFK rewards, PDC-marked shards, and persistent pending delivery.

  • Death/first-join routing and isolated WorldEdit, WorldGuard, and PlaceholderAPI hooks.

Paths

  • Java: src/main/java/com/kodari/afkspawn/

  • Defaults: src/main/resources/gui/

  • Documentation: src/main/resources/GUIDE.md

  • Runtime data: plugins/AFKSpawn21/

Start with /setspawn spawn1 and /setafk crystals.

No builds or tests were run. Compatibility through 26.3 is targeted, not runtime-verified.

Update existing AFK + Spawn 2-1 per user correction. Read current source/resources first; feature code only, no tests/builds (lead will compile). I inspected AFKSpawnPlugin.java, ShardService.java, RewardManager.java, PlayerEvents.java, Hooks.java, Text.java, PapiHook.java, DestinationStore.java, plugin.yml/config/lang/GUIDE.

USER REQUIREMENTS:

  • %shard% must be VIRTUAL currency balance, never physical inventory items. Player rewards should be backed by optional Vault OR VaultUnlocked economy integration; user will add integrations later. Vault is a bridge and needs a registered Economy provider: communicate this clearly, do not claim Vault alone stores balances or creates a separate multi-currency shard economy.
  • Keep /setafk <name> generic, with NO hardcoded 'crystals' command/example requirement. Existing implementation is generic; remove the /setafk crystals example in GUIDE and any such docs/messages and use /setafk <name> (explain to replace name). Amethyst may remain AFK GUI icon only, not currency inventory item.
  • Fully connect /afk and /spawn subcommands/usage/tab completion. Add OP-only /afk reload, preserve/fix OP-only /spawn reload. Both refresh destinations/config/lang/menus/hooks and command-related state; reload all shared config consistently rather than partially load dependencies. All /afk and /spawn base commands remain universal and no cooldowns or automatic AFK detection.

IMPLEMENTATION SPEC: 1) Replace item-based ShardService with persistent UUID-based virtual currency service. Remove inventory delivery/create/counting as currency functionality and all callsites in RewardManager, PlayerEvents, Text, PapiHook. No item reward from any code path. Provide useful public API via getShardService for future rewards: balance by OfflinePlayer/UUID, deposit/award, safe withdraw with insufficient-funds/positive-finite validation; preferably explicit success/failure. Atomic persistent internal balances with rollback on failed IO, no per-second unchanged writes, bounded/validated values, restart/reload safety and readable formatting. Default INTERNAL virtual backend so plugin works before user adds economy dependencies. Add documented config e.g. shard.backend: INTERNAL or VAULT; VAULT deposits to installed provider and %shard% reports SAME provider's balance, never unrelated internal/inventory count. Explicit config opt-in to VAULT avoids silently losing/mixing internal balances when plugins are later installed. Docs: when user installs Vault or VaultUnlocked AND compatible economy provider they set backend VAULT, then /afk reload or /spawn reload; Vault-backed shards represent the provider's normal currency unless provider offers a dedicated shard currency. Do not implement a fictitious separate currency in standard Vault. Never silently migrate internal balances to provider on backend switches, document that existing internal ledger is retained and migration isn't automatic. 2) plugin.yml softdepend add exact plugin names Vault and VaultUnlocked, retain WorldGuard/WorldEdit/PlaceholderAPI. Isolate optional economy classes/loading, no mandatory linkage with either missing. Use standard Economy API compatibility for Vault/VaultUnlocked, accounting for whichever APIs actually available in project dependency setup (inspect .kodari/build settings/manifest; reflection acceptable only with correct service lookups, response validation and provider availability). Do NOT blindly cast services to Object or log enabled without a registered provider. Validate deposit and withdrawal EconomyResponse.transactionSuccess; handle missing provider, unregister/register or disabled bridge/provider gracefully and never award phantom successes. Provider unavailable in VAULT mode should preserve earned rewards as persistent pending virtual credits for later delivery, not create items or quietly switch to INTERNAL. %shard% = spendable selected backend balance; %pending% = undeposited virtual credits (if retained); notify honestly queued vs actually credited, no repeat console reward hooks on retry. Don't repeatedly spam log/schedule tasks when absent. External economic transactions cannot be made perfectly atomic across arbitrary provider/database and local disk; avoid naive double-deposit retry on local save failure and document uncertainty, never claim impossible exactly-once behavior. Keep implementation sensible and small. 3) Existing pending-shards.yml contains pending ITEMS from old version. Safely, once-only preserve that numerical value as virtual credits (internal or pending appropriate to current backend), with durable migration marker/backup and no duplication on restart. Legacy physical marked shard items must not be counted or silently redeemed; document they no longer count, leave items alone. Update all default reward messages and placeholder explanations, remove obsolete inventory/pending delivery wording/material/lore currency settings from defaults (can preserve unused existing YAML keys). Upgrade existing gui/lang/en.yml defaults surgically: unchanged old built-in reward/delivered/placeholder descriptions should be updated so existing installations don't show 'Inventory'; preserve genuinely customized messages. Update existing generated GUIDE only if safe or supply current docs in artifact. PAPI %afkspawn_shard% supports offline balances if backend supports them, no blanket fake zero on async for cached internal balance; don't invoke unsafe Bukkit/provider API off-thread (safe snapshot/offline cache strategy or documented graceful fallback). Internal %shard% formats same balance as PAPI. 4) Refactor AFKSpawnPlugin command routing to share /afk and /spawn dispatch. Explicitly implement/document: /afk and /spawn -> menus (all players) /afk reload and /spawn reload -> OP-only complete shared reload, no balance wipe/duplicate timers/PAPI expansion, command state usable after reload. /afk delete <name> and /spawn delete <name> -> OP-only symmetric named destination deletion (spawn existing semantics), persist, invalidate pending teleports and refresh correct menus. /setafk <name> and /setspawn <name> -> OP only as before; optionally offer /afk set <name> and /spawn set <name> aliases for connected subcommands, if implemented reserve set and document. /afk help and /spawn help -> helpful appropriate public/OP command listing, no unauthorized administrative operation. Reserve any implemented subcommand names in DestinationStore.valid, including help; don't delete existing valid destinations just because adding reserved words (warn/migrate handling as appropriate).

Correct argument validation, localized type-specific usage, case-insensitive matching, tab-complete actual subcommands/named delete targets per type, no admin target/subcommand suggestions to non-OPs. Unknown args get usage; no invented teleport-by-name behavior. Console can reload/help as OP/console if straightforward but set/menu remains player-only. Revalidate OP and stale GUI ownership unchanged. Delete operations don't require creating unsolicited AFK right-click GUI unless refactoring naturally supports it. 5) Preserve rest of working plugin: menu security/exact spawn 9-slot confirmation/pagination, areas geometry/timers default 1 minute, configurable sounds/countdown, OP restriction, death/first join, optional other integrations. Cleanly coordinate load/reload order for currency backend hooks and balances: currently settings.load->shards.load->store.load->hooks.load, reload omits shards.load; adapt carefully to avoid overwriting unsaved state, loading twice, stale economy hook, duplicate payouts. No synchronous unbounded migration or per-player repeating tasks.

Done: coherent virtual rewards and documented Vault/VaultUnlocked opt-in with missing-provider fallback queue; both reloads and connected management subcommands work and are tab-completed; no item payouts or mandatory 'crystals' name; updated resources/guide. Summarize exact command list/config keys and any integration caveats. Do not run build or create tests.

Kodari AI
KodariNov 8 at 6:26 am 10
  1. Replace item shards with persistent virtual balances and optional economy-backed credits.

  2. Connect shared AFK/spawn commands, reloads, help, deletion, and tab completion.

  3. Update messages and guidance for virtual currency, migration, and economy setup.

Virtual rewards now use a UUID ledger with no item delivery. Vault mode checks for a registered economy provider, queues undelivered rewards, and holds uncertain transaction outcomes for manual reconciliation rather than risking duplicate deposits.

Implemented:

  • Virtual shards only: persistent UUID balances, deposits, validated withdrawals, and no inventory payouts or counting.

  • Economy opt-in: shard.backend: INTERNAL by default; VAULT uses a registered compatible economy provider through Vault or VaultUnlocked.

  • Safe queuing: unavailable providers leave rewards pending. Uncertain external transactions require manual reconciliation instead of automatic retry.

  • Legacy migration: old pending amounts convert once with a backup and durable marker. Physical shard items remain untouched and no longer count.

  • Shared commands: /afk and /spawn menus; public help; OP-only delete <name> and complete reload; /setafk <name> and /setspawn <name>. Tab completion respects OP status.

  • Updated language defaults and bundled guide, preserving customized messages.

Integration caveat: Vault alone does not store money. Install a compatible economy provider, set shard.backend: VAULT, then run either reload command. This uses the provider’s normal currency; backend switching does not migrate balances automatically.

No builds or tests were run.

satansgoat96

make 2 more commands named /shards eco give <amount> /shards eco take <amount> then add formats for shortened number like 1000 make that 1k or 10000 is 10 k formate will presist of k - thousands m - millions b - billions t - trillions formats accept up to 999,999,999,999 trillion so if i want to give myself or other shards i just run the commands /shards eco give %player% <amount> and the player chosen receives that amount of shards

Kodari AI
KodariNov 8 at 4:24 pm 12
  1. Add OP-only /shards eco give|take <player> <amount>, with self-targeting when the player is omitted.

  2. Add compact k, m, b, and t balance formatting and update command help.

Added OP-only commands:

  • /shards eco give <player> <amount>

  • /shards eco take <player> <amount>

  • Omit <player> to target yourself.

Examples:

Plain Text
/shards eco give Alex 10k
/shards eco take Alex 500
/shards eco give 1m

Balances now display shortened numbers: 1k, 10k, 1m, 1b, 1t, up to 999,999,999,999 trillion. Amount inputs also accept these suffixes.

Commands use your selected INTERNAL or VAULT backend. Very large balances have double-precision limits, documented in the guide.

No builds or tests were run.

satansgoat96

please make sure command /shards eco give %player% <amount> take from an infinite pool and add back end offline player support so if player goes offline while command is executed player still gets <amount> when other player or consol runs /shards eco give %player% <amount>

Kodari AI
KodariNov 8 at 4:47 pm 2

give already creates shards without charging the sender. I’m updating queued economy delivery so it also retries for offline players, not just players currently online.

/shards eco give <player> <amount> creates shards from an infinite pool—nothing is deducted from the sender.

  • OPs and console can give to offline players using their known name or UUID.

  • INTERNAL balances are saved immediately, without requiring login.

  • VAULT credits go to the provider; unavailable or rejected deposits remain saved and now retry even while the recipient is offline.

  • If the recipient disconnects during the command, their UUID-based credit is retained.

Example: /shards eco give Alex 10k

Replace <player> with the actual player name; %player% only works if the system running the command substitutes it.

No builds or tests were run.

satansgoat96

remove this command as its a double and you need players name to complete command | /shards eco give <amount>, /shards eco take <amount> | OP players | Credit/withdraw your own shards |

Kodari AI
KodariNov 8 at 5:03 pm 2

Removed the self-targeting shortcuts. Both commands now require a player name or UUID:

  • /shards eco give <player> <amount>

  • /shards eco take <player> <amount>

Updated usage messages and documentation. Omitting the player now rejects the command.

satansgoat96

make the base command /shards so when i run the command /shards it displays the amount of %shards% that %player% has display of %shards text is shown middle of screen low but above the inventory bar so its seeable and doesnt overlap with inventory bar

Kodari AI
KodariNov 8 at 5:32 pm 2

/shards now shows your formatted balance in the action bar, centered above the hotbar:

PlayerName | 10k shards

  • Available to every player.

  • Editable through shards-balance in gui/lang/en.yml.

  • %shards% works as an alias for %shard%.

  • Economy give/take commands remain OP-only.

No builds or tests were run.

satansgoat96

can you add support and make this plugin use as little memory disk and cpu as possible while still having great performance and stability when running commands from multiple players

Kodari AI
KodariNov 8 at 5:47 pm 3

I found repeated destination-list allocations, duplicate balance lookups, and potentially large economy retry batches. I’ll reduce that background work while keeping immediate currency saves and reward safety intact.

Reduced background CPU work and temporary memory allocations:

  • Cached destination lists instead of rebuilding them for every area scan, menu, and placeholder. Changes invalidate the cache.

  • Removed duplicate balance lookups when text contains both shard placeholders.

  • Limited queued economy retries to 5 per pass, reducing disk-write spikes.

  • Removed unnecessary balance polling for every online player; command balance requests still query the selected backend.

Kept immediate currency persistence, offline rewards, OP restrictions, and transaction safeguards intact. No durability was traded for speed.

No builds, tests, or performance benchmarks were run, so actual resource usage under load remains unverified.

satansgoat96

add | '/shards' discription to GUIDE.dm under command access action

Kodari AI
KodariNov 8 at 5:51 pm 1

Added /shards to the Command / Access / Action table in src/main/resources/GUIDE.md: available to all players and displays their formatted shard balance above the hotbar.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
20 1,832
src/main/java/com/kodari/afkspawn/AFKSpawnPlugin.java
package com.kodari.afkspawn;

import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

public final class AFKSpawnPlugin extends JavaPlugin {
    Settings settings;
    DestinationStore store;
    Text text;
    Hooks hooks;
    ShardService shards;
    RewardManager rewards;
    TeleportManager teleports;
    Menus menus;
    long epoch;
    private BukkitTask pulse;

    @Override
    public void onEnable() {
        settings = new Settings(this);
        store = new DestinationStore(this);
        text = new Text(this);
        hooks = new Hooks(this);
        shards = new ShardService(this);
        rewards = new RewardManager(this);
        teleports = new TeleportManager(this);
        menus = new Menus(this);
        try {
            settings.load();
            shards.load();
            store.load();
            hooks.load();
        } catch (Exception ex) {
            getLogger().log(java.util.logging.Level.SEVERE, "AFK + Spawn 2-1 could not load safely; plugin disabled. Correct the YAML/data and restart.", ex);
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }
        for (String command : List.of("afk", "spawn", "setafk", "setspawn", "shards")) {
            Objects.requireNonNull(getCommand(command)).setExecutor(this);
            Objects.requireNonNull(getCommand(command)).setTabCompleter(this);
        }
        Bukkit.getPluginManager().registerEvents(menus, this);
        Bukkit.getPluginManager().registerEvents(new PlayerEvents(this), this);
        startPulse();
        getLogger().info("AFK + Spawn 2-1 enabled. No automatic inactivity detection and no teleport cooldowns.");
    }

    private void startPulse() {
        pulse = Bukkit.getScheduler().runTaskTimer(this, () -> {
            teleports.tick();
            rewards.tick();
            if (++currencyTicks % 30 == 0) shards.retry();
        }, 20L, 20L);
    }

    @Override
    public void onDisable() {
        epoch++;
        if (pulse != null) pulse.cancel();
        if (menus != null) menus.closeAll();
        if (teleports != null) teleports.clear();
        if (rewards != null) rewards.resetAll();
        if (hooks != null) hooks.close();
        Bukkit.getScheduler().cancelTasks(this);
    }

    public ShardService getShardService() { return shards; }

    private int currencyTicks;

    private void message(CommandSender sender, String key, String type) {
        sender.sendMessage(text.format(sender instanceof Player player ? player : null,
                settings.lang.getString("prefix", "") + settings.lang.getString(key, ""), Map.of("type", type)));
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        String cmd = command.getName().toLowerCase(Locale.ROOT);
        if (cmd.equals("shards")) return shardCommand(sender, args);
        String type = cmd.endsWith("afk") ? "afk" : "spawn";
        boolean set = cmd.startsWith("set");
        Player player = sender instanceof Player online ? online : null;
        if (!set && args.length == 0) {
            if (player == null) message(sender, "player-only", type); else menus.open(player, type, 0);
            return true;
        }
        if (!set && args.length == 1 && args[0].equalsIgnoreCase("help")) {
            message(sender, "help-public", type);
            if (sender.isOp()) message(sender, "help-admin", type);
            return true;
        }
        boolean reload = !set && args.length == 1 && args[0].equalsIgnoreCase("reload");
        boolean delete = !set && args.length == 2 && args[0].equalsIgnoreCase("delete");
        if (!(reload || delete || (set && args.length == 1))) {
            message(sender, set ? "usage-set" : "usage-public", type); return true;
        }
        if (!sender.isOp()) { message(sender, "op-only", type); return true; }
        try {
            if (set) {
                if (player == null) { message(sender, "player-only", type); return true; }
                String name = args[0].toLowerCase(Locale.ROOT);
                if (!DestinationStore.valid(name)) { text.send(player, "invalid-name"); return true; }
                store.save(type, name, player);
                teleports.invalidate();
                rewards.resetAll();
                menus.refresh();
                text.send(player, "saved", Map.of("destination", name));
                return true;
            }
            if (delete) {
                String name = args[1].toLowerCase(Locale.ROOT);
                Destination d = store.get(type, name);
                if (d == null) { message(sender, "missing", type); return true; }
                if (store.delete(d)) {
                    sender.sendMessage(text.format(player, settings.lang.getString("deleted", ""), Map.of("destination", name)));
                    if (player != null) text.sound(player, "delete", d, "confirmation");
                    menus.refresh();
                }
                return true;
            }
            if (reload) {
                epoch++;
                Bukkit.getScheduler().cancelTasks(this);
                menus.closeAll();
                teleports.clear();
                rewards.resetAll();
                hooks.close();
                try {
                    settings.load();
                    shards.load();
                    store.load();
                    hooks.load();
                    currencyTicks = 0;
                    startPulse();
                    message(sender, "reloaded", type);
                } catch (Exception ex) {
                    message(sender, "io-error", type);
                    getLogger().log(java.util.logging.Level.SEVERE, "Reload failed", ex);
                    getLogger().severe("Reload failed; disabling plugin to avoid operating on partially loaded settings.");
                    Bukkit.getPluginManager().disablePlugin(this);
                }
                return true;
            }
        } catch (Exception ex) {
            message(sender, "io-error", type);
            getLogger().log(java.util.logging.Level.SEVERE, "Data operation failed", ex);
            return true;
        }
        message(sender, "usage-public", type);
        return true;
    }

    private void shardMessage(CommandSender sender, String key, Map<String, String> values) {
        sender.sendMessage(text.format(sender instanceof Player player ? player : null,
                settings.lang.getString("prefix", "") + settings.lang.getString(key, ""), values));
    }

    private boolean shardCommand(CommandSender sender, String[] args) {
        if (args.length == 0) {
            if (!(sender instanceof Player player)) {
                message(sender, "player-only", "shards");
                return true;
            }
            String balance = ShardService.format(shards.balance(player));
            String display = text.format(player, settings.lang.getString("shards-balance", "&d%player% &8| &f%shards% &dshards"),
                    Map.of("shards", balance));
            player.spigot().sendMessage(net.md_5.bungee.api.ChatMessageType.ACTION_BAR,
                    net.md_5.bungee.api.chat.TextComponent.fromLegacyText(display));
            return true;
        }
        if (!sender.isOp()) { message(sender, "op-only", "shards"); return true; }
        if (args.length != 4 || !args[0].equalsIgnoreCase("eco")
                || (!args[1].equalsIgnoreCase("give") && !args[1].equalsIgnoreCase("take"))) {
            shardMessage(sender, "shards-usage", Map.of()); return true;
        }
        org.bukkit.OfflinePlayer target;
        {
            target = Bukkit.getPlayerExact(args[2]);
            if (target == null) {
                try { target = Bukkit.getOfflinePlayer(java.util.UUID.fromString(args[2])); }
                catch (IllegalArgumentException ex) {
                    target = java.util.Arrays.stream(Bukkit.getOfflinePlayers())
                            .filter(p -> p.getName() != null && p.getName().equalsIgnoreCase(args[2])).findFirst().orElse(null);
                }
            }
            if (target == null) {
                shardMessage(sender, "shards-player-missing", Map.of()); return true;
            }
        }
        double amount;
        try { amount = ShardService.parseAmount(args[args.length - 1]); }
        catch (IllegalArgumentException ex) { shardMessage(sender, "shards-invalid-amount", Map.of()); return true; }