Create a professional Minecraft Paper/Spigot addon plugin called:
StrikePracticeQueuePlaceholders
The addon is designed specifically for StrikePractice and must integrate directly with the installed StrikePractice API/dev build.
The purpose of this addon is simple:
Add accurate, live PlaceholderAPI placeholders for StrikePractice's UNRANKED and RANKED 1v1 queues, showing both players currently waiting in queue and players currently fighting through that queue
๐
STRIKEPRACTICE QUEUE PLACEHOLDER ADDON.md
md
2439 lines
โถ
# STRIKEPRACTICE QUEUE PLACEHOLDER ADDON
## MASTER AI DEVELOPMENT PROMPT
### Production-Grade Unranked + Ranked Queue/Fight Counter Integration for StrikePractice
---
## 1. PROJECT OVERVIEW
Create a professional Minecraft Paper/Spigot addon plugin called:
**StrikePracticeQueuePlaceholders**
The addon is designed specifically for **StrikePractice** and must integrate directly with the installed StrikePractice API/dev build.
The purpose of this addon is simple:
> Add accurate, live PlaceholderAPI placeholders for StrikePractice's UNRANKED and RANKED 1v1 queues, showing both players currently waiting in queue and players currently fighting through that queue.
The addon MUST NOT create a second queue system.
The addon MUST NOT maintain an independent matchmaking system.
The addon MUST NOT duplicate StrikePractice's queue logic.
StrikePractice is the authoritative source of truth.
The addon reads and derives its counters from StrikePractice's real queue/fight state.
---
# 2. PRIMARY PLACEHOLDERS
Register exactly these four primary PlaceholderAPI placeholders:
### UNRANKED
```text
%unranked_inqueue_%
%unranked_infight_%
```
### RANKED
```text
%ranked_inqueue_%
%ranked_infight_%
```
Example:
```text
%unranked_inqueue_Sumo%
%unranked_infight_Sumo%
%ranked_inqueue_Sumo%
%ranked_infight_Sumo%
```
Also support kit names containing:
- spaces
- hyphens
- underscores
- uppercase letters
- lowercase letters
- numbers
- special characters where PlaceholderAPI safely allows them
Kit matching should be case-insensitive where appropriate, but returned/displayed kit identity must correspond to the actual StrikePractice BattleKit.
---
# 3. ABSOLUTE SOURCE-OF-TRUTH RULE
This is the most important requirement.
DO NOT create:
```text
HashMap
```
as a second permanent queue system.
DO NOT create:
```text
HashMap queueCounts
```
and blindly increment/decrement it.
DO NOT trust only Bukkit join events.
DO NOT assume:
```text
player joined queue = +1 forever
player left queue = -1 forever
```
because StrikePractice may:
- match players
- cancel queues
- disconnect players
- move players into fights
- remove invalid queue entries
- alter queues internally
- use ranked/unranked separately
- change queue state without the addon receiving a custom event
Instead:
**derive the current state from StrikePractice itself.**
The addon may maintain lightweight caches for performance, but those caches must be rebuildable from StrikePractice and must NEVER become the authoritative state.
---
# 4. STRIKEPRACTICE INTEGRATION
Use the StrikePractice API provided by the user.
The known API package is:
```java
ga.strikepractice.api.StrikePracticeAPI
```
Relevant API methods include:
```java
getUnrankedQueue()
getRankedQueue()
getQueuedKit(Player)
isInQueue(Player)
getFight(Player)
isInFight(Player)
getKit(Player)
getDuelOpponent(Player)
getStrikePractice()
```
The API also exposes:
```java
ga.strikepractice.fights.queue.DuelQueueRunnable
```
and:
```java
DuelQueueRunnable.getRanked(Player)
```
Use the actual API rather than reflection whenever possible.
---
# 5. STRIKEPRACTICE DEPENDENCY
StrikePractice is the MAIN dependency.
The addon must refuse to operate incorrectly if StrikePractice is unavailable.
plugin.yml should declare the appropriate dependency relationship.
PlaceholderAPI is also required for placeholder registration.
Recommended dependency structure:
```yaml
depend:
- StrikePractice
- PlaceholderAPI
```
If the specific StrikePractice environment requires soft-dependency behavior, make this configurable, but the default behavior should expect StrikePractice to exist.
Do not bundle StrikePractice classes into the addon.
Do not relocate/repackage StrikePractice.
Do not ship a modified StrikePractice.
Do not shadow StrikePractice classes.
Compile against the provided StrikePractice API.
---
# 6. UNRANKED QUEUE COUNTER
Placeholder:
```text
%unranked_inqueue_%
```
Definition:
> Number of players currently waiting in StrikePractice's UNRANKED queue for the requested kit.
Example:
Sacrificed has joined:
```text
Unranked > NoDebuff
```
If 1 player is waiting:
```text
%unranked_inqueue_NoDebuff%
```
returns:
```text
1
```
If another player joins:
```text
2
```
If two players are matched:
```text
0
```
The counter must represent the CURRENT queue state, not historical joins.
---
# 7. UNRANKED MATCH TRANSITION
This behavior is critical.
Suppose:
```text
Player A -> NoDebuff Unranked Queue
Player B -> NoDebuff Unranked Queue
Player C -> NoDebuff Unranked Queue
```
Before matchmaking:
```text
unranked_inqueue_NoDebuff = 3
```
StrikePractice matches:
```text
A vs B
```
and they enter a fight.
Player C remains queued.
The addon MUST report:
```text
unranked_inqueue_NoDebuff = 1
```
NOT:
```text
0
```
NOT:
```text
3
```
NOT:
```text
2
```
Only the players who actually transitioned from queue into the fight are removed from the queue count.
This must work automatically by reading the actual StrikePractice state.
---
# 8. UNRANKED IN-FIGHT COUNTER
Placeholder:
```text
%unranked_infight_%
```
Definition:
> Number of active players currently fighting in a StrikePractice UNRANKED fight using the requested kit.
StrikePractice's standard queue matchmaking is 1v1.
Therefore:
```text
1 active fight = 2 fighters
```
So if:
```text
Player A vs Player B
```
is actively fighting NoDebuff Unranked:
```text
%unranked_infight_NoDebuff%
```
returns:
```text
2
```
If there are two simultaneous fights:
```text
A vs B
C vs D
```
returns:
```text
4
```
If there are three simultaneous fights:
```text
6
```
The value represents **players**, not matches.
---
# 9. UNRANKED FIGHT DETECTION
Do NOT simply assume every player returned by:
```java
isInFight(player)
```
is an Unranked fighter.
A player may be:
- in a direct duel
- in a party fight
- in an event
- in another StrikePractice mode
- spectator
- bot-related
- otherwise associated with a fight
The addon must determine whether the fight originated from the StrikePractice **UNRANKED queue**.
The implementation must inspect the actual StrikePractice objects/state available through the API/dev build.
The logic must distinguish:
```text
UNRANKED
```
from:
```text
RANKED
```
and from unrelated fights.
Do not count direct `/duel` fights as queue fights.
Do not count Party Fights.
Do not count Party FFA.
Do not count events.
Do not count spectators.
Do not count bots unless they are genuinely represented as queue fighters by StrikePractice.
---
# 10. RANKED QUEUE COUNTER
Placeholder:
```text
%ranked_inqueue_%
```
Definition:
> Number of players currently waiting in StrikePractice's RANKED queue for the requested kit.
Example:
```text
Player A -> Ranked NoDebuff
Player B -> Ranked NoDebuff
Player C -> Ranked NoDebuff
```
returns:
```text
3
```
If StrikePractice matches:
```text
A vs B
```
while C remains queued:
```text
1
```
Again, never reset the whole counter when only two players are matched.
---
# 11. RANKED QUEUE DATA
StrikePractice's API exposes:
```java
Map> getRankedQueue()
```
Use this where appropriate.
Each ranked queue entry must be associated with its:
```text
Player
UUID
BattleKit
ELO/range state
queue validity
```
Use:
```java
DuelQueueRunnable#getPlayer()
DuelQueueRunnable#getUUID()
DuelQueueRunnable#getKit()
DuelQueueRunnable#isValidQueue()
```
where applicable.
Invalid queue entries must not be counted.
Offline/removed players must not remain counted.
---
# 12. RANKED IN-FIGHT COUNTER
Placeholder:
```text
%ranked_infight_%
```
Definition:
> Number of active players currently fighting in a StrikePractice RANKED queue match using the requested kit.
Example:
```text
A vs B
```
Ranked NoDebuff:
```text
2
```
Two simultaneous fights:
```text
4
```
Three simultaneous fights:
```text
6
```
Again:
**COUNT PLAYERS, NOT MATCHES.**
---
# 13. RANKED VS UNRANKED MUST NEVER MIX
This is an absolute requirement.
These counters are independent:
```text
UNRANKED
โโโ inqueue
โโโ infight
RANKED
โโโ inqueue
โโโ infight
```
Example:
```text
Unranked NoDebuff:
3 waiting
4 fighting
Ranked NoDebuff:
2 waiting
6 fighting
```
The results MUST be:
```text
%unranked_inqueue_NoDebuff% = 3
%unranked_infight_NoDebuff% = 4
%ranked_inqueue_NoDebuff% = 2
%ranked_infight_NoDebuff% = 6
```
Never return:
```text
5
10
```
by combining ranked and unranked.
---
# 14. DIRECT DUELS MUST NOT BE COUNTED
If:
```text
Player A /duel Player B
```
and they fight NoDebuff:
DO NOT count them as:
```text
unranked_infight
```
DO NOT count them as:
```text
ranked_infight
```
unless StrikePractice itself identifies that fight as originating from the corresponding queue.
The addon must follow StrikePractice's actual queue/fight classification.
---
# 15. QUEUE -> FIGHT MIGRATION
The addon must correctly understand the lifecycle:
```text
NOT QUEUED
โ
JOIN UNRANKED QUEUE
โ
IN UNRANKED QUEUE
โ
MATCH FOUND
โ
REMOVED FROM QUEUE
โ
FIGHT STARTS
โ
IN UNRANKED FIGHT
โ
FIGHT ENDS
โ
NO LONGER IN FIGHT
```
And independently:
```text
NOT QUEUED
โ
JOIN RANKED QUEUE
โ
IN RANKED QUEUE
โ
MATCH FOUND
โ
REMOVED FROM QUEUE
โ
RANKED FIGHT
โ
FIGHT ENDS
```
Counters must follow the actual current state.
---
# 16. NO DOUBLE COUNTING
A player must never simultaneously contribute to both:
```text
inqueue
```
and:
```text
infight
```
for the same queue mode.
If StrikePractice has already removed the player from its queue and placed them into a fight:
```text
inqueue -= 1
infight += 1
```
Conceptually.
However, implementation should preferably derive both values from current StrikePractice state rather than manually incrementing/decrementing.
---
# 17. EVERY SECOND REFRESH
Counters should remain live.
Recommended architecture:
```text
StrikePractice state
โ
Queue/Fight scanner
โ
Cache
โ
Placeholder request
```
Refresh/reconciliation approximately every:
```text
20 ticks
```
or:
```text
1 second
```
Make the interval configurable:
```yaml
update-interval-ticks: 20
```
Minimum safe value should prevent excessive scanning.
Do NOT run expensive operations every Minecraft tick unless explicitly configured.
---
# 18. PLACEHOLDER REQUEST BEHAVIOR
When PlaceholderAPI requests:
```text
%unranked_inqueue_NoDebuff%
```
the addon should:
1. Extract `NoDebuff`.
2. Resolve the corresponding StrikePractice `BattleKit`.
3. Determine the current UNRANKED queue count for that kit.
4. Return an integer string.
Example:
```java
"0"
"1"
"2"
"15"
```
Never return:
```text
null
```
for a valid registered placeholder.
---
# 19. UNKNOWN KIT
If:
```text
%unranked_inqueue_DoesNotExist%
```
is requested:
Return configurable fallback:
```yaml
placeholder:
unknown-kit: "0"
```
Default:
```text
0
```
Do not throw exceptions.
Do not spam console.
Do not create fake kits.
---
# 20. KIT RESOLUTION
Use StrikePractice's actual kit registry:
```java
StrikePracticeAPI#getKit(String)
```
or:
```java
StrikePracticeAPI#getKits()
```
where appropriate.
Never create an independent list that can become outdated.
If a new kit is added/reloaded in StrikePractice, the addon should automatically recognize it.
No addon restart should be required.
---
# 21. HOLOGRAM SUPPORT
The placeholders must work anywhere PlaceholderAPI works.
Therefore they must automatically work with hologram plugins that support PlaceholderAPI.
Examples include:
```text
Holograms
FancyHolograms
DecentHolograms
```
Do NOT hard-depend on hologram plugins.
The addon only provides PlaceholderAPI expansion support.
Example hologram:
```text
&6&lNO DEBUFF
&fWaiting: &e%unranked_inqueue_NoDebuff%
&fFighting: &c%unranked_infight_NoDebuff%
```
Should update automatically.
---
# 22. INVENTORY GUI SUPPORT
The placeholders must work inside:
- inventory item names
- item lore
- GUI menus
- DeluxeMenus
- chest GUIs
- scoreboard systems
- TAB
- holograms
- chat
- NPC-related displays
- any PlaceholderAPI-compatible plugin
Example:
```text
&6NoDebuff Queue
&7Waiting: &e%unranked_inqueue_NoDebuff%
&7Fighting: &c%unranked_infight_NoDebuff%
```
No GUI-specific implementation should be necessary.
PlaceholderAPI handles integration.
---
# 23. DELUXEMENUS COMPATIBILITY
Ensure placeholders can be used inside DeluxeMenus item:
```yaml
name: "&eNoDebuff"
lore:
- "&7Waiting: &f%unranked_inqueue_NoDebuff%"
- "&7Fighting: &f%unranked_infight_NoDebuff%"
```
The addon should not require DeluxeMenus.
---
# 24. TAB / SCOREBOARD COMPATIBILITY
The placeholders must be safe for repeated requests.
Avoid:
```text
new StrikePractice API lookup
new collection scan
new expensive calculation
```
on every individual placeholder call if unnecessary.
Cache/reconcile state once per update interval.
Placeholder requests should be extremely cheap.
---
# 25. THREAD SAFETY
Bukkit/Spigot/Paper objects must not be accessed unsafely from asynchronous threads.
Unless StrikePractice explicitly documents async-safe access:
**perform Bukkit/StrikePractice state inspection on the main server thread.**
Database is not required for this addon.
Do not introduce unnecessary database systems.
---
# 26. PERFORMANCE
The addon must be lightweight.
Target:
- minimal CPU usage
- zero unnecessary database access
- zero network requests
- zero blocking operations
- no per-player permanent timers
- no runaway scheduled tasks
- no memory leaks
The queue scanner should only inspect relevant StrikePractice state.
Do not scan thousands of unrelated Bukkit entities.
---
# 27. CACHE DESIGN
A cache is allowed only as a performance optimization.
Recommended structure:
```java
Map unrankedQueueCounts;
Map rankedQueueCounts;
Map unrankedFightCounts;
Map rankedFightCounts;
```
These maps must be completely rebuilt/reconciled from StrikePractice during each refresh.
Never do:
```java
count++;
count--;
```
as the only state-management mechanism.
Instead:
```text
clear temporary counts
scan StrikePractice
calculate actual current state
replace cache atomically
```
This makes the system self-healing.
---
# 28. SELF-HEALING
The system must survive:
- plugin reloads
- StrikePractice reloads where supported
- player disconnects
- server lag
- failed matches
- cancelled queues
- invalid queue entries
- fight ending
- player switching modes
- kit reloads
- unexpected exceptions
If internal cache becomes wrong:
The next reconciliation must correct it automatically.
---
# 29. RESTART BEHAVIOR
After server restart:
```text
Addon starts
โ
StrikePractice starts
โ
PlaceholderAPI starts
โ
Addon hooks StrikePractice
โ
Initial state scan
โ
Counters become available
```
Do not persist queue counts to disk.
Queue state is runtime state and should be reconstructed from StrikePractice.
---
# 30. STRIKEPRACTICE API INSTANCE
Obtain the API using the supported StrikePractice API mechanism from the supplied API/dev build.
Do NOT guess undocumented methods.
Inspect the supplied API JAR if necessary.
If the dev build contains an implementation-specific API accessor not exposed in the API JAR, isolate that implementation detail behind:
```java
StrikePracticeHook
```
so the rest of the addon remains clean.
---
# 31. ARCHITECTURE
Use clean modular architecture:
```text
StrikePracticeQueuePlaceholders
โ
โโโ StrikePracticeQueuePlaceholdersPlugin
โ
โโโ hook
โ โโโ StrikePracticeHook
โ โโโ StrikePracticeHookImpl
โ
โโโ queue
โ โโโ QueueSnapshot
โ โโโ QueueScanner
โ โโโ QueueMode
โ โโโ KitQueueState
โ
โโโ placeholder
โ โโโ QueuePlaceholderExpansion
โ
โโโ cache
โ โโโ QueueStateCache
โ
โโโ task
โ โโโ QueueRefreshTask
โ
โโโ config
โ โโโ PluginConfig
โ
โโโ util
โโโ KitNameResolver
```
Keep responsibilities separated.
---
# 32. QUEUE MODE ENUM
Create something similar to:
```java
public enum QueueMode {
UNRANKED,
RANKED
}
```
Do not use random booleans everywhere such as:
```java
boolean ranked
```
unless appropriate.
The architecture should remain readable.
---
# 33. QUEUE SNAPSHOT
Create an immutable snapshot representing:
```text
kit
mode
queueCount
fightCount
timestamp
```
Example conceptual object:
```java
QueueSnapshot {
String kitName;
QueueMode mode;
int inQueue;
int inFight;
}
```
Snapshots should be safely replaceable.
---
# 34. SCANNING UNRANKED
Use StrikePractice's actual:
```java
getUnrankedQueue()
```
data.
The API indicates:
```java
Map
```
is exposed for the unranked queue.
Do not blindly assume the String means a player count.
Inspect the supplied dev build implementation/API behavior before deciding exactly how it is represented.
If the String represents StrikePractice's queue count, parse/use it according to the real implementation.
If player-level queue entries can be obtained more reliably through another public API exposed by the dev build, use that.
The goal is:
**match StrikePractice's own queue state exactly.**
---
# 35. SCANNING RANKED
Use:
```java
getRankedQueue()
```
which exposes:
```java
Map>
```
Count only valid queue entries.
For every:
```java
DuelQueueRunnable
```
verify:
```java
isValidQueue()
```
and obtain the actual player/UUID.
Do not count invalid entries.
Do not count a player twice.
---
# 36. FIGHT SCANNING
For each relevant player/queue transition, determine:
```text
Is player actually fighting?
Which kit?
Ranked or Unranked?
Is this fight from queue matchmaking?
Is player an active fighter?
```
The API exposes:
```java
getFight(Player)
isInFight(Player)
getKit(Player)
```
and `Fight` exposes player/fighter-related information.
Use the strongest reliable public API path available.
Do not count spectators.
Do not count ended fights.
Do not count unrelated duel types.
---
# 37. DUPLICATE PROTECTION
Use UUID sets while scanning.
Example concept:
```java
Set countedPlayers = new HashSet<>();
```
This prevents:
```text
same player
same fight
multiple references
```
from being counted more than once.
For a fight:
```text
Player A
Player B
```
must produce:
```text
2
```
not:
```text
4
```
because both API references point to the same fight.
---
# 38. FIGHT CLASSIFICATION
The implementation must carefully determine whether a fight is:
```text
RANKED QUEUE
```
or:
```text
UNRANKED QUEUE
```
Possible sources may include StrikePractice's internal queue/fight metadata.
Do not infer ranked solely from:
```java
BattleKit#isElo()
```
unless inspection proves that this is exactly how StrikePractice distinguishes queued ranked fights.
Likewise, do not infer unranked solely from:
```text
!kit.isElo()
```
unless confirmed by the dev build.
The source of truth must be StrikePractice's actual queue/fight classification.
---
# 39. DO NOT MODIFY STRIKEPRACTICE
This addon must be completely external.
Never:
- patch StrikePractice
- modify its JAR
- inject bytecode unnecessarily
- replace its queue manager
- replace matchmaking
- cancel its tasks
- modify its internal queue collections
The addon is a consumer/integration layer.
---
# 40. OPTIONAL EVENT LISTENERS
If the dev build exposes suitable Bukkit/plugin events, the addon may listen to them for faster invalidation.
Examples:
```text
queue joined
queue left
fight started
fight ended
```
But event listeners are optional optimization.
The periodic reconciliation remains the final authority.
If an event is missed:
**the next scan must fix the state.**
---
# 41. NO GLITCHED COUNTERS
Specifically prevent these known classes of bugs:
### Bug 1
Player leaves queue but count remains.
### Bug 2
Two players match and entire queue becomes zero.
### Bug 3
Three players queue, two match, remaining player disappears.
### Bug 4
Ranked player counted as unranked.
### Bug 5
Unranked player counted as ranked.
### Bug 6
Direct duel counted as queue fight.
### Bug 7
Spectator counted as fighter.
### Bug 8
Player counted twice.
### Bug 9
Ended fight remains counted.
### Bug 10
Disconnected player remains in queue.
### Bug 11
Unknown kit causes exception.
### Bug 12
Placeholder randomly returns stale values.
### Bug 13
StrikePractice reload leaves broken API reference.
### Bug 14
Placeholder request causes console spam.
### Bug 15
Large server causes excessive CPU usage.
---
# 42. CONFIGURATION
Create:
```yaml
# config.yml
update-interval-ticks: 20
placeholder:
unknown-kit: "0"
error-value: "0"
debug:
enabled: false
logging:
startup: true
warnings: true
```
Everything reasonable should be configurable.
Do NOT make unnecessary configuration options that complicate the plugin.
---
# 43. COMMANDS
Create:
```text
/spqph reload
/spqph status
/spqph debug
```
Permission:
```text
strikepracticequeueplaceholders.admin
```
### reload
Reload configuration and refresh counters.
### status
Show:
```text
StrikePractice Hook: CONNECTED
PlaceholderAPI: CONNECTED
Kits: X
Unranked Queue Kits: X
Ranked Queue Kits: X
Tracked Fights: X
Update Interval: X ticks
```
### debug
Toggle/debug current snapshot information.
---
# 44. OPTIONAL ADMIN DEBUG
When debug is enabled, provide controlled logging such as:
```text
[SPQPH] Unranked NoDebuff queue=2 fight=4
[SPQPH] Ranked NoDebuff queue=1 fight=2
```
Do NOT print every player every second by default.
Debug logging must be rate-limited or only output when manually requested.
---
# 45. PLACEHOLDER EXPANSION
PlaceholderAPI expansion should use a clean identifier such as:
```text
spqueue
```
But the actual placeholders MUST remain exactly:
```text
%unranked_inqueue_%
%unranked_infight_%
%ranked_inqueue_%
%ranked_infight_%
```
Do not change them to:
```text
%spqueue_unranked_inqueue%
```
etc.
The four requested placeholders are the public API.
---
# 46. PLACEHOLDER VERSION
Expose a meaningful version through PlaceholderAPI if appropriate.
Example:
```text
getVersion() -> plugin version
```
The placeholder expansion should register/unregister cleanly during plugin lifecycle.
---
# 47. PLACEHOLDER THREAD SAFETY
Placeholder requests may come from plugins that call PlaceholderAPI asynchronously.
Therefore:
- Never perform unsafe Bukkit operations inside the placeholder request.
- Do not directly scan StrikePractice there.
- Read from the latest immutable/atomic cache.
- The scheduled main-thread scanner updates the cache.
This provides:
```text
safe placeholder calls
+
safe StrikePractice access
+
low CPU
```
---
# 48. ATOMIC CACHE REPLACEMENT
Build the entire new snapshot first.
Example conceptual flow:
```text
old snapshot
โ
scan StrikePractice
โ
new snapshot
โ
atomic replacement
```
Do not mutate the live cache halfway through a scan.
This prevents placeholders from seeing:
```text
queue=3
fight=0
```
halfway through calculation and then:
```text
queue=1
fight=4
```
during the same refresh.
---
# 49. ZERO COUNTER GUARANTEE
Every valid kit/mode combination should naturally resolve to:
```text
0
```
when nobody is waiting/fighting.
Example:
```text
%unranked_inqueue_Sumo% = 0
%unranked_infight_Sumo% = 0
%ranked_inqueue_Sumo% = 0
%ranked_infight_Sumo% = 0
```
No blank output.
No `null`.
No exception.
---
# 50. INTEGER GUARANTEE
The four placeholders return plain integer-compatible strings.
Examples:
```text
0
1
2
10
100
```
Do not include:
```text
players
queued:
%
```
unless a future separate formatted placeholder is added.
---
# 51. TEST SCENARIOS
The AI MUST create tests or at minimum a deterministic test plan for all cases.
### Test A
Nobody queued.
Expected:
```text
queue = 0
fight = 0
```
### Test B
One unranked player queued.
Expected:
```text
unranked queue = 1
unranked fight = 0
```
### Test C
Two unranked players queued.
Expected:
```text
queue = 2
fight = 0
```
### Test D
Two become matched.
Expected:
```text
queue = 0
fight = 2
```
### Test E
Three queue.
Two match.
Expected:
```text
queue = 1
fight = 2
```
### Test F
Four queue.
Two separate matches start.
Expected:
```text
queue = 0
fight = 4
```
### Test G
Ranked and unranked simultaneously.
Expected independent values.
### Test H
Direct duel.
Expected:
```text
queue = 0
```
and no queue-derived fight count.
### Test I
Fight ends.
Expected fight count decreases automatically.
### Test J
Player disconnects while queued.
Expected queue decreases.
### Test K
Invalid ranked queue object.
Expected it is ignored.
### Test L
Unknown kit placeholder.
Expected:
```text
0
```
### Test M
Kit name with spaces.
Expected correct resolution.
### Test N
Multiple kits simultaneously.
Expected completely independent counters.
---
# 52. EXAMPLE REAL SERVER STATE
Suppose StrikePractice currently has:
```text
UNRANKED
NoDebuff:
Waiting: A, B, C
Fighting: D vs E
Sumo:
Waiting: F
Fighting: G vs H
```
The placeholders should return:
```text
%unranked_inqueue_NoDebuff% = 3
%unranked_infight_NoDebuff% = 2
%unranked_inqueue_Sumo% = 1
%unranked_infight_Sumo% = 2
```
Now A and B match.
State becomes:
```text
NoDebuff:
Waiting: C
Fighting: D vs E
Fighting: A vs B
```
Expected:
```text
%unranked_inqueue_NoDebuff% = 1
%unranked_infight_NoDebuff% = 4
```
Not:
```text
0 / 4
```
and not:
```text
1 / 2
```
---
# 53. RANKED EXAMPLE
Suppose:
```text
Ranked NoDebuff:
Waiting: A, B, C
Fighting: D vs E
```
Expected:
```text
%ranked_inqueue_NoDebuff% = 3
%ranked_infight_NoDebuff% = 2
```
A and B match:
```text
Waiting: C
Fighting: D vs E
Fighting: A vs B
```
Expected:
```text
%ranked_inqueue_NoDebuff% = 1
%ranked_infight_NoDebuff% = 4
```
---
# 54. IMPORTANT INTERPRETATION
The words:
```text
inqueue
```
mean:
**players currently waiting for matchmaking.**
The words:
```text
infight
```
mean:
**players currently participating in an active fight created by that queue.**
They do NOT mean:
```text
number of matches
```
They do NOT mean:
```text
number of queue objects
```
They do NOT mean:
```text
number of spectators
```
They mean:
**actual player count.**
---
# 55. MATCH COUNT VS PLAYER COUNT
If there is:
```text
1 match
```
then:
```text
infight = 2
```
If there are:
```text
5 matches
```
then:
```text
infight = 10
```
because StrikePractice queue matchmaking is 1v1.
However, do not hardcode `matches * 2` as the only implementation.
Count actual active fighters when possible.
This protects the addon if StrikePractice behavior changes or special fight structures appear.
---
# 56. STRIKEPRACTICE VERSION COMPATIBILITY
The uploaded dev build identifies itself as:
```text
StrikePractice 4.0.0-SNAPSHOT
```
The addon should target the supplied API/dev build.
Do not blindly claim compatibility with every StrikePractice version.
Instead implement:
```text
API compatibility where public API allows it
```
and fail clearly if an incompatible version is detected.
---
# 57. BUILD SYSTEM
Use Gradle.
Recommended:
```text
Java 21+
Paper API matching target server
StrikePractice API as compileOnly
PlaceholderAPI as compileOnly
```
StrikePractice should be:
```gradle
compileOnly
```
not bundled.
PlaceholderAPI should also be:
```gradle
compileOnly
```
unless the target distribution explicitly requires another setup.
---
# 58. DEPENDENCY VERSION RULE
Do not invent dependency versions.
Read the supplied StrikePractice API/dev build and target the user's actual server environment.
Keep dependencies configurable through Gradle properties where useful.
---
# 59. PROJECT STRUCTURE
Generate a complete buildable project:
```text
StrikePracticeQueuePlaceholders/
โ
โโโ build.gradle
โโโ settings.gradle
โโโ gradle.properties
โ
โโโ src/
โ โโโ main/
โ โโโ java/
โ โ โโโ your/package/
โ โ โโโ StrikePracticeQueuePlaceholders.java
โ โ โโโ hook/
โ โ โโโ queue/
โ โ โโโ placeholder/
โ โ โโโ cache/
โ โ โโโ task/
โ โ โโโ command/
โ โ โโโ util/
โ โ
โ โโโ resources/
โ โโโ plugin.yml
โ โโโ config.yml
โ
โโโ README.md
```
Use a clean package namespace.
Do not use the user's personal name unless explicitly requested.
---
# 60. CODE QUALITY
Code must be:
- production quality
- readable
- documented where necessary
- null-safe
- exception-safe
- memory-safe
- thread-safe
- maintainable
Avoid:
- giant single classes
- duplicated logic
- reflection everywhere
- magic numbers
- unnecessary dependencies
- static global state
- unsafe async Bukkit access
---
# 61. ERROR HANDLING
If StrikePractice API access fails:
Do not crash the server.
Log:
```text
[SPQPH] Failed to read StrikePractice queue state.
```
with useful debug information only when appropriate.
Fallback placeholder value:
```text
0
```
The plugin must remain operational.
---
# 62. STARTUP VALIDATION
At startup verify:
```text
StrikePractice installed
StrikePractice API accessible
PlaceholderAPI installed
StrikePractice version detected
API compatibility
```
Then log something like:
```text
StrikePracticeQueuePlaceholders enabled.
StrikePractice hook: CONNECTED
PlaceholderAPI hook: CONNECTED
```
---
# 63. SHUTDOWN
On disable:
- cancel scheduled tasks
- unregister PlaceholderAPI expansion if necessary
- clear caches
- release StrikePractice references
- avoid memory leaks
---
# 64. NO PERSISTENT QUEUE DATABASE
Do not use:
```text
SQLite
MySQL
MongoDB
Redis
```
for these counters.
These are live runtime values.
StrikePractice already owns the queue state.
---
# 65. NO CROSS-SERVER SYSTEM
This addon is strictly:
```text
ONE MINECRAFT SERVER
```
Do not add:
```text
BungeeCord
Velocity
Redis queue synchronization
cross-server queues
```
unless explicitly requested later.
---
# 66. NO COMMAND-BASED DETECTION
Do not detect queues by listening to:
```text
/queue
/ranked
/unranked
```
commands.
Players may enter queues through:
- GUI
- API
- internal StrikePractice logic
- another addon
- command
- automation
Therefore only actual StrikePractice state matters.
---
# 67. NO INVENTORY-SCRAPING
Do not inspect player inventory/menu items to determine queue state.
The addon must read StrikePractice.
---
# 68. NO PLACEHOLDER SELF-REFERENCE
Do not calculate:
```text
%unranked_inqueue_%
```
from another external placeholder.
The addon itself must read StrikePractice.
---
# 69. API-FIRST DESIGN
Before implementing, inspect the supplied:
```text
strikepractice-api.jar
StrikePractice-dev-bulid.jar
```
and identify:
- exact API methods
- exact package names
- queue implementation
- ranked queue implementation
- unranked queue implementation
- fight implementation
- how ranked/unranked state is represented
- how fights are linked to queues
- whether any relevant Bukkit events exist
- how BattleKit is represented
- whether queue objects expose enough information
- how queue entries disappear when matched
Do NOT guess if the supplied JAR can answer the question.
Use the public API first.
Only use implementation-specific access when genuinely necessary.
---
# 70. IMPLEMENTATION PRIORITY
Priority order:
### Priority 1
Correctness.
### Priority 2
Exact StrikePractice integration.
### Priority 3
No duplicate counting.
### Priority 4
Thread safety.
### Priority 5
Performance.
### Priority 6
Configuration.
### Priority 7
Developer convenience.
Never sacrifice correctness for a clever optimization.
---
# 71. FINAL ACCEPTANCE CRITERIA
The addon is considered complete ONLY when all of the following are true:
[ ] StrikePractice is the authoritative queue source.
[ ] Unranked queue count works.
[ ] Unranked fight count works.
[ ] Ranked queue count works.
[ ] Ranked fight count works.
[ ] Ranked and unranked never mix.
[ ] Direct duels are excluded.
[ ] Party fights are excluded unless genuinely queue-originated.
[ ] Spectators are excluded.
[ ] Players are counted exactly once.
[ ] Queue-to-fight transitions are reflected.
[ ] Remaining queued players remain counted.
[ ] Ended fights disappear.
[ ] Disconnected players disappear.
[ ] Invalid queue entries disappear.
[ ] Unknown kits return configurable fallback.
[ ] Kit names resolve dynamically.
[ ] Placeholders work in PlaceholderAPI.
[ ] Holograms can use them.
[ ] Inventory items/lore can use them.
[ ] Scoreboards can use them.
[ ] DeluxeMenus can use them.
[ ] Cache is rebuilt from StrikePractice.
[ ] No second matchmaking system exists.
[ ] No queue database exists.
[ ] No cross-server dependency exists.
[ ] No unsafe asynchronous Bukkit access exists.
[ ] Plugin survives normal runtime errors.
[ ] Plugin disables cleanly.
[ ] Gradle build succeeds.
[ ] JAR is produced successfully.
---
# 72. REQUIRED FINAL DELIVERABLE
Do not only explain the design.
Generate the COMPLETE addon source code.
Provide:
```text
build.gradle
settings.gradle
gradle.properties
plugin.yml
config.yml
all Java source files
README.md
```
The result must be directly buildable.
Do not leave:
```text
TODO
implement this
your code here
...
```
inside critical functionality.
Do not create fake API methods.
If the supplied API does not expose something directly, inspect the supplied dev build and implement the safest compatible solution.
---
# 73. FINAL RULE
The entire addon can be summarized as:
```text
StrikePractice
โ
โ REAL QUEUE/FIGHT STATE
โผ
StrikePractice Hook
โ
โผ
Queue Scanner
โ
โโโ Unranked Queue
โโโ Unranked Fights
โโโ Ranked Queue
โโโ Ranked Fights
โ
โผ
Immutable Cache
โ
โผ
PlaceholderAPI
โ
โโโ %unranked_inqueue_%
โโโ %unranked_infight_%
โโโ %ranked_inqueue_%
โโโ %ranked_infight_%
โ
โผ
Holograms / GUIs / Scoreboards / TAB / DeluxeMenus
```
**StrikePractice owns the state.**
**This addon observes the state.**
**The addon never invents a second state.**
That principle must be preserved throughout the entire implementation.
Created the complete Gradle Paper/Spigot addon project with:
Required
StrikePracticeandPlaceholderAPIdependencies inplugin.ymlAtomic, refresh-driven cache updated on the server thread
Exact PlaceholderAPI formats:
%unranked_inqueue_<kitname>%%unranked_infight_<kitname>%%ranked_inqueue_<kitname>%%ranked_infight_<kitname>%
Dynamic kit-name resolution with configurable unknown/error fallbacks
Ranked queue validation and UUID duplicate protection
Queue-origin fight classification designed to exclude direct duels, spectators, and unrelated fights
/spqph reload,/spqph status, and/spqph debugConfig, build files, and a deterministic verification plan in
README.md
Place the matching Paper API, PlaceholderAPI, and supplied StrikePractice API/dev JARs into libs/, then build using Java 21 with gradle build.
package dev.kodari.strikepracticequeueplaceholders;
import dev.kodari.strikepracticequeueplaceholders.cache.QueueStateCache;
import dev.kodari.strikepracticequeueplaceholders.command.AdminCommand;
import dev.kodari.strikepracticequeueplaceholders.config.PluginConfig;
import dev.kodari.strikepracticequeueplaceholders.hook.StrikePracticeHook;
import dev.kodari.strikepracticequeueplaceholders.hook.StrikePracticeHookImpl;
import dev.kodari.strikepracticequeueplaceholders.placeholder.QueuePlaceholderExpansion;
import dev.kodari.strikepracticequeueplaceholders.queue.QueueScanner;
import dev.kodari.strikepracticequeueplaceholders.task.QueueRefreshTask;
import org.bukkit.command.PluginCommand;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.plugin.java.JavaPlugin;
public final class StrikePracticeQueuePlaceholdersPlugin extends JavaPlugin {
private PluginConfig pluginConfig;
private QueueStateCache stateCache;
private StrikePracticeHook strikePracticeHook;
private QueueScanner queueScanner;
private BukkitTask refreshTask;
private QueuePlaceholderExpansion unrankedExpansion;
private QueuePlaceholderExpansion rankedExpansion;
@Override
public void onEnable() {
saveDefaultConfig();
this.pluginConfig = new PluginConfig(this);
this.stateCache = new QueueStateCache();
this.strikePracticeHook = new StrikePracticeHookImpl(this);
this.queueScanner = new QueueScanner(this, strikePracticeHook, stateCache);
if (!strikePracticeHook.connect()) {
getLogger().severe("[SPQPH] StrikePractice API could not be accessed; disabling.");
getServer().getPluginManager().disablePlugin(this);
return;
}
this.unrankedExpansion = new QueuePlaceholderExpansion(this, stateCache, pluginConfig, "unranked");
this.rankedExpansion = new QueuePlaceholderExpansion(this, stateCache, pluginConfig, "ranked");
if (!unrankedExpansion.register() || !rankedExpansion.register()) {
getLogger().severe("[SPQPH] PlaceholderAPI expansions could not be registered; disabling.");
getServer().getPluginManager().disablePlugin(this);
return;
}
startRefreshTask();
refreshNow();
PluginCommand command = getCommand("spqph");
if (command != null) {
AdminCommand executor = new AdminCommand(this);
command.setExecutor(executor);
command.setTabCompleter(executor);
}
if (pluginConfig.logStartup()) {
getLogger().info("[SPQPH] Enabled. StrikePractice hook: CONNECTED; PlaceholderAPI hook: CONNECTED.");
}
}
@Override
public void onDisable() {
if (refreshTask != null) {
refreshTask.cancel();
refreshTask = null;
}
if (unrankedExpansion != null) {
unrankedExpansion.unregister();
}
if (rankedExpansion != null) {
rankedExpansion.unregister();
}
if (stateCache != null) {
stateCache.clear();
}
if (strikePracticeHook != null) {
strikePracticeHook.disconnect();
}
}
public void reloadPlugin() {
reloadConfig();
pluginConfig.reload();
startRefreshTask();
refreshNow();
}
public void refreshNow() {
queueScanner.refresh();
}
private void startRefreshTask() {
if (refreshTask != null) {
refreshTask.cancel();
}
long interval = pluginConfig.updateIntervalTicks();
refreshTask = getServer().getScheduler().runTaskTimer(this, new QueueRefreshTask(queueScanner), interval, interval);
}
public PluginConfig pluginConfig() {
return pluginConfig;
}
public QueueStateCache stateCache() {
return stateCache;
}
public StrikePracticeHook strikePracticeHook() {
return strikePracticeHook;
}
}