Server Messages
一款 Minecraft 模组,用于自定义任何服务器消息,支持文本格式化和占位符。
它能做什么?
此模组允许你按照喜好修改任何[1] 服务器消息。你可以替换消息本身、添加或更改 格式,甚至使用 占位符。其格式与语言文件使用的 翻译文本格式 完全兼容。
常见用例包括更改“你已被封禁”等消息的颜色、在“你不在白名单中”的消息中添加信息,或自定义踢出通知。你甚至可以利用此模组在玩家加入或离开服务器时显示一些统计数据,或者让死亡消息以彩虹色显示。可能性是无限的!
对于任何与聊天相关的内容,我建议使用 Styled Chat。 如果你使用了它,本模组中所有相关消息将被禁用以防止冲突。 然后你可以使用 Styled Chat 来更改它们。
如何使用?
要修改一条消息,只需将对应的
翻译键
添加到配置文件中,并将其值更改为你喜欢的内容。文本格式基于
翻译文本格式,
并支持用于文本格式化的 QuickText 格式
以及全局 占位符。
你可以使用 /reload 命令重新加载配置文件。
占位符的格式为 ${placeholder},对于大多数消息,你只能使用不依赖特定玩家/实体的占位符!因此,${server:tps} 和 ${world:name}(主世界)是完全没问题的,但 ${player:name} 并不总是有效。
更多信息,请参阅 占位符上下文。
配置文件的格式与 Minecraft 语言文件格式兼容。因此,你可以简单地将配置文件替换为语言文件(强烈不建议这样做),它也能正常工作。请注意,这不会覆盖玩家的本地语言设置!作为参考,你可以在 这里 找到当前可用的所有语言文件列表。
如果你手动使用翻译键
(QuickText / STF
或 文本组件),例如在聊天消息或其他模组中,
它们也会受到此模组的影响,从而使用配置文件中指定的相同格式。
如果你不希望这样,你可以将 r 或 raw 附加到
QuickText
/ STF
翻译标签 (<lang ...> -> <rlang ...>),或者在翻译参数中添加 #raw 作为最后一个参数。
例如,<rawlang ...> 等同于 <lang ... #raw>,这将防止消息被修改。
对于 文本组件,其形式如下:
{"translate": "...", "with": [..., "#raw"]}。
任何其他修改服务器消息的模组(例如 BanHammer),很可能 会优先于本模组所做的更改生效。
示例配置
{
// 仅更改格式
"multiplayer.disconnect.not_whitelisted": "<red><bold><lang multiplayer.disconnect.not_whitelisted></bold></red>",
// 替换消息;使用占位符
"multiplayer.disconnect.server_shutdown": "<green>We'll be right back!</green>\n<gray><underline>Uptime: </>${server:uptime}</gray>",
// 添加文本;使用嵌套翻译参数
"multiplayer.player.joined": "<yellow><lang multiplayer.player.joined '%s'>. Good to see you!</yellow>",
// 替换消息;使用翻译参数
"multiplayer.player.left": "<yellow>See you soon, <bold>%s</bold>!</yellow>",
// 自定义翻译键;在踢出消息中添加原因
"multiplayer.disconnect.kicked.reason": "<lang multiplayer.disconnect.kicked>\n<yellow>%s</yellow>"
}
不要直接复制此内容!配置文件使用的是 JSON 格式,而 JSON 不支持 注释。示例中的注释仅用于澄清说明。请勿复制注释!
支持的翻译键
理论上,只要显式使用(例如在 翻译标签中),每个翻译键都受支持。 但在原生情况下,服务器仅使用少量翻译。 所有在服务器上解析的翻译键均受支持。这包括你在服务器上游玩时能看到的大多数消息。
如需更详细的受支持按键列表,请参见 此处。
此列表中的信息可能不准确!
虽然它能帮助你快速了解概况,但它仅基于我的发现以及大量假设。
占位符上下文
上下文是允许不同占位符生效的附加信息。例如,AfkPlus 等模组需要 player 上下文才能使其占位符正常工作。这并非在所有消息中都可获得,因此请在下方的列表中查看你所需消息的附加上下文。
所有消息均支持基本上下文,即 服务器 和 主世界,但不包括 玩家。
| 翻译键(Translation Key) | 上下文 | 添加版本 |
|---|---|---|
chat.type.advancement.* |
player |
1.0 |
commands.ban.success |
player |
1.1 |
commands.banip.success |
player |
1.1 |
commands.deop.success |
player |
1.1 |
commands.kick.success |
player |
1.0 |
commands.op.success |
player |
1.1 |
commands.pardon.success |
player |
1.1 |
death.* |
player |
1.0 |
multiplayer.disconnect.* |
player:如果玩家在断开连接前已在服务器上;否则为 profile。例外情况(非详尽列表) .transfers_disabled, .outdated_client, .incompatible这些仅具有默认上下文( server)。 |
1.1(部分 1.0) |
multiplayer.player.joined |
player |
1.0 |
multiplayer.player.joined.renamed |
player |
1.0 |
multiplayer.player.left |
player |
1.0 |
如果你希望添加特定上下文,请 提交 Issue 或 在 Discord 上告诉我。
附加翻译键
本模组还添加了若干用于配置的附加翻译键。 它们将允许你自定义一些通常无法更改的消息。
这些翻译键并非由 Minecraft 本身提供,且仅在模组配置中指定时生效。
| Translation Key | Context | Notes | Default | Version Added |
|---|---|---|---|---|
multiplayer.disconnect.kicked.reason |
player |
发送给被踢出的玩家(如果有指定原因)。 原因是唯一的参数( %s)。参见 multiplayer.disconnect.banned.reason。 |
%s |
1.1 |
为什么需要它?
几乎原版服务器发送给玩家的所有文本消息都使用翻译键来显示相应的消息。因此,它发送的不是实际的文本(例如 <Player> joined the game),而是类似 translate[multiplayer.player.joined] 的内容。客户端随后会根据玩家选择的语言将其转换为实际文本。这样游戏可以确保每位玩家都能以他们偏好的语言查看消息。虽然这非常有用,但有时这可能不是你想要的行为,因为你无法在不强制玩家使用自定义资源包的情况下更改这些消息的格式。这就是这个模组存在的原因。
通常,这些消息显示为普通的白色纯文本,相当枯燥。为了增加趣味性,你需要能够全局更改这些消息。例如,你可以将“不在白名单上”的消息更改为给新玩家提供更多额外信息。你也可以更改“你已被封禁”消息的颜色使其更加醒目。有很多这类服务器消息你可能想要自定义,所以试试看吧!
它是如何工作的?
此模组会在文本发送给玩家之前,用你在配置中指定的文本替换翻译键。这样玩家接收到的就是你的自定义消息而不是默认消息。这并不一定影响消息的翻译。因此,你可以在不丢失自动翻译功能的情况下为消息添加格式(参见示例配置)。
为了防止无限递归,你自定义消息中使用的所有翻译键都将使用其默认值和格式,而非你提供的值。
[ 1 ]: 由于 Minecraft 处理某些消息的方式,存在一些特殊情况可能无法按预期工作。
如果你遇到这种情况,请提交 Issue,
我会看看能否让它们也正常工作。
玩家聊天消息(包括 /me 等)不幸的是不被此模组支持。
请改用 Styled Chat。
Server Messages
A Minecraft mod to customize any server message, with support for text formatting and placeholders.
What does it do?
This mod lets you modify any[1] server message to your liking. You can replace the message itself, add or change the formatting, and even use placeholders. The format is fully compatible with the translated text format used by language files.
Common use cases include changing the color of messages like "You have been banned", adding information to the "You're not whitelisted" message or customizing the kick notification. You could even use the mod to display some stats when a player joins or leaves the server or make death messages appear in rainbow colors. The possibilities are endless!
For anything chat related, I recommend using Styled Chat instead. If you do, all related messages in this mod will be disabled to prevent conflicts. You can then change them using Styled Chat.
How do I use it?
To modify a message, you simply add the corresponding
translation key
to the config and change its value to your liking. The text format is based on
the translated text format
and also supports the QuickText Format for text formatting
and global placeholders.
You can reload the config with /reload.
The format for placeholders is ${placeholder} and for most messages you can only use placeholders that do NOT depend
on a player/entity! So ${server:tps} and ${world:name} (overworld) are perfectly fine, but ${player:name} will
not always work.
For more information, see Placeholder Contexts.
The config format is compatible with the Minecraft language file format. So you could simply replace the config with a language file (strongly discouraged) and it would work just fine. Note, however, that this would NOT overwrite the language setting of the players! For reference, you can find a list of all language files currently available here.
If you use translation keys manually
(QuickText / STF
or Text components), for example in chat messages or other mods,
they will also be affected by this mod and thus use the same formatting as specified in the config.
If you do not want this, you can either append r or raw to the
QuickText
/ STF
translation tags (<lang ...> -> <rlang ...>), or add #raw as the last argument to the translation arguments.
For example, <rawlang ...> is the same as <lang ... #raw> and will prevent the message from being modified.
For Text components, it would look like this:
{"translate": "...", "with": [..., "#raw"]}.
Any other mod that modifies server messages (e.g. BanHammer), will most certainly take precedence over changes made by this mod.
Example Config
{
// only change formatting
"multiplayer.disconnect.not_whitelisted": "<red><bold><lang multiplayer.disconnect.not_whitelisted></bold></red>",
// replace message; use placeholder
"multiplayer.disconnect.server_shutdown": "<green>We'll be right back!</green>\n<gray><underline>Uptime: </>${server:uptime}</gray>",
// add text; use nested translation argument
"multiplayer.player.joined": "<yellow><lang multiplayer.player.joined '%s'>. Good to see you!</yellow>",
// replace message; use translation argument
"multiplayer.player.left": "<yellow>See you soon, <bold>%s</bold>!</yellow>",
// custom translation key; add reason to kick message
"multiplayer.disconnect.kicked.reason": "<lang multiplayer.disconnect.kicked>\n<yellow>%s</yellow>"
}
Don't copy this as is! The config is using the JSON format and JSON does NOT support comments. The comments in the example are just for clarification. Do not copy the comments!
Supported Translation Keys
In theory, every translation key is supported when it is used explicitly (e.g. in a translation tag). But natively, the server only uses a few translations. All translation keys, that are parsed on the server, are supported. That includes most of the messages you can see when playing on a server.
For a more detailed list of supported keys, see here.
The information in this list may not be accurate!
Though it can be helpful to get a quick overview, it's only based on my findings and a lot of assumptions.
Placeholder Contexts
Contexts are additional information that allows different placeholders to work. For example, some mods like AfkPlus
require the player context for their placeholders to work. This may not always be available in every message,
so please check the additional contexts of your desired message in the list below.
All messages support the basic contexts, meaning the Server and the Overworld, but NOT the Player.
| Translation Key(s) | Context | Version Added |
|---|---|---|
chat.type.advancement.* |
player |
1.0 |
commands.ban.success |
player |
1.1 |
commands.banip.success |
player |
1.1 |
commands.deop.success |
player |
1.1 |
commands.kick.success |
player |
1.0 |
commands.op.success |
player |
1.1 |
commands.pardon.success |
player |
1.1 |
death.* |
player |
1.0 |
multiplayer.disconnect.* |
player if the player was already on the server before the disconnect, otherwise profile.Exceptions (non-exhaustive list) .transfers_disabled, .outdated_client, .incompatibleThese only have the default context ( server). |
1.1 (some 1.0) |
multiplayer.player.joined |
player |
1.0 |
multiplayer.player.joined.renamed |
player |
1.0 |
multiplayer.player.left |
player |
1.0 |
If you want a specific context added, please open an issue or tell me on Discord.
Additional Translation Keys
This mod also adds some additional translation keys for use in the config. They will let you customize some messages that you normally would not be able to change.
These translation keys are not provided by Minecraft itself and only work when specified in the mod config.
| Translation Key | Context | Notes | Default | Version Added |
|---|---|---|---|---|
multiplayer.disconnect.kicked.reason |
player |
Sent to the kicked player(s), if there was a reason specified. The reason is the only argument ( %s).See multiplayer.disconnect.banned.reason. |
%s |
1.1 |
Why do I need it?
Almost every text message, a vanilla server sends to its players, uses a translation key to display the corresponding
message. So instead of sending actual text (e.g. <Player> joined the game), it sends something
like translate[multiplayer.player.joined]. The client then converts this into actual text, using the player's selected
language. This way the game ensures that each player will see the message in their preferred language. While this is
pretty helpful, sometimes it may not be the behavior you want, because you cannot change the formatting of those
messages without forcing your players to use a custom resource pack. This is why this mod exists.
Usually those messages are displayed as plain old white text, which is pretty boring. So to spice things up, you need to be able to change those messages server wide. For example, you can change the "not on whitelist" message to give your new players some more information. You could also change the color of the "you have been banned" message to make it stand out. There are a lot of those server messages that you may want to customize, so give it a try!
How does it work?
This mod replaces the translation key with the text you specified in the config, before the text is sent to the player. This way the player receives your custom message instead of the default one. This does not necessarily affect the translation of the messages. So you can add formatting to messages without losing the auto translation feature (see example config).
To prevent infinite recursion, all translation keys used in your custom messages will have their default values and formatting, not the values you provided.
[ 1 ]: There are some special cases where it might not work as expected due to how Minecraft
handles certain messages.
If you encounter one of those, please open an issue,
and I'll see what can be done to make them work too.
Player chat messages (also /me, etc.), unfortunately are not supported by this mod.
Use Styled Chat for these instead.
下载 Custom Server Messages
下载 Custom Server Messages
下载 Custom Server Messages
下载 Custom Server Messages
下载 Custom Server Messages
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Custom Server Messages
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Custom Server Messages
下载 Custom Server Messages
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Custom Server Messages
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Custom Server Messages
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
更新至 26.2
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
? 使用命令保存和加载玩家或他人的背包/套装。
模组
一个基于构建器的 Minecraft 配置库!
模组
一款轻量级模组,允许服务器管理员对抗透视作弊者。
模组
通过图形界面控制模组加载。适用于需要可选功能的整合包和服务器,也适合不想手动操作文件而希望直接管理模组的极客用户。
模组
一个完整经济模组:玩家余额、动态定价商店、玩家市场、买入订单、货币物品以及网页仪表盘。
模组
? 这是 Serilum 发布的一个自定义模组整合包,请设置你的模组包实例!
评论 0
登录后参与评分
还没有评论,来抢沙发吧