Placeholders¶
The placeholder module offers a shared registry plus platform bridges for:
- Bukkit PlaceholderAPI
- Fabric PB4 Placeholder API
- Fabric Text Placeholder API
- Fabric MiniPlaceholders
Register Placeholders¶
MagicPlaceholders.registerNamespace("myplugin", "MyPlugin", "1.0.0");
MagicPlaceholders.register("myplugin", "online", (audience, arg) -> "42");
MagicPlaceholders.register("myplugin", "balance", (audience, arg) -> {
return arg != null ? arg : "0";
});
Global placeholders are available without a namespace:
Local placeholders are scoped to an owner key:
Resolve And Render¶
Resolve a single entry directly:
Render tokens inside text:
PlaceholderContext context = PlaceholderContext.builder()
.audience(audience)
.defaultNamespace("myplugin")
.ownerKey(this)
.inline(Map.of("player", "Steve"))
.build();
String text = "Hello {player}! Balance: {balance|bank}";
String rendered = MagicPlaceholders.render(context, text);
Convenience overloads:
Resolution Order¶
For {key} tokens:
- Inline values from the context
- Local placeholders for the
ownerKey - Default namespace (
defaultNamespace:key) - Global placeholders
Namespaced tokens use {namespace:key} or {namespace:key:arg}. For local
arguments in plain {key} form, use the argument separator (default |):
Platform Bridges¶
- Bukkit: the bridge is installed when the Bukkit
Loggeradapter is created or when Bukkit bootstrap wiring creates that logger for you. - Fabric: the bridge is installed by the Fabric logger integration and registers available placeholders with PB4 Placeholder API, Text Placeholder API, and MiniPlaceholders when those mods are present.
Supported Fabric mods:
Registry Introspection¶
Snapshots of the registry are available for tooling and debugging:
Set<String> namespaces = MagicPlaceholders.namespaces();
Map<MagicPlaceholders.PlaceholderKey, MagicPlaceholders.PlaceholderResolver> entries =
MagicPlaceholders.entries();
See Placeholders Advanced for metadata, listeners, and debug hooks.