IPlaceholders
Namespace Mc.Scripting.Services · Kind interface
public interface IPlaceholdersThe placeholder registry: text templates such as “Online: %server_online%” are rendered through it, and any plugin can add its own placeholders (the chat format, the tab list, nametags, kits, the messages of other plugins). Process-wide: the built-in instance is registered with ServiceManager, so every plugin in the same process sees the same names. Rendering is pure managed code (no engine call of its own): a value that reads engine state pays for that read, which is why each placeholder declares how long its value may be reused. Thread: tick thread (the values are evaluated where the text is rendered).
Methods
Section titled “Methods”| Member | Description |
|---|---|
void Invalidate(string id) |
Drops every cached value of a placeholder so the next render evaluates it again. |
bool IsRegistered(string id) |
Whether an id is registered. |
Register |
Adds a placeholder. |
string Resolve(Player subject, string text) |
Renders a template for a subject. |
Invalidate
Section titled “Invalidate”void Invalidate(string id)Drops every cached value of a placeholder so the next render evaluates it again.
Parameters
| Name | Type | Description |
|---|---|---|
id |
string |
The placeholder id. |
IsRegistered
Section titled “IsRegistered”bool IsRegistered(string id)Whether an id is registered.
Parameters
| Name | Type | Description |
|---|---|---|
id |
string |
The id. |
Returns bool: True when a placeholder has it.
Register
Section titled “Register”IPluginResource Register(string id, PlaceholderScope scope, TimeSpan cacheFor, PlaceholderValue value)Adds a placeholder. The id is lowercase letters, digits and underscores (“charter_prefix”); “%charter_prefix%” renders it. A registration with the same id replaces the earlier one (a hot-reload successor). Disposing the result (or unloading the owning plugin, when it registered from a plugin’s enable or event handler) removes it.
Parameters
| Name | Type | Description |
|---|---|---|
id |
string |
The placeholder id, namespaced by its owner (“tab_ping”, “essentials_balance”). |
scope |
PlaceholderScope |
Global (one value) or per player. |
cacheFor |
TimeSpan |
How long a value may be reused. Zero evaluates it every time it is rendered. |
value |
PlaceholderValue |
The value function. |
Returns IPluginResource: The registration.
Resolve
Section titled “Resolve”string Resolve(Player subject, string text)Renders a template for a subject. “%%” is a literal percent sign; a token that is not a registered placeholder is left as written. Text without a percent sign comes back unchanged.
Parameters
| Name | Type | Description |
|---|---|---|
subject |
Player |
The player the text is for (Player.None when there is none). |
text |
string |
The template. |
Returns string: The rendered text.
See also
Section titled “See also”IPluginResource · PlaceholderScope · PlaceholderValue · Player