占位符

警告

These docs were written for SpongeAPI 7 and are likely out of date. If you feel like you can help update them, please submit a PR!

A common task for chat plugins is to provide and consume placeholders, tokens that map to Component based on context. For example, a 「name」 placeholder may return a player’s name, or a 「balance」 placeholder may return the value of a player’s default account.

Sponge 提供了一个易用的占位符 API,它为占位符提供一个注册器和解析的流程。不需要安装一些占位符的库就能允许插件以通用的方式提供自己的占位符。

備註

Sponge 占位符 API 不提供解析含占位符标记的整个字符串。

目錄