MessageFilter
该插件为您提供控制来自任何来源的聊天消息的能力。您可以隐藏令人烦恼的插件消息(永久隐藏或使用冷却时间显示),或将任意消息替换为其他内容。您甚至可以将 MessageFilter 用作翻译工具,用于那些自身不提供翻译机制的插件。
为什么我需要这个插件?
- 您希望隐藏服务器上使用的某些插件产生的垃圾信息;
- 您希望将一条消息替换为另一条消息;
- 您打算翻译某插件的消息,但该插件未提供可编辑的语言文件;
功能特性
- 隐藏消息
- 替换消息
- 消息冷却(例如,您不喜欢看到大量相同的信息,并希望在一定时间内只查看其中一条)
- 支持正则表达式(及其他类型的字符串匹配方式)
工作原理
所有添加到 MessageFilter 的规则都存储在 "MessageFilter/rules" 文件夹中的文件里。您可以通过命令或编辑规则文件来添加、修改或删除规则。
每条规则基于以下参数:
- Type(类型) — 定义用于确定消息文本的方法(在屏幕上显示之前)。共有五种类型:
- EQUAL — 不区分大小写的比较(示例:"Aaaa Bbbb" 等同于 "aaaa bbbb")
- CONTAINS — 在输入消息中查找子串
- START — 检查消息是否以提供的文本开头
- END — 检查消息是否以提供的文本结尾
- REGEX — 使用正则表达式进行匹配查找
- message-mask(消息掩码) — 定义输入掩码,用于在原消息中查找匹配项
- replace-to(替换为目标) — 定义替换内容。替换支持占位符 %word1% ... %wordN%,它们将被原消息中对应的词替换
- cooldown-time(冷却时间) — 时间格式类似于 ReActions 插件中使用的时间格式。冷却时间用于设置显示烦人消息的时间限制。例如,如果冷却时间设置为 5 秒,且 "replace-to" 掩码为空,则该烦人消息每五秒仅显示一次。
当插件(或其他来源)发送消息时,此消息会由 MessageFilter 进行管控,并根据已定义的规则进行修改。玩家看到的将是替换后的消息而非原始消息。这种方法甚至允许翻译那些未内置您所需语言翻译功能的插件。您只需找到相关消息并创建规则将其替换即可。
以下是规则文件示例:
命令
插件的主命令是 msgfilter(别名:mfilter, filter)。
- /msgfilter help — 帮助... h
- /msgfilter add <RuleId> [GroupId] — 创建新规则
- /msgfilter set <RuleId> type|input|output|cooldown|group <Value> — 将参数(类型、输入掩码、输出掩码、冷却时间或组)设置为 <Value>
- /msgfilter remove <RuleId> — 删除规则
- /msgfilter list [Mask] [PageNumber] — 显示规则列表
- /msgfilter info <RuleId> — 显示规则参数
- /msgfilter save <GroupId> [<Number>|<Time>] — 将消息保存到文件 <GroupId>.yml 中。
- /msgfilter reload — 重新加载规则
- /msgfilter test — 测试 MessageFilter。
创建规则
您可以通过以下方式创建新规则:命令行、接收到的聊天消息以及手动编辑文件。
示例:
使用命令
- /msgfilter add newrule
- /msgfilter set newrule type EQUAL
- /msgfilter set newrule input this is the input message
- /msgfilter set newrule output &6this is the output message
保存接收到的聊天消息
- /msgfilter save test1 — 将下一条(仅一条)接收到的消息保存到文件 test1.yml
- /msgfilter save test2 15 — 将接下来 15 条接收到的消息保存到文件 test1.yml
- /msgfilter save test2 10m — 在 10 分钟内将所有接收到的消息保存到文件 test1.yml
手动配置
MessageFilter 支持多个规则定义文件。它们是位于 "rules" 文件夹中的 "YAML" 文件 (*.yml)。您可以手动编辑(或创建)这些文件。
示例如下:
roadprotector: # rule Id
type: EQUAL # rule type
message-mask: '&3[RP]&cThisplaceisprotected!' # incoming message (with color code)
replace-to: '&6Здесьнельзяломатьистроить!' #outgoing (translated) message
cooldown-time: '' # cooldown time
use-formating: true # use formatting (colors)
removejoing: # rule Id
type: REGEX #rule type
message-mask: '\w+joinedtheserver\.' # incoming message, I'm going to hide it
replace-to: '' # Empty line
cooldown-time: ''
use-formating: false # 忽略格式化
annoying:
type: EQUAL
message-mask: 'Youcan't build here!'
replace-to: '' # 空行
cooldown-time: '5s' # 在五秒内你只会看到这条消息一次
use-formating: false # 忽略格式化
MessageFilter 自测
你可以使用命令 /msgfilter test 来确认 MessageFilter 是否正常工作。只需在聊天栏输入此命令即可。如果收到消息“MessageFilter test failed!”,通常你需要安装或更新 ProtocolLib。
权限
- messagefilter.config — 仅一个用于访问命令的权限。
- messagefilter.test — 当玩家加入服务器时执行 MessageFilter 测试。
依赖项
本插件需要你的服务器上已安装 ProtocolLib。
更新检查器
MessageFilter 包含一个更新检测器,它会使用您服务器的互联网连接。更新检测器每小时会检查 dev.bukkit.org,以查找插件的新发布版本。您可以轻松禁用它:只需在 config.yml 中将参数 "version-check" 设置为 "false" 即可。
MessageFilter
This plugin brings to you ability to control message in your chat provided from any source. You can hide annoying message of plugin (forever or using cooldown to display it), change any message to another. You can even use MessageFilter as translation tool for plugins that not provides translation mechanics by itself.
Why I need this plugin?
- You would like to hide some spamming message print by plugin you use at your server;
- You would like to replace one message to another;
- You going to translate message of plugin but that plugin is not providing you language-file to edit;
Features
- Hiding messages
- Replacing messages
- Cooldown for message (for example, you don't like to lot of same message, and going to see only one of them during one minute)
- Regex (and other types of string comparison) supported
How it works
All rules added to MessageFilter store in files in "MessageFilter/rules" folder. You can add, modify or remove rules using command or by editing rule files.
Every rule base on some parameters:
- Type — defines the method which will used to determine text in message (before display it on screen). There are five types:
- EQUAL — case insensitive compare (Example: "Aaaa Bbbb" will be equal to "aaaa bbbb")
- CONTAINS — find substring in input-message
- START — check if message starts with provided text
- END — check if message ends with provided text
- REGEX — using regular expression to find matches
- message-mask — defines input mask, that will used to find matches in original message
- replace-to — defines replacement. Replacements supports placeholders %word1% ... %wordN% the will be replaced with conforming word from original message
- cooldown-time — time defined in format similar to time format used in ReActions plugin. Cooldown used to set up time-limit for displaying annoying message. For example, if cooldown time is set to 5 seconds. And "replace-to" mask is empty. Annoying message will displayed only once per five seconds.
When plugin (or other source) is sending message, this message is controlled by MessageFilter and changed according to defined rules. Player will see replaced message instead of original. This methods allows even to translate a plugins that not provides built-in translation for your language. You just need to find messages and create rules to replace it.
Here is rule file example:
Commands
Main command of plugin is msgfilter (aliases: mfilter, filter).
- /msgfilter help — hmm... h
- /msgfilter add <RuleId> [GroupId] — create new rule
- /msgfilter set <RuleId> type|input|output|cooldown|group <Value> — set parameter (type, input mask, output mask, cooldown time or group) to <Value>
- /msgfilter remove <RuleId> — remove rule
- /msgfilter list [Mask] [PageNumber] — show list of rules
- /msgfilter info <RuleId> — display rule parameters
- /msgfilter save <GroupId> [<Number>|<Time>] — save message into file <GroupId>.yml.
- /msgfilter reload — reload rules
- /msgfilter test — test MessageFilter.
Creating rules
You can create new rules using: command line, incoming chat message and manully editing file.
Examples:
Using commands
- /msgfilter add newrule
- /msgfilter set newrule type EQUAL
- /msgfilter set newrule input this is the input message
- /msgfilter set newrule output &6this is the output message
Save incoming chat message
- /msgfilter save test1 — save next (only one) incoming message to file test1.yml
- /msgfilter save test2 15 — save next 15 incoming messages to file test1.yml
- /msgfilter save test2 10m — save all incoming messages during the 10 minutes to file test1.yml
Manual configuration
MessageFilter supports multiple rules definition files. It's a "YAML" fie (*.yml) located in "rules" folder. You can edit (or create new) this files manually.
Here is example:
roadprotector: # rule Id
type: EQUAL # rule type
message-mask: '&3[RP]&cThisplaceisprotected!' # incoming message (with color code)
replace-to: '&6Здесьнельзяломатьистроить!' #outgoing (translated) message
cooldown-time: '' # cooldown time
use-formating: true # use formatting (colors)
removejoing: # rule Id
type: REGEX #rule type
message-mask: '\w+joinedtheserver\.' # incoming message, I'm going to hide it
replace-to: '' # Empty line
cooldown-time: ''
use-formating: false # ignore formatting
annoying:
type: EQUAL
message-mask: 'Youcan\'t build here!'
replace-to: '' # Empty line
cooldown-time: '5s' #You will see this message only once during the five seconds
use-formating: false # ignore formatting
MessageFilter self-test
You can use command /msgfilter test to be sure that MessageFilter works fine. Just type this command in chat. If you receive message "MessageFilter test failed!" usually you need to install or update ProtocolLib.
Permissions
- messagefilter.config — only one permission to access commands.
- messagefilter.test — perform test of MessageFilter when player joins the server.
Dependencies
This plugin requires ProtocoLib installed on your server.
Update checker
MessageFilter includes a update checker that use your server internet connection. Update checker will every hour check the dev.bukkit.org to find new released version of plugin and you can easy disable it: just set parameter "version-check" to "false" in config.yml.
评论 0
登录后参与评分
还没有评论,来抢沙发吧