mProtect
针对 Paper、Purpur 和 Folia 的漏洞利用、卡顿机器及事件泛滥防护。
mProtect 的检测内容
- 非法材质、附魔、属性修饰符、耐久度、超大组件以及深层嵌套容器。
- 物品名称/描述、自定义药水效果、烟花、书页/作者/标题、告示牌文本/点击事件以及铁砧名称/修复成本。
- 命令长度、频率、被禁用的命令、命名空间及根节点。
- 未经授权的创造模式或旁观者模式。
- 基于维护中的计数器而非重复扫描附近实体,限制每个区块及每种实体类型的过量实体数量。
- 玩家过快进入新区块的移动行为。
- 红石时钟、活塞链、漏斗网络、发射器、流体循环、火焰蔓延、潜影贝连锁反应及块物理风暴。
- TNT 引燃、爆炸爆发、超大的爆炸方块列表、刷怪笼爆发以及传送门搜索或创建滥用。
- Inventory-click(库存点击)、交互、方块更改、物品掉落及投射物事件泛滥。
所有检测均可写入 H2 数据库和 JSONL 格式,向在线管理人员显示,并可选择发送到 Discord Webhook。包含英文和俄文提示消息。
要求
- Java 25
- Paper、Purpur 或 Folia 26.3
- 无需任何插件或外部数据库
mProtect 保护服务器事件层。损坏的数据包必须在 Bukkit 事件存在之前被拒绝,因此请按照 Paper 加固 中所述使用 Paper 的原生数据包限制器。mProtect 不声称其无法执行的数据包拦截功能。
安装
- 停止服务器。
- 将
mProtect-1.2.1.jar 放入服务器的 plugins 目录。
- 启动服务器一次以生成
plugins/mProtect/config.yml 和语言文件。
- 在对玩家开放服务器之前,审查各项限制。
- 从控制台或以管理员身份运行
/mprotect status 和 /mprotect test items。
更改检查项、限制、警报或消息后,请使用 /mprotect reload。更改存储设置需要重启服务器。
配置指南
生成的 config.yml 是权威来源。缺失的配置选项会自动恢复,无效的数字值将被替换为安全默认值。
物品与容器
items.blocked-materials 包含玩家不得持有的材质。验证还涵盖堆叠超限、附魔、属性、耐久度、名称、描述、自定义药水效果、烟花、序列化大小及嵌套容器。保守的默认设置避免拒绝故意的不可破坏奖励,除非启用 items.reject-unbreakable。
items.action 接受以下值:
REMOVE — 移除不安全物品。
REPLACE — 将其替换为 items.replacement。
LOG — 保留物品并记录违规。
KICK — 取消操作并断开玩家连接。
大多数检查在库存实际被触碰时运行。items.fallback-scan-minutes 控制低频安全扫描;它不是逐刻(per-tick)扫描。
书籍、告示牌与铁砧
books、signs 和 anvils 部分分别设置字符数、组件和修复成本限制。仅当需要移除格式化内容时,才设置 books.strip-formatting 或 anvils.strip-formatting。可以独立地使用 signs.strip-click-events 剥离告示牌点击事件。
命令
在移除命名空间后会检查显式禁止的名称,因此 /minecraft:op 无法绕过 op 规则。配置文件第 2 版不再默认禁止所有原生命名空间命令。当必须禁止整个插件命名空间时,仍可使用 blocked-namespaces。
实体与区块
entities.max-per-chunk 限制区块中跟踪的实体总数,而 entities.max-per-type-per-chunk 限制单一类型的实体数量。现有区块在加载时进行计数,并在生成和移除时更新计数器。
chunk-loads 限制玩家进入新区块的速度。对于预期会有快速鞘翅飞行的服务器,可增加此限制。
卡顿机器防护
每个热路径规则都是一个有界的 O(1) 窗口,键入区块、方块或玩家。没有任何规则会扫描附近的实体或整个世界:
redstone 在达到每个区块阈值后,冻结额外的红石电流变化。
automation 限制活塞移动、漏斗传输/拾取以及发射器行为。
physics 限制方块更新、流体、蔓延的火/潜影贝,以及超大型多方块结构的生长。
explosions 限制 TNT 引燃、爆炸频率、受影响的方块数量以及掉落物产出。
spawners 应用每个刷怪笼和每个区块的生成窗口限制。
portals 限制传送门的创建、玩家使用、搜索半径以及创建半径。
activity 取消过多的玩家生成的库存、交互、方块、掉落物及投射物事件。
默认值对于普通生存服务器而言故意设置得较为宽松。技术型服务器应使用 /mprotect status 和 /mprotect violations 命令逐个部分进行调整。管理绕过权限仅适用于可归因于玩家的限制;机器限制没有绕过权限,因为大多数世界事件无法确定可靠的所有者。
警报与存储
alerts.staff-chat 向拥有 mprotect.alerts 权限的玩家发送去重后的警报。
alerts.file-log 将数据写入 plugins/mProtect/violations.jsonl。
alerts.discord 可通过 HTTPS Discord Webhook 发送警报。请保持其 URL 私密。
storage.retention-days 控制内置 H2 历史记录的清理周期。
命令
| 命令 |
描述 |
权限 |
/mprotect status |
显示启用的检查项及今日计数 |
mprotect.command.status |
/mprotect violations [player] |
显示最近十条存储的违规记录 |
mprotect.command.violations |
/mprotect test <check> |
验证已配置的检查项 |
mprotect.command.test |
/mprotect inspect |
检查手持物品而不修改它 |
mprotect.command.inspect |
/mprotect scan |
审计你的库存而不修改它 |
mprotect.command.scan |
/mprotect reload |
重载安全设置和语言文件 |
mprotect.command.reload |
也可以使用别名 /mpr。
权限
mprotect.admin 授予所有管理命令、警报以及可归因于玩家的绕过权限。单独的绕过权限可用于 items(物品)、commands(命令)、books(书)、signs(告示牌)、anvils(铁砧)、creative(创造模式)、chunks(区块)、portals(传送门)和 activity(活动),格式为 mprotect.bypass.<check>。
实体生成限制故意不提供绕过权限,因为许多生成事件并没有可靠的玩家发起者。
遥测与更新
当 metrics.enabled 设置为 true 时,mProtect 使用 bStats 收集匿名使用统计数据。服务器所有者可以在全局 bStats 配置中选择退出。收集的数据和隐私详情记录在 bStats 服务器所有者指南 中。
更新检查器仅在 updates.enabled 设置为 true 且配置了项目 ID 时,才会从 Modrinth 请求公共发布元数据。它绝不会下载或安装更新。
构建
./gradlew clean build
可部署的工件是 build/libs/mProtect-1.2.1.jar。自动化测试覆盖了有界键控速率窗口、配置的操作、语义版本以及存储路径隔离。
支持
通过 GitHub Issues 报告可复现的问题,或在 Discord 寻求帮助。请提供服务器软件、Java 版本、mProtect 版本、相关配置文件以及日志中的完整错误信息。
依据 MIT License 授权。
mProtect
Exploit, lag-machine, and event-spam protection for Paper, Purpur, and Folia.
What mProtect checks
- Illegal materials, enchantments, attribute modifiers, durability, oversized components, and deeply nested containers.
- Item names/lore, custom potion effects, fireworks, book pages/authors/titles, sign text/click events, and anvil names/costs.
- Command length, frequency, blocked commands, namespaces, and roots.
- Unauthorized creative or spectator mode.
- Excessive entities per chunk and per entity type using maintained counters instead of repeated nearby-entity scans.
- Excessive player movement into new chunks.
- Redstone clocks, piston chains, hopper networks, dispensers, fluid loops, fire spread, sculk cascades, and block-physics storms.
- TNT priming, explosion bursts, oversized blast block lists, spawner bursts, and portal-search or portal-creation abuse.
- Inventory-click, interaction, block-change, item-drop, and projectile event floods.
Every detection can be written to H2 and JSONL, shown to online staff, and optionally sent to a Discord webhook. English and Russian messages are included.
Requirements
- Java 25
- Paper, Purpur, or Folia 26.3
- No required plugins or external database
mProtect protects the server event layer. Malformed packets must be rejected before Bukkit events exist, so use Paper's native packet limiter as described in Paper hardening. mProtect does not claim packet interception it cannot perform.
Installation
- Stop the server.
- Put
mProtect-1.2.1.jar into the server's plugins directory.
- Start the server once to create
plugins/mProtect/config.yml and the language files.
- Review the limits before opening the server to players.
- Run
/mprotect status and /mprotect test items from the console or as an administrator.
Use /mprotect reload after changing checks, limits, alerts, or messages. Changing storage settings requires a restart.
Configuration guide
The generated config.yml is the source of truth. Missing options are restored automatically and invalid numeric values are replaced with safe defaults.
Items and containers
items.blocked-materials contains materials players must not possess. Validation also covers overstacking, enchantments, attributes, durability, names, lore, custom potion effects, fireworks, serialized size, and nested containers. Conservative defaults avoid rejecting intentional unbreakable rewards unless items.reject-unbreakable is enabled.
items.action accepts:
REMOVE — remove the unsafe item.
REPLACE — replace it with items.replacement.
LOG — keep it and record the violation.
KICK — cancel the action and disconnect the player.
Most checks run when an inventory is actually touched. items.fallback-scan-minutes controls the low-frequency safety scan; it is not a per-tick scan.
Books, signs, and anvils
The books, signs, and anvils sections set character, component, and repair-cost limits. Set books.strip-formatting or anvils.strip-formatting only if formatting should be removed. Sign click events can be stripped independently with signs.strip-click-events.
Commands
Explicit blocked names are checked after removing a namespace, so /minecraft:op cannot bypass the op rule. Config version 2 no longer blocks every vanilla namespaced command by default. blocked-namespaces remains available when an entire plugin namespace must be prohibited.
Entities and chunks
entities.max-per-chunk limits the total tracked entities in a chunk, while entities.max-per-type-per-chunk limits a single type. Existing chunks are counted as they load and counters are updated on spawn and removal.
chunk-loads limits how quickly a player may cross into new chunks. Increase the limit for servers where fast elytra travel is expected.
Lag-machine protection
Every hot-path rule is a bounded O(1) window keyed by chunk, block, or player. No rule scans nearby entities or the whole world:
redstone freezes additional current changes after the per-chunk threshold.
automation limits piston movement, hopper transfers/pickups, and dispenser actions.
physics limits block updates, fluids, spreading fire/sculk, and oversized multi-block growth.
explosions limits TNT priming, explosion frequency, affected blocks, and drop yield.
spawners applies both per-spawner and per-chunk spawn windows.
portals bounds portal creation, player use, search radius, and creation radius.
activity cancels excessive player-generated inventory, interaction, block, drop, and projectile events.
The defaults are intentionally generous for ordinary survival servers. Technical servers should tune one section at a time using /mprotect status and /mprotect violations. Administrative bypasses exist only for attributable player limits; machine limits have no bypass because most world events have no trustworthy owner.
Alerts and storage
alerts.staff-chat sends deduplicated alerts to players with mprotect.alerts.
alerts.file-log writes plugins/mProtect/violations.jsonl.
alerts.discord can send alerts to an HTTPS Discord webhook. Keep its URL private.
storage.retention-days controls cleanup of the embedded H2 history.
Commands
| Command |
Description |
Permission |
/mprotect status |
Show enabled checks and today's counts |
mprotect.command.status |
/mprotect violations [player] |
Show the ten newest stored violations |
mprotect.command.violations |
/mprotect test <check> |
Validate a configured check |
mprotect.command.test |
/mprotect inspect |
Check the held item without modifying it |
mprotect.command.inspect |
/mprotect scan |
Audit your inventory without modifying it |
mprotect.command.scan |
/mprotect reload |
Reload safe settings and language files |
mprotect.command.reload |
The alias /mpr is also available.
Permissions
mprotect.admin grants all administrative commands, alerts, and player-attributable bypasses. Individual bypass permissions are available for items, commands, books, signs, anvils, creative, chunks, portals, and activity, using the form mprotect.bypass.<check>.
Entity spawn limits intentionally have no bypass permission because many spawn events do not have a reliable player initiator.
Telemetry and updates
mProtect uses bStats to collect anonymous usage statistics when metrics.enabled is true. Server owners can opt out in the global bStats configuration. The collected data and privacy details are documented in the bStats server owner guide.
The update checker only requests public release metadata from Modrinth when updates.enabled is true and a project ID is configured. It never downloads or installs updates.
Building
./gradlew clean build
The deployable artifact is build/libs/mProtect-1.2.1.jar. Automated tests cover bounded keyed rate windows, configured actions, semantic versions, and storage path containment.
Support
Report reproducible problems through GitHub Issues or ask for help in Discord. Include the server software, Java version, mProtect version, relevant configuration, and the complete error from the log.
Licensed under the MIT License.
评论 0
登录后参与评分
还没有评论,来抢沙发吧