|
| 1 | +--- |
| 2 | +name: minecraft-plugin-development |
| 3 | +description: 'Use this skill when building or modifying Minecraft server plugins for Paper, Spigot, or Bukkit, including plugin.yml setup, commands, listeners, schedulers, player state, team or arena systems, configuration files, Adventure text, and version-safe API usage. Trigger for requests like "build a Minecraft plugin", "add a Paper command", "fix a Bukkit listener", "create plugin.yml", "implement a minigame mechanic", or "debug server plugin behavior".' |
| 4 | +--- |
| 5 | + |
| 6 | +# Minecraft Plugin Development |
| 7 | + |
| 8 | +Use this skill for Minecraft server plugin work in the Paper, Spigot, and Bukkit ecosystem. |
| 9 | + |
| 10 | +This skill is especially useful for gameplay-heavy plugins such as combat systems, wave or boss encounters, war or team modes, arenas, kit systems, cooldown-based abilities, scoreboards, and config-driven game rules. |
| 11 | + |
| 12 | +For grounded implementation patterns drawn from real Paper plugins, load these references as needed: |
| 13 | + |
| 14 | +- [`references/project-patterns.md`](references/project-patterns.md) for high-level architecture patterns seen in real gameplay plugins |
| 15 | +- [`references/bootstrap-registration.md`](references/bootstrap-registration.md) for `onEnable`, command wiring, listener registration, and shutdown expectations |
| 16 | +- [`references/state-sessions-and-phases.md`](references/state-sessions-and-phases.md) for player session modeling, game phases, match state, and reconnect-safe logic |
| 17 | +- [`references/config-data-and-async.md`](references/config-data-and-async.md) for config managers, database-backed player data, async flushes, and UI refresh tasks |
| 18 | +- [`references/maps-heroes-and-feature-modules.md`](references/maps-heroes-and-feature-modules.md) for map rotation, hero or class systems, and modular feature growth |
| 19 | + |
| 20 | +## Scope |
| 21 | + |
| 22 | +- In scope: Paper, Spigot, Bukkit plugin development |
| 23 | +- In scope: `plugin.yml`, commands, tab completion, listeners, schedulers, configs, permissions, Adventure text, player state, minigame flow |
| 24 | +- In scope: Java-based server plugin architecture, debugging, refactoring, and feature implementation |
| 25 | +- Out of scope by default: Fabric mods, Forge mods, client mods, Bedrock add-ons |
| 26 | + |
| 27 | +If the user says "Minecraft plugin" but the stack is unclear, first determine whether the project is Paper/Spigot/Bukkit or a modding stack. |
| 28 | + |
| 29 | +## Default Working Style |
| 30 | + |
| 31 | +When this skill triggers: |
| 32 | + |
| 33 | +1. Identify the server API and version target. |
| 34 | +2. Identify the build system and Java version. |
| 35 | +3. Inspect `plugin.yml`, the main plugin class, and command or listener registration. |
| 36 | +4. Map the gameplay flow before editing code: |
| 37 | + - player lifecycle |
| 38 | + - game phases |
| 39 | + - timers and scheduled tasks |
| 40 | + - team, arena, or match state |
| 41 | + - config and persistence |
| 42 | +5. Make the smallest coherent change that keeps registration, config, and runtime behavior aligned. |
| 43 | + |
| 44 | +If the plugin is gameplay-heavy or stateful, read [`references/project-patterns.md`](references/project-patterns.md) and [`references/state-sessions-and-phases.md`](references/state-sessions-and-phases.md) before editing. |
| 45 | + |
| 46 | +## Project Discovery Checklist |
| 47 | + |
| 48 | +Check these first when present: |
| 49 | + |
| 50 | +- `plugin.yml` |
| 51 | +- `pom.xml`, `build.gradle`, or `build.gradle.kts` |
| 52 | +- the plugin main class extending `JavaPlugin` |
| 53 | +- command executors and tab completers |
| 54 | +- listener classes |
| 55 | +- config bootstrap code for `config.yml`, messages, kits, arenas, or custom YAML files |
| 56 | +- scheduler usage through Bukkit scheduler APIs |
| 57 | +- any player data, team state, arena state, or match state containers |
| 58 | + |
| 59 | +## Core Rules |
| 60 | + |
| 61 | +### Prefer the concrete server API in the repo |
| 62 | + |
| 63 | +- If the project already targets Paper APIs, keep using Paper-first APIs instead of downgrading to generic Bukkit unless compatibility is explicitly required. |
| 64 | +- Do not assume an API exists across all versions. Check the existing dependency and surrounding code style first. |
| 65 | + |
| 66 | +### Keep registration in sync |
| 67 | + |
| 68 | +When adding commands, permissions, or listeners, update the relevant registration points in the same change: |
| 69 | + |
| 70 | +- `plugin.yml` |
| 71 | +- plugin startup registration in `onEnable` |
| 72 | +- any permission checks in code |
| 73 | +- any related config or message keys |
| 74 | + |
| 75 | +### Respect main-thread boundaries |
| 76 | + |
| 77 | +- Do not touch world state, entities, inventories, scoreboards, or most Bukkit API objects from async tasks unless the API explicitly permits it. |
| 78 | +- Use async tasks for external I/O, heavy computation, or database work, then switch back to the main thread before applying gameplay changes. |
| 79 | + |
| 80 | +### Model gameplay as state, not scattered booleans |
| 81 | + |
| 82 | +For gameplay plugins, prefer explicit state objects over duplicated flags: |
| 83 | + |
| 84 | +- match or game phase |
| 85 | +- player role or class |
| 86 | +- cooldown state |
| 87 | +- team membership |
| 88 | +- arena assignment |
| 89 | +- alive, eliminated, spectating, or queued state |
| 90 | + |
| 91 | +When the feature affects NightMare-style or War-style gameplay, look for hidden state transitions first before patching symptoms. |
| 92 | + |
| 93 | +### Favor config-driven values |
| 94 | + |
| 95 | +When the feature includes damage, cooldowns, rewards, durations, messages, map settings, or toggles: |
| 96 | + |
| 97 | +- prefer config-backed values over hardcoding |
| 98 | +- provide sensible defaults |
| 99 | +- keep key names stable and readable |
| 100 | +- validate or sanitize missing values |
| 101 | + |
| 102 | +### Be careful with reload behavior |
| 103 | + |
| 104 | +- Avoid promising safe hot reload unless the code already supports it well. |
| 105 | +- On config reload, ensure in-memory caches, scheduled tasks, and gameplay state are handled consistently. |
| 106 | + |
| 107 | +## Implementation Patterns |
| 108 | + |
| 109 | +### Commands |
| 110 | + |
| 111 | +For new commands: |
| 112 | + |
| 113 | +- add the command to `plugin.yml` |
| 114 | +- implement executor and tab completion when needed |
| 115 | +- validate sender type before casting to `Player` |
| 116 | +- separate parsing, permission checks, and gameplay logic |
| 117 | +- send clear player-facing feedback for invalid usage |
| 118 | + |
| 119 | +### Listeners |
| 120 | + |
| 121 | +For event listeners: |
| 122 | + |
| 123 | +- guard early and return early |
| 124 | +- check whether the current player, arena, or game phase should handle the event |
| 125 | +- avoid doing expensive work in hot events such as move, damage, or interact spam |
| 126 | +- centralize repeated checks where practical |
| 127 | + |
| 128 | +### Scheduled Tasks |
| 129 | + |
| 130 | +For timers, rounds, countdowns, cooldowns, or periodic checks: |
| 131 | + |
| 132 | +- store task handles when cancellation matters |
| 133 | +- cancel tasks on plugin disable and when a match or arena ends |
| 134 | +- avoid multiple overlapping tasks for the same gameplay concern unless explicitly intended |
| 135 | +- prefer one authoritative game loop over many loosely coordinated repeating tasks |
| 136 | + |
| 137 | +### Player and Match State |
| 138 | + |
| 139 | +For per-player or per-match state: |
| 140 | + |
| 141 | +- define ownership clearly |
| 142 | +- clean up on quit, kick, death, match end, and plugin disable |
| 143 | +- avoid memory leaks from stale maps keyed by `Player` |
| 144 | +- prefer `UUID` for persistent tracking unless a live player object is strictly needed |
| 145 | + |
| 146 | +### Text and Messages |
| 147 | + |
| 148 | +When the project uses Adventure or MiniMessage: |
| 149 | + |
| 150 | +- follow the existing formatting approach |
| 151 | +- avoid mixing legacy color codes and Adventure styles without a reason |
| 152 | +- keep message templates configurable when messages are gameplay-facing |
| 153 | + |
| 154 | +## High-Risk Areas |
| 155 | + |
| 156 | +Pay extra attention when editing: |
| 157 | + |
| 158 | +- damage handling and custom combat logic |
| 159 | +- death, respawn, spectator, and elimination flow |
| 160 | +- arena join and leave flow |
| 161 | +- scoreboard or boss bar updates |
| 162 | +- inventory mutation and kit distribution |
| 163 | +- async database or file access |
| 164 | +- version-sensitive API calls |
| 165 | +- shutdown and cleanup in `onDisable` |
| 166 | + |
| 167 | +## Output Expectations |
| 168 | + |
| 169 | +When implementing or revising plugin code: |
| 170 | + |
| 171 | +- produce runnable Java code, not pseudo-code, unless the user asks for design only |
| 172 | +- mention any required updates to `plugin.yml`, config files, build files, or resources |
| 173 | +- call out version assumptions explicitly |
| 174 | +- point out thread-safety or API-compatibility risks when they exist |
| 175 | +- preserve the project's existing conventions and folder structure |
| 176 | + |
| 177 | +When the requested change touches plugin startup, async data, match flow, class systems, or rotating maps, consult the matching reference file before editing. |
| 178 | + |
| 179 | +## Validation Checklist |
| 180 | + |
| 181 | +Before finishing, verify as many of these as the task allows: |
| 182 | + |
| 183 | +- the command, listener, or feature is registered correctly |
| 184 | +- `plugin.yml` matches the implemented behavior |
| 185 | +- imports and API types match the targeted server stack |
| 186 | +- scheduler usage is safe |
| 187 | +- config keys referenced in code exist or have defaults |
| 188 | +- state cleanup paths exist for match end, player quit, and plugin disable |
| 189 | +- there are no obvious null, cast, or lifecycle hazards |
| 190 | + |
| 191 | +## Common Gotchas |
| 192 | + |
| 193 | +- Casting `CommandSender` to `Player` without checking |
| 194 | +- Updating Bukkit state from async tasks |
| 195 | +- Forgetting to register listeners or declare commands in `plugin.yml` |
| 196 | +- Using `Player` objects as long-lived map keys when `UUID` is safer |
| 197 | +- Leaving repeating tasks alive after a round, arena, or plugin shutdown |
| 198 | +- Hardcoding gameplay constants that should live in config |
| 199 | +- Assuming Paper-only APIs in a Spigot-targeted plugin |
| 200 | +- Treating reload as free even though stateful plugins often break under reload |
| 201 | + |
| 202 | +## Preferred Response Shape |
| 203 | + |
| 204 | +For substantial requests, structure work like this: |
| 205 | + |
| 206 | +1. Current plugin context and assumptions |
| 207 | +2. Gameplay or lifecycle impact |
| 208 | +3. Code changes |
| 209 | +4. Required registration or config updates |
| 210 | +5. Validation and remaining risks |
| 211 | + |
| 212 | +For small requests, keep the answer concise but still mention any needed `plugin.yml`, config, or lifecycle updates. |
0 commit comments