Placeholders Advanced
This page covers namespace metadata, listeners, local scopes, and platform integration details.
Namespace Metadata
Register namespace metadata to expose author and version information:
Metadata is consumed by PlaceholderAPI expansions and Fabric namespace registration layers.
Key Normalization
Namespaces and keys are normalized to lowercase. Use lowercase names to avoid accidental duplicates.
Arguments
Resolvers receive an optional argument string.
PlaceholderAPI-style examples:
%donatemenu_balance%%donatemenu_balance:bank%
Inside MagicPlaceholders.render(...), the default argument separator is |:
{balance|bank}{donatemenu:balance}{donatemenu:balance:bank}
Override the local separator per context when needed:
Audience Handling
Audience can be null for console or offline contexts. Use
MagicPlaceholders.audienceFromUuid(UUID) when you only have a player ID:
Local And Global Placeholders
Global placeholders are namespace-free:
Local placeholders are tied to an owner key such as a plugin instance, a logger, or another stable runtime object:
This is useful when you want one placeholder key to mean different things in different runtime scopes.
Registry Listeners
Listen to registry changes:
Debug Listeners
Subscribe to resolution events. The listener's onResolve receives the resolved
key, owner context, audience, argument, the resolved value (null on error), and
the error (null on success):
This is especially useful when debugging placeholder chains inside logger
output. LoggerCore registers such a listener itself when debug logging is on.
Safe Resolution
MagicPlaceholders.resolve(...) returns an empty string when the placeholder is
missing or when a resolver throws. Keep resolvers fast and side-effect free.
Integration Summary
- Bukkit: auto-bridges to PlaceholderAPI when the Bukkit logger integration is active.
- Fabric: registers with PB4 Placeholder API when present.
- Fabric: registers with Text Placeholder API and MiniPlaceholders when present.