Skip to content

IPlaceholders

Namespace Mc.Scripting.Services · Kind interface

public interface IPlaceholders

The 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).

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.
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.
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.

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.

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.

IPluginResource · PlaceholderScope · PlaceholderValue · Player