需要 PacketEvents。遵循 GPL-3.0 协议免费开源 —— GitHub 源码。
功能介绍
某些插件会发送丑陋的消息,且没有任何方式可以修改它。没有语言文件,没有配置选项,什么都没有。MessageStyler 从外部解决了这个问题。
它会拦截发往玩家的消息路径,允许你重写文本、将其移动到动作栏(action bar)或标题(title),甚至完全删除它——无论该消息来自哪个插件,也无论该插件是否支持格式化。
特性
- 适用于任何消息。 原版消息、插件消息、以及那些从未设计为可配置的插件消息。
- 自动消息键(Key)。 每条消息都会生成一个稳定的 8 位字符 ID,通过去除数字后的文本生成,因此
Wait 9m 45s 和 Wait 3m 20s 共享同一个键和同一条规则。
- 保留数字。 用于构建键而被移除的值会以
{0}、{1}、{2} 的形式返回——在不丢失数据的情况下完全重设消息样式。
- 路由到任意位置。 聊天框、动作栏、标题、副标题,或删除。
- 精确的动作栏计时。 以刻(ticks)为单位,让消息在动作栏停留精确的时长。如果需要,甚至可以比客户端自然的淡出时间更长。
- 按键或文本匹配。 文本匹配也会搜索原始组件 JSON,因此像
block.minecraft.set_spawn 这样的原版翻译键可以直接使用。
- 引导式设置。 开启调试模式,触发目标消息,从控制台复制键值。这就是整个工作流。
- 保持低调。 默认情况下忽略其他插件产生的动作栏输出,且不会处理已被其他插件取消的消息。
- 干净卸载。 禁用时会正确注销数据包监听器,因此使用 PlugMan 进行热插拔时不会导致监听器泄漏。
要求
- Paper 或 Spigot 1.20.5+
- PacketEvents —— 必需
- Java 21 或更高版本(26.1+ 服务器已要求 Java 25)
- 不支持 Folia
安装步骤
- 安装 PacketEvents
- 将 MessageStyler 放入
/plugins 文件夹
- 重启服务器
- 在配置文件中设置
debug: true,然后运行 /messagestyler reload
- 触发你想要修改的消息,并从控制台复制键值
- 编写规则,重新加载,然后将
debug 设置为 false
全新安装时没有激活的规则,因此在配置之前什么都不会改变。
查找消息
当 debug: true 时,每条经过的消息都会打印类似如下的行:
[7c0efe5f] "You need to wait #m #s." args=[9, 45] (no rule)
第一部分是键值。引号内的部分是消息,其中的数字已被替换为 #。args 是被提取出的数字——可在 replace 中作为 {0} 和 {1} 使用。
示例
rules:
sleep-wait:
key: '7c0efe5f'
replace: '&7Wait &f{0}m &f{1}s &7before sleeping.'
to: actionbar
duration: 60
规则选项
| 选项 |
描述 |
match |
必须出现在消息中的文本。同时搜索可见文本和原始 JSON。 |
key |
来自调试输出的 8 位字符 ID。如果同时设置了 key 和 match,key 优先级更高。 |
replace |
新文本。支持 & 颜色代码和 &x&R&R&G&G&B&B 十六进制颜色。省略则保留原文。设置为 none 则删除。 |
to |
chat、actionbar、title、subtitle 或 none |
cancel |
true 表示删除该消息 |
fade-in / stay / fade-out |
此规则的标题淡入、停留和淡出时间(单位:刻) |
duration |
动作栏停留时间(单位:刻,20 = 1 秒) |
to 还接受 message、hotbar、overlay、hidden、cancel 和 delete。下划线、连字符和大写字母将被忽略。
规则按文件顺序检查,第一个匹配的规则生效。使用 title 或 subtitle 的规则还必须设置 replace,因为标题是作为新数据包发送的,而不是就地修改。
全局设置
| 设置项 |
默认值 |
描述 |
inspect-action-bar |
false |
允许规则匹配动作栏消息。默认为关闭,以确保不触碰其他插件的动作栏输出。 |
debug |
false |
打印每条消息的键值和标准化文本 |
debug-once |
true |
每种不同的消息仅记录一次 |
debug-ignore |
[] |
从调试日志中排除的键值或文本 |
title-times |
10 / 40 / 10 |
默认的标题淡入、停留和淡出时间(单位:刻) |
命令与权限
| 命令 |
权限 |
/messagestyler reload (别名 /mstyler) |
messagestyler.reload — 默认为 op 权限 |
工作原理
MessageStyler 在 NORMAL 优先级下注册了一个针对 SYSTEM_CHAT_MESSAGE 的 PacketEvents 监听器,因此以 MONITOR 优先级监听的插件仍能观察到最终文本。
消息键的生成方式是:从组件 JSON 中提取所有的 text 和 translate 值,去除颜色代码,合并空白字符,将连续的数字替换为 #,并取 SHA-256 摘要的前四个字节作为十六进制字符串。被移除的数字按顺序保留,并暴露为 {0}、{1} 等。
仅处理纯 JSON 字符串——未在任何地方引用 Adventure 类,这也是该插件能够在不同服务器版本间保持便携性的原因。
默认 config.yml
# MessageStyler
# ==================================================================
# 重写、重新样式化并路由服务器向玩家发送的消息,
# 使无论消息由哪个插件产生,其措辞、颜色和标点符号都保持一致。
#
# 每条规则都会筛选出一条消息并决定对其执行的操作:
# - 重写文本
# - 将其移至动作栏、标题或副标题
# - 完全删除它
#
# 开箱即用,此文件中不包含任何活动规则,因此在你添加规则之前,
# 服务器上的任何内容都不会发生变化。底部的所有示例均已注释掉,
# 随时可供复制使用。
#
#
# 快速入门
# ==================================================================
# 1. 将下方的 debug: true 设置为开启状态,然后运行 /messagestyler reload
# 2. 在游戏中触发你想要更改的消息
# 3. 观察控制台。每条消息都会打印出一行类似如下格式的内容:
#
# [7c0efe5f] "You need to wait #m #s." args=[9, 45] (no rule)
#
# 第一部分是键(key)。引号内的部分是经过数字替换为 # 后的消息文本。
# args 是被提取出来的数字。
# 4. 使用该键添加一条规则(参见底部的 RULES)
# 5. 再次运行 /messagestyler reload
# 6. 完成后将 debug: false 设置回关闭状态
#
#
# 识别消息
# ==================================================================
# 有两种方式可以将规则指向某条消息。任选其一即可。如果规则同时设置了两者,
# 则以 "key" 为准,"match" 将被忽略。
#
# key 调试模式下显示的八字符标识符。它是根据消息的可见文本生成的,
# 其中数字被替换为 #,因此即使数字发生变化,同一条消息始终生成相同的 key。
# 最适合没有自有翻译键的插件消息。
#
# match 消息中出现的任意文本。搜索范围包括可见文本和原始 JSON,
# 因此 vanilla 翻译键(如 block.minecraft.set_spawn)也可在此处匹配,
# 且颜色代码将消息分割成多段也不会阻止匹配。
#
# 规则按其在文件中出现的顺序进行检查,第一条匹配成功的规则即为生效规则。
#
#
# 保留数字
# ==================================================================
# 在生成 key 时被移除的数字,可以在 "replace" 中以 {0}、{1}、{2} 等形式获取,
# 顺序与其出现顺序一致。这样可以在完全不丢失数值的情况下对消息进行彻底的重样式化。
#
# original You need to wait 9m 45s.
# replace '&7Wait &f{0}m &f{1}s &7before sleeping.'
# result Wait 9m 45s before sleeping.
#
#
# 规则选项
# ==================================================================
# match 消息中必须包含的文本。除非设置了 "key",否则此项为必填。
#
# key 来自调试信息的八字符标识符。除非设置了 "match",否则此项为必填。
#
# replace 消息的新文本。支持 & 颜色代码以及 &x&R&R&G&G&B&B 格式的十六进制颜色。
# 如果不填写此项,则保留原始措辞,这在你只想更改 "to" 时非常有用。
# 将其设置为 "none" 可完全删除该消息。
#
# to 消息应显示的位置:
# chat 普通聊天消息(默认值)
# actionbar 热件栏上方
# title 屏幕中央的大号文本
# subtitle 标题下方的小号文本
# none 删除消息
# 也接受别名:message, hotbar, overlay, hidden, cancel, delete。
# 下划线、连字符和大写字母均会被忽略,因此 action_bar 和 ACTIONBAR 均可正常工作。
#
# 标题是通过新数据包发送的,因此使用 title 或 subtitle 的规则也必须设置 "replace"。
#
# cancel true 表示删除消息。效果等同于 replace: none。
#
# fade-in
# stay
# fade-out 仅针对本规则的标题持续时间(以刻为单位)。
# 20 刻 = 1 秒。默认值来自 title-times。
#
# duration 动作栏消息在屏幕上停留的时间(以刻为单位)。
# 20 刻 = 1 秒。仅当消息最终显示在动作栏上时生效。
# 动作栏文本通常会在大约三秒后自动淡出。较短的持续时间会提前清除它,
# 而较长的持续时间会通过重新发送来延长其显示时间。
# 0(默认值)保持正常的淡出行为不变。
#
#
# 常规设置
# ==================================================================
# 动作栏文本作为带有覆盖标志的系统聊天消息发送到客户端。
# 将此设置为 false 会忽略此类消息,从而确保其他插件产生的动作栏输出不受影响。
# 仅当你希望规则也能匹配动作栏消息时,才将其设置为 true。
inspect-action-bar: false
# 打印所有流经消息的键和标准化文本。
# 可用于发现键,发现后请将其关闭。
debug: false
# 每种不同的消息仅记录一次,而不是每次发送时都记录。
# 当某个插件反复发送相同消息(例如每刻更新一次动作栏)时,
# 此举可保持控制台的易读性。
debug-once: true
# 完全排除在调试日志中的消息。
# 条目可以是 key,也可以是消息中包含的任何文本。
# 这在查找其他问题同时屏蔽某个频繁刷屏的插件时非常有用。
debug-ignore: []
# - '7c0efe5f'
# - 'X: '
# 默认的标题持续时间(以刻为单位)。20 刻 = 1 秒。
# 单个规则可以覆盖其中的任何一项。
title-times:
fade-in: 10
stay: 40
fade-out: 10
# 规则
# ==================================================================
# 在此处添加你的规则。下面的每个示例均已注释掉。
# 规则名称(如 respawn-set、sleep-wait 等)由你自行定义,
# 且仅出现在日志消息中。
rules:
根据翻译键匹配并重设原版消息的样式。
respawn-set:
match: 'block.minecraft.set_spawn'
replace: '&7已设置重生点。'
使用生成的键重设插件消息的样式,保留其中的数字。{0} 和 {1} 是原始消息中的值。
sleep-wait:
key: '7c0efe5f'
replace: '&7等待 &f{0}分 &f{1}秒 &7后再睡觉。'
to: actionbar
将消息移动到动作栏,但保持其原始措辞不变。
没有 "replace" 字段,因此文本完全保持不变。
respawn-set-to-hotbar:
match: 'block.minecraft.set_spawn'
to: actionbar
以大型标题形式显示消息,而非聊天行,并为该规则单独设置时间。
respawn-set-as-title:
match: 'block.minecraft.set_spawn'
replace: '&a已设置重生点'
to: title
fade-in: 5
stay: 30
fade-out: 5
在动作栏上固定显示某内容恰好五秒钟。
brief-note:
key: 'abc12345'
replace: '&7已保存。'
to: actionbar
duration: 100
使用十六进制颜色。
fancy-note:
key: 'abc12345'
replace: '&x&5&5&F&F&A&ASaved.'
删除一条消息,使其完全不显示。
两种形式均可。
hide-something:
match: 'some.translation.key'
replace: none
hide-something-else:
match: 'some.other.key'
cancel: true
Requires PacketEvents. Free and open source under GPL-3.0 — source on GitHub.
What it does
Some plugin sends an ugly message and gives you no way to change it. No locale file, no config option, nothing. MessageStyler fixes that from the outside.
It intercepts messages on their way to the player and lets you rewrite the text, move it to the action bar or a title, or delete it entirely — regardless of which plugin sent it or whether that plugin supports formatting at all.
Features
- Works on any message. Vanilla messages, plugin messages, messages from plugins that were never designed to be configurable.
- Automatic message keys. Every message gets a stable 8-character ID generated from its text with numbers stripped out, so
Wait 9m 45s and Wait 3m 20s share one key and one rule.
- Keeps the numbers. Values removed to build the key come back as
{0}, {1}, {2} — restyle a message completely without losing its data.
- Reroute anywhere. chat, action bar, title, subtitle, or delete.
- Exact action bar timing. Hold a message for precisely as long as you want, in ticks. Longer than the client's natural fade if you need it.
- Match by key or by text. Text matching searches the raw component JSON too, so vanilla translation keys like
block.minecraft.set_spawn work directly.
- Guided setup. Turn on debug, trigger the message, copy the key from console. That's the whole workflow.
- Stays out of the way. Action bar output from other plugins is ignored by default, and messages already cancelled by another plugin are left alone.
- Clean unload. The packet listener is properly unregistered on disable, so hot-swapping with PlugMan doesn't leak listeners.
Requirements
- Paper or Spigot 1.20.5+
- PacketEvents — required
- Java 21 or newer (26.1+ servers already require Java 25)
- Folia is not supported
Setup
- Install PacketEvents
- Drop MessageStyler in
/plugins
- Restart
- Set
debug: true in the config, run /messagestyler reload
- Trigger the message you want to change and copy the key from console
- Write a rule, reload, set
debug: false
No rules are active on a fresh install, so nothing changes until you configure it.
Finding a message
With debug: true, every message passing through prints a line like:
[7c0efe5f] "You need to wait #m #s." args=[9, 45] (no rule)
The first part is the key. The quoted part is the message with its numbers replaced by #. The args are the numbers that were taken out — available in replace as {0} and {1}.
Example
rules:
sleep-wait:
key: '7c0efe5f'
replace: '&7Wait &f{0}m &f{1}s &7before sleeping.'
to: actionbar
duration: 60
Rule options
| Option |
Description |
match |
Text that must appear in the message. Both the visible text and the raw JSON are searched. |
key |
8-character ID from debug output. Takes priority over match if both are set. |
replace |
New text. Supports & colour codes and &x&R&R&G&G&B&B hex. Omit to keep the original wording. Set to none to delete. |
to |
chat, actionbar, title, subtitle or none |
cancel |
true deletes the message |
fade-in / stay / fade-out |
Title timing in ticks for this rule |
duration |
Action bar hold time in ticks (20 = 1 second) |
to also accepts message, hotbar, overlay, hidden, cancel and delete. Underscores, hyphens and capitals are ignored.
Rules are checked in file order and the first match wins. Rules using title or subtitle must also set replace, since titles are sent as new packets rather than modified in place.
Global settings
| Setting |
Default |
Description |
inspect-action-bar |
false |
Allow rules to match action bar messages. Off by default so other plugins' action bar output is never touched. |
debug |
false |
Print the key and normalised text of every message |
debug-once |
true |
Log each distinct message only once |
debug-ignore |
[] |
Keys or text to exclude from debug logging |
title-times |
10 / 40 / 10 |
Default title fade-in, stay and fade-out in ticks |
Commands and permissions
| Command |
Permission |
/messagestyler reload (alias /mstyler) |
messagestyler.reload — default op |
How it works
MessageStyler registers a PacketEvents listener on SYSTEM_CHAT_MESSAGE at NORMAL priority, so plugins listening at MONITOR still observe the final text.
Message keys are generated by extracting every text and translate value from the component JSON, stripping colour codes, collapsing whitespace, replacing digit runs with #, and taking the first four bytes of the SHA-256 digest as hex. The removed digits are kept in order and exposed as {0}, {1} and so on.
Only plain JSON strings are touched — no Adventure classes are referenced anywhere, which is what keeps the plugin portable across server versions.
Default config.yml
# MessageStyler
# ==================================================================
# Rewrites, restyles and reroutes the messages your server sends to
# players, so wording, colour and punctuation stay consistent no
# matter which plugin produced them.
#
# Every rule picks out a message and decides what happens to it:
# - rewrite the text
# - move it to the action bar, a title or a subtitle
# - delete it entirely
#
# Out of the box this file contains no active rules, so nothing on
# your server changes until you add one. All the examples near the
# bottom are commented out and ready to copy.
#
#
# QUICK START
# ==================================================================
# 1. Set debug: true below, then run /messagestyler reload
# 2. Trigger the message you want to change, in game
# 3. Watch the console. Every message prints a line like:
#
# [7c0efe5f] "You need to wait #m #s." args=[9, 45] (no rule)
#
# The first part is the key. The quoted part is the message with
# its numbers replaced by #. The args are the numbers that were
# taken out.
# 4. Add a rule using that key (see RULES at the bottom)
# 5. Run /messagestyler reload again
# 6. Set debug: false when you are finished
#
#
# IDENTIFYING A MESSAGE
# ==================================================================
# There are two ways to point a rule at a message. Use one or the
# other. If a rule sets both, "key" wins and "match" is ignored.
#
# key The eight character identifier shown in debug. It is built
# from the message's visible text with numbers replaced by #,
# so the same message always produces the same key even when
# its numbers change. Best for plugin messages, which have no
# translation key of their own.
#
# match Any text that appears in the message. Both the visible text
# and the raw JSON are searched, so vanilla translation keys
# such as block.minecraft.set_spawn work here too, and colour
# codes splitting a message into pieces will not stop a match.
#
# Rules are checked in the order they appear in this file, and the
# first one that matches is the one that applies.
#
#
# KEEPING THE NUMBERS
# ==================================================================
# The numbers removed when the key was generated are available in
# "replace" as {0}, {1}, {2} and so on, in the order they appeared.
# So a message can be completely restyled without losing its values.
#
# original You need to wait 9m 45s.
# replace '&7Wait &f{0}m &f{1}s &7before sleeping.'
# result Wait 9m 45s before sleeping.
#
#
# RULE OPTIONS
# ==================================================================
# match Text that must appear in the message. Required unless
# "key" is set.
#
# key Eight character identifier from debug. Required unless
# "match" is set.
#
# replace New text for the message. Supports & colour codes, and
# &x&R&R&G&G&B&B for hex colours.
# Leave it out to keep the original wording, which is
# useful when you only want to change "to".
# Set it to "none" to delete the message entirely.
#
# to Where the message should appear:
# chat normal chat message (the default)
# actionbar above the hotbar
# title large centre-screen text
# subtitle smaller text below the title
# none delete the message
# Aliases also accepted: message, hotbar, overlay, hidden,
# cancel, delete. Underscores, hyphens and capitals are
# ignored, so action_bar and ACTIONBAR both work.
#
# Titles are sent as new packets, so a rule using title or
# subtitle must also set "replace".
#
# cancel true deletes the message. Same as replace: none.
#
# fade-in
# stay
# fade-out Title timing in ticks for this rule only.
# 20 ticks = 1 second. Defaults come from title-times.
#
# duration How long an action bar message stays on screen, in ticks.
# 20 ticks = 1 second. Only applies when the message ends
# up on the action bar.
# Action bar text normally fades on its own after about
# three seconds. A shorter duration clears it early, and a
# longer one keeps it alive by resending.
# 0, the default, leaves the normal fade alone.
#
#
# GENERAL SETTINGS
# ==================================================================
# Action bar text reaches the client as a system chat message with an
# overlay flag set. Leave this false and such messages are ignored, so
# action bar output from other plugins is never touched. Set it to true
# only if you want rules to be able to match action bar messages too.
inspect-action-bar: false
# Prints the key and normalised text of every message passing through.
# Use it to discover keys, then turn it off again.
debug: false
# Log each distinct message only once instead of every time it is sent.
# Keeps the console readable when a plugin sends the same message over
# and over, for example something updating the action bar every tick.
debug-once: true
# Messages to leave out of debug logging entirely.
# Entries can be a key, or any text contained in the message.
# Useful for silencing one noisy plugin while you look for something else.
debug-ignore: []
# - '7c0efe5f'
# - 'X: '
# Default title timings in ticks. 20 ticks = 1 second.
# Individual rules can override any of these.
title-times:
fade-in: 10
stay: 40
fade-out: 10
# RULES
# ==================================================================
# Add your rules here. Every example below is commented out.
# Rule names (respawn-set, sleep-wait, and so on) are yours to choose
# and only appear in log messages.
rules:
# Restyle a vanilla message, matched by its translation key.
#
# respawn-set:
# match: 'block.minecraft.set_spawn'
# replace: '&7Respawn point set.'
# Restyle a plugin message using its generated key, keeping its
# numbers. {0} and {1} are the values from the original message.
#
# sleep-wait:
# key: '7c0efe5f'
# replace: '&7Wait &f{0}m &f{1}s &7before sleeping.'
# to: actionbar
# Move a message to the action bar but keep its original wording.
# No "replace", so the text is left exactly as it was.
#
# respawn-set-to-hotbar:
# match: 'block.minecraft.set_spawn'
# to: actionbar
# Show a message as a large title instead of a chat line, with
# timings just for this rule.
#
# respawn-set-as-title:
# match: 'block.minecraft.set_spawn'
# replace: '&aRespawn point set'
# to: title
# fade-in: 5
# stay: 30
# fade-out: 5
# Hold something on the action bar for exactly five seconds.
#
# brief-note:
# key: 'abc12345'
# replace: '&7Saved.'
# to: actionbar
# duration: 100
# Use a hex colour.
#
# fancy-note:
# key: 'abc12345'
# replace: '&x&5&5&F&F&A&ASaved.'
# Delete a message so nothing is shown at all.
# Either form works.
#
# hide-something:
# match: 'some.translation.key'
# replace: none
#
# hide-something-else:
# match: 'some.other.key'
# cancel: true
评论 0
登录后参与评分
还没有评论,来抢沙发吧