Role: Act as an expert Java 21 plugin developer for the PaperMC/Spigot API.
Task: Write a highly optimized, production-ready Java plugin implementing a custom "Card SMP" ability system. Ensure the code is modular, fully commented, and registers all commands, subcommands, and event listeners properly in the main class.
Core Architecture Constraints: * Item Security: Every custom item must be secured using a PersistentDataContainer (PDC) with a custom NamespacedKey (e.g., card_type). Do NOT rely on display names or lore to identify items. * Texture Pack Integration: Every item must have a unique CustomModelData integer assigned via ItemMeta#setCustomModelData() so it can be linked to a custom resource pack. * Targeting & UI: Ensure all cooldown notifications are sent via player.sendActionBar(). Every Area of Effect (AoE) ability must explicitly filter out the caster (if (target != caster)).
CRITICAL BUG FIX (Apply to all cards): All BukkitRunnables must include an internal tick counter. When the specified duration ends, you must explicitly call this.cancel() and fully revert all applied states (e.g., restore walkSpeed to 0.2f, flySpeed to 0.1f, and remove NoAI NBT tags). Do not leave permanent stat changes or infinite loops.
Command Framework (/cardsmp):
Implement a command executor with the following subcommands:
- /cardsmp start: Initializes the server's tracking systems and enables card usage globally.
- /cardsmp INVENTORY GUI: Opens a Bukkit Inventory INVENTORY GUI (27 slots) displaying all 6 cards. Clicking a card in the INVENTORY GUI gives it to the player and closes the menu.
- /cardsmp give <player> <card>: Admin command to bypass the INVENTORY GUI and give a specific card directly to a target's inventory.
- /cardsmp reset: Instantly clears all active card cooldowns globally and terminates any active tracking entities or BukkitRunnables.
- /cardsmp reroll: Takes the custom card currently held in the player's main hand, removes it, and gives them a random different card from the remaining 5 options.
Mechanics & Item Mapping (Must include PDC and CustomModelData):
- Time Card (Item: Light Blue Dye | ModelData: 1):
* Cooldown: 60 seconds. * Effect: Freeze all entities within a 50-block radius (excluding caster) for 15 seconds. Set target walk/fly speeds to 0 and apply the NoAI NBT tag to mobs. Revert to default speeds and remove NoAI after exactly 15 seconds via runnable cancellation.
- Gravity Card (Item: Black Dye | ModelData: 2):
* Cooldown: 45 seconds. * Effect: Creates a miniature black hole. Continuously pulls all entities and items within an 8-block radius (excluding caster) toward the center for 5 seconds using vector math. Ends with a force-2, terrain-safe explosion (createExplosion with block damage disabled). Simulate using PORTAL, SQUID_INK, and END_ROD particles via World#spawnParticle (strictly capped at 1 spawn per 5 ticks). Cancel runnable at 5 seconds.
- Glitch Card (Item: Gray Dye | ModelData: 3):
* Cooldown: 45 seconds. * Effect: Forces all players within a 15-block radius (excluding caster) to drop their held main-hand item once per second for 30 seconds. Cancel runnable at 30 seconds.
- Thunder Card (Item: Yellow Dye | ModelData: 4):
* Cooldown: 30 seconds. * Effect: Spams lightning strikes at all entities within a 10-block radius (excluding caster). Use a BukkitRunnable to execute the World#strikeLightning method exactly 1 time per tick (20 times per second) for 10 seconds. Cancel runnable at 10 seconds.
- Soul Card (Item: White Dye | ModelData: 5):
* Cooldown: 40 seconds. * Effect: Grants the caster 10 seconds of absolute damage immunity via the EntityDamageEvent. Track and accumulate all canceled damage values in a HashMap. When the 10-second BukkitRunnable ends, cancel immunity and instantly apply 100% of the accumulated damage directly to the caster via player.damage().
- Demon Card (Item: Red Dye | ModelData: 6):
* Passive Trigonometric Tracking: Run a background BukkitRunnable using PlayerItemHeldEvent. You MUST create an explicit ItemStack array containing the 5 other specific cards to ensure they are visually distinct in the orbit:
Index 0: Light Blue Dye (ModelData: 1) Index 1: Black Dye (ModelData: 2) Index 2: Gray Dye (ModelData: 3) Index 3: Yellow Dye (ModelData: 4) Index 4: White Dye (ModelData: 5) When spawning the 5 ItemDisplay entities, assign setItem(array[i]) so all 5 orbiting cards are strictly their correct colors. Orbit them in a continuous, equally spaced circle around the player's chest height (Y + 1.2) using parametric equations: x = x_0 + r cos(theta) and z = z_0 + r sin(theta) where theta = base_angle + (i 2 * PI / 5). Update base_angle every tick. remove() all entities immediately when the item is unequipped or hotbar slot changes. * Active Execution: 60-second cooldown. On Right Click, randomly select one of the five orbiting cards and execute its respective ability method instantly as if the player cast it. Caster must remain immune to any resulting AoE effects. * Cinematic Effect: Upon active trigger, spawn a dense vertical beam of END_ROD particles shooting straight up from the caster. Concurrently, trigger a "Visual Earthquake" by rapidly playing the MINECART_RIDING sound and spawning BLOCK_CRACK particles of stone/dirt at the caster's feet to simulate terrain destruction without causing actual block modifications.