PAPIProxyBridge 是一个需要同时安装在您的后端服务器和代理服务器上的库桥接插件。它允许代理端插件使用 PlaceholderAPI 的占位符来格式化文本。
这是一个供其他插件调用其 API 的库插件,本身无需任何配置。
请注意:此插件并非 PlaceholderAPI 的替代品。您仍然需要在 Spigot 服务器上安装 PlaceholderAPI。
PAPIProxyBridge 提供了一个跨平台 API,让您能够使用 PlaceholderAPI 的占位符来格式化文本。
PAPIProxyBridge 可在 repo.william278.net 获取(查看 Javadocs)。
首先,在您的 build.gradle 中添加 Maven 仓库:
repositories {
maven { url 'https://repo.william278.net/releases/' }
}dependencies {
implementation 'net.william278:papiproxybridge:1.6'
}PlaceholderAPI 类提供了格式化占位符的 API。目前仅支持单例、不带括号的占位符(未来会支持更多)。
通过 PlaceholderAPI.getInstance() 获取类的实例,然后使用 #formatPlaceholders 方法为指定玩家(通过 UUID 指定,以实现跨平台兼容)格式化包含占位符的字符串。
该方法返回一个 CompletableFuture(因为我们不希望在线程等待代理与后端玩家通信时造成阻塞),您可以使用它来接收格式化后的字符串。
// 使用占位符格式化字符串
final PlaceholderAPI api = PlaceholderAPI.createInstance();
final UUID player = player.getUniqueId();
api.formatPlaceholders("Hello %player_name%!", player).thenAccept(formatted -> {
player.sendMessage(formatted);
});切勿在调用 #formatPlaceholders 时使用 #join() 方法,这是不安全的。
PAPIProxyBridge 会将已解析的请求缓存 30000 毫秒(30 秒),以避免在服务器网络通道上产生过多流量。您可以使用 PlaceholderAPI#setCacheExpiry(long) 方法来调整缓存时长。
此外,还存在 #formatComponentPlaceholders 方法。此方法允许您提供一个包含占位符的字符串,并接收一个包含格式化文本的 Adventure 组件,该组件可能包含格式和聊天事件。
友情链接: 网易我的世界 | 泰拉瑞亚 | ocent云计算 | 米饭Minecraft插件文档 | 友链合作
历史访问人次:3,101,927 | 今日访问人次:10,091 | 昨日访问人次:22,124
独立 IP:19,223 | 最近24小时独立访客:19,216
Copyright © 2019-2026 我的世界服务器列表站. All rights reserved.
❤ Powered by GermMC 京ICP备17023959号-6