Placeholders
AstralStats registers a single namespace, stats, as a ComplexPlaceholder (StatsPlaceholder) on AstralCore's RootPlaceholderContainer (AstralStats.onEnable). It resolves anywhere AstralCore evaluates a placeholder — menus, dialogs, action arguments, item lore, messages — the same surfaces described in Placeholders.
Every stats_* lookup requires the placeholder context to be a Player:
If the placeholder is resolved without one — no sub-key at all, or a context that isn't a Player — it returns null rather than throwing.
plugin.yml hard-depends on both AstralCore and PlaceholderAPI: Bukkit refuses to enable AstralStats unless PlaceholderAPI is already loaded, which guarantees the PAPI fallback built into AstralCore's own placeholder chain (see PlaceholderAPI Fallback) is available alongside %stats_...% wherever AstralStats' own configs or messages are resolved.
stats_*
Placeholder | Returns | Notes |
|---|---|---|
| The stat's current computed value, formatted |
|
| The resource's current amount, formatted |
|
The namespace prefix on <stat-key> is required. Key.key(String) (Adventure) defaults to the minecraft namespace when no : is present, so omitting astralstats: resolves the wrong key instead of failing loudly:
Example — read attack damage and shield into a menu item's lore:
Sub-key routing
StatsPlaceholder.get consumes the first remaining token with context.next() to pick a branch, then rejoins every token still left with context.collapseRemaining() (delimiter _) to rebuild the <stat-key>/<type> argument:
Any first token other than stat or resource (including none) resolves to null. For the stat branch, hyphens anywhere in the collapsed key are converted to underscores before the Key is built — so %stats_stat_astralstats:critical-chance% and %stats_stat_astralstats:critical_chance% resolve the same key.
Resolution defaults and errors
Case | Behavior |
|---|---|
|
|
|
|
|
|
|
|
Formatting
Both branches format their result through a single shared DecimalFormat("#.##") instance — at most two decimal places, no trailing zeros, no thousands separator: 50.0 → "50", 12.345 → "12.35", the -1.0 unregistered-stat default → "-1".