API reference / @jsprismarine/script-host / host/placeholders / ScriptPlaceholders
Class: ScriptPlaceholders
Defined in: script-host/src/host/placeholders.ts:61
The placeholder namespaces of one runtime, and the server's, in registration order.
Constructors
Constructor
new ScriptPlaceholders(
options):ScriptPlaceholders
Defined in: script-host/src/host/placeholders.ts:67
Parameters
options
Returns
ScriptPlaceholders
Methods
namespaces()
namespaces():
PlaceholderNamespace[]
Defined in: script-host/src/host/placeholders.ts:143
Every registered namespace with its keys, oldest first.
Returns
register()
register(
owner,namespace,provider):number
Defined in: script-host/src/host/placeholders.ts:77
Registers a namespace for an owner.
Parameters
owner
namespace
string
provider
Returns
number
The registration's id, which unregister takes.
Throws
For a malformed namespace or key, or a provider without keys.
Throws
For a namespace that is registered already.
release()
release(
owner):void
Defined in: script-host/src/host/placeholders.ts:100
Ends every registration of an owner, as its scripts stop.
Parameters
owner
Returns
void
resolve()
resolve(
text,player):string
Defined in: script-host/src/host/placeholders.ts:111
Renders a text: each token a registered provider answers becomes its value, and every other token stays as written.
Parameters
text
string
player
string | undefined
The entity id of the player the text is for, or undefined for no one.
Returns
string
unregister()
unregister(
id,owner):void
Defined in: script-host/src/host/placeholders.ts:92
Ends a registration, when it is the owner's. An id that is not registered is left alone.
Parameters
id
number
owner
Returns
void
value()
value(
namespace,key,player):string|undefined
Defined in: script-host/src/host/placeholders.ts:125
The value of one token, as text, or undefined when nobody provides it, its provider gives no string or number, or its provider throws an error that is not fatal.
Parameters
namespace
string
key
string
player
string | undefined
The entity id of the player the text is for, or undefined for no one.
Returns
string | undefined
Throws
The error a resolver threw when fatal says it ends the render, such as the watchdog's; a render passes it on rather than leaving the token.