GitHub — Discord
PAPIProxyBridge 是一个库桥接插件,你需要将其安装在后端和代理服务器上,它允许代理插件使用 PlaceholderAPI 占位符来格式化文本。
面向服务器所有者
这是一个库插件,旨在与实现了其 API 的插件配合使用。无需进行任何配置。
在你的 Spigot (1.16.5+) 或 Fabric (1.19.3+) 服务器上安装该插件的最新版本以及 PlaceholderAPI 插件(在 Fabric 上为 PlaceholderAPI 模组),然后在你的 BungeeCord 或 Velocity 代理服务器上安装此插件。
请注意,本插件不能替代 PlaceholderAPI。你仍然需要在 Spigot/Fabric 服务器上安装 PlaceholderAPI。
面向开发者
PAPIProxyBridge 提供了一个跨平台的 API,让你能够使用 PlaceholderAPI 占位符来格式化文本。
将库添加到你的项目中
PAPIProxyBridge 可在 repo.william278.net 上获取(在此查看 javadocs)。首先,将 maven 仓库添加到你的 build.gradle 中:
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 component,其中可能包含格式化和聊天事件。
GitHub — Discord
PAPIProxyBridge is a library bridge plugin you install on both your backend and proxy servers that allows proxy plugins to format text with PlaceholderAPI placeholders.
For server owners
This is a library plugin intended for use with plugins that implement its API. There is nothing to configure.
Install the latest version of the plugin alongside the PlaceholderAPI plugin on your Spigot (1.16.5+) or the PlaceholderAPI mod on your Fabric (1.19.3+) server, then install the plugin on your BungeeCord or Velocity proxy server.
Note this plugin is not a replacement for PlaceholderAPI. You still need to install PlaceholderAPI on your Spigot/Fabric server.
For developers
PAPIProxyBridge exposes a cross-platform API to let you format text with PlaceholderAPI placeholders.
Adding the library to your project
PAPIProxyBridge is available on repo.william278.net (view javadocs here). First, add the maven repository to your build.gradle:
repositories {
maven { url 'https://repo.william278.net/releases/' }
}
Then add the dependency:
dependencies {
implementation 'net.william278:papiproxybridge:1.6'
}
Example usage
The PlaceholderAPI class exposes the API for formatting placeholders. At the moment, only singleton non-bracketed placeholders are supported (more in the future).
Get an instance of the class with PlaceholderAPI.getInstance(), then use the #formatPlaceholders method to format a string with placeholders on a player (specified with UUID for cross-platform simplicity).
The method returns a CompletableFuture (since we don't want to lock threads while the proxy networks with players on the backend) that you can use to accept the formatted string.
// Format a string with placeholders
final PlaceholderAPI api = PlaceholderAPI.createInstance();
final UUID player = player.getUniqueId();
api.formatPlaceholders("Hello %player_name%!", player).thenAccept(formatted -> {
player.sendMessage(formatted);
});
Never invoke #join() on calls to #formatPlaceholders; this is unsafe.
PAPIProxyBridge caches resolved requests for 30000 milliseconds (30 seconds), to avoid causing excessive traffic over your server's network channels. You can adjust how long to cache requests for using the PlaceholderAPI#setCacheExpiry(long) method.
There also exists #formatComponentPlaceholders. This method allows you to supply a string containing placeholders and receive an adventure component containing the formatted text, which may contain formatting and chat events.
下载 PAPIProxyBridge
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 PAPIProxyBridge
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 PAPIProxyBridge
下载 PAPIProxyBridge
下载 PAPIProxyBridge
下载 PAPIProxyBridge
下载 PAPIProxyBridge
下载 PAPIProxyBridge
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 PAPIProxyBridge
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 PAPIProxyBridge
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
[已验证] 修复:按后端范围缓存占位符 (#238)
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
插件
PacketEvents 是一款专为 Minecraft Java 版打造的协议库,旨在简化数据包的处理与传输。
插件
ExyliaPlugins 的库。
插件
为基于 Spigot/Paper/Folia 的服务器添加对 Vivecraft 的支持
插件
一个在游戏内运行的 Minecraft 地图编辑器! 支持选区、蓝图、复制粘贴、笔刷和脚本。 可在创造模式中使用,也可在生存模式中临时使用。
插件
SkyBlock、OneBlock、Boxed、SkyGrid、AcidIsland、CaveBlock、Poseidon、StrangerRealms——以及更多!这些只是由 BentoBox 支持的基于岛屿的游戏模式之一。来自原版 ASkyBlock 的作者。
插件
一个强大的 API,用于为你的 Minecraft 服务器创建自定义进度。
评论 0
登录后参与评分
还没有评论,来抢沙发吧