ServerLinksSender
背景
Minecraft 1.21 发布了一项新功能,允许原版服务器向原版客户端发送特定的链接,客户端可以在暂停菜单中通过一个新选项“Server Links”(服务器链接)来显示这些链接。在该界面中,链接会被列出并可以点击。
原版仅暴露了发送“错误报告链接”的功能,供玩家用于报告服务器上的问题,但该系统实际上能够支持更多功能!这就是本模组的作用所在。
描述
ServerLinksSender 允许配置自定义的按钮标签和对应的链接,因此你可以提供属于自己的链接和标签,例如服务器网站、投票链接、Discord 链接等,并且可以在服务器运行期间定期更新它们。
此外,本模组支持 占位符 API 和 quicktext,从而实现简单且动态的文本组件。
最后,你可以利用 Predicate API 在特定条件下发送某些链接,例如:仅向拥有 staff 权限的玩家发送工作人员文档链接,或者当玩家处于活动世界时发送包含活动规则的链接!
限制
首先,你无法使用任何形式的点击事件或悬停效果,因为这些链接是作为按钮而非聊天消息显示的。我尚未测试所有情况,但可以确认文本装饰和颜色可以正常工作。
此外,原版服务器链接界面在新链接发送后不会重新渲染。它仅在玩家实际打开该界面时才会重新渲染,并且仅渲染一次,这意味着你无法使用像世界时间这样高度动态的占位符,因为它们在玩家查看时不会更新。
命令
| 命令 |
权限 |
描述 |
/reloadserverlinks [--force-update] |
serverlinks.main |
从文件中重载配置文件,并可选择将新列表发送给当前所有在线玩家;如果玩家仅在登录时获取链接(详见下文),此命令在无需重新登录的情况下更新链接非常有用 |
示例配置
模组会创建一个默认配置文件,你可以将其作为基础进行参考。以下是一个类似的配置,并附带了一些解释(以 // 标记注释):
{
// 在列表再次发送给所有玩家之前应经过的刻数
// 如果你使用了在整个用户游戏会话中会变化的占位符,则需要此项。设置为 20 表示大约每秒发送一次。不建议低于 20。
// 设置为 -1 将禁用周期性更新,意味着玩家仅在登录时(或使用 --force-update 时)获取列表
"refresh_interval": -1,
// 无条件发送给所有用户的链接列表
"global_server_links": {
"<red><bold>My cool link!": "https://google.com"
},
// 如果玩家满足要求(例如拥有特定权限或处于特定世界),可额外发送的多组链接
"additional_links": [
{
"links": {
"<rb>My cool extra link!": "https://google.com"
},
// 有关如何使用此功能的更多信息,请参阅 https://github.com/Patbox/PredicateAPI/blob/1.21/BUILTIN.md
"requirement": {
"type": "permission",
"permission": "example.permission",
"operator": 2
}
}
]
}
ServerLinksSender
Context
Minecraft 1.21 released a new feature, allowing vanilla servers to send vanilla clients certain links which the client then can display in the pause menu under a new option called Server Links. In there they are listed and can be clicked on.
Vanilla only exposes sending a “Bug report link” that players can use to report bugs on the server, but the system is capable of doing much more! That’s where this mod comes in.
Description
ServerLinksSender allows to configure custom button labels and links for those, so you can supply your very own links and labels for things like server website, vote links, discord links, etc. and periodically update them as the server runs.
Additionally, this supports placeholder API and quicktext, allowing for easy and dynamic text components.
Finally, you can make use of the Predicate API to send certain links only under certain conditions, for example, send a link to the staff docs only to players with the staff permission or send a link with event rules if players are in the event world!
Limitations
First things first, you are not able to use clickevents or hovereffects of any sort as these are used in a button, not chat. I have not tested everything, but can confirm text decorations and colours work fine.
Additionally, the vanilla server links screen does NOT re-render if the new links gets sent. It will only re-render whenever the player actually opens it, and then it only gets rendered once, meaning you can't do super dynamic placeholders like worldtime as they don't get updated as the played looks at them.
Commands
| Command |
Permission |
Description |
/reloadserverlinks [--force-update] |
serverlinks.main |
Reloads the config from file and can optionally send the new list to all currently online players; this is especially useful if the players only get the links once (more on that below) and you want to update the links without having to re-log |
Example config
The mod creates a default configuration that you can use as a baseline, below is a similar configuration with some explanations (marked with //
{
// how many ticks should pass before the list gets sent to all players again
// you will need this if you have placeholders in use that change throughout user's play session. Setting this to 20 means it gets sent roughly every second. Lower than 20 is not recommended.
// Setting this to -1 will disable periodic updates, meaning players will only get the list when they login (or --force-update is used)
"refresh_interval": -1,
// list of links to get sent to all users without any condition
"global_server_links": {
"<red><bold>My cool link!": "https://google.com"
},
// multiple sets of links that can be sent additionally to those above if the player matches the requirements (e.g. has a certain permission or is in a certain world)
"additional_links": [
{
"links": {
"<rb>My cool extra link!": "https://google.com"
},
// for more info on how to use this, see here https://github.com/Patbox/PredicateAPI/blob/1.21/BUILTIN.md
"requirement": {
"type": "permission",
"permission": "example.permission",
"operator": 2
}
}
]
}
评论 0
登录后参与评分
还没有评论,来抢沙发吧