ChunkGuard
当服务器因卡顿机器(lag machine)而变卡时,你通常需要在世界中四处奔跑寻找是哪个玩家的农场导致了问题。此插件会自动找出导致卡顿的区块,将其冻结,并将坐标发送给管理员。
它仅处理游戏内的负载问题,并非 DDoS 防护。
工作原理
每隔一秒(可配置),插件会统计每个区块中的事件数量:红石、漏斗、生物生成、活塞,以及可选的方块物理效果。每种事件类型都有各自的权重,总和即为该窗口期内的区块负载分数。
如果某个区块连续多个窗口期的分数超过阈值(默认为 3 个窗口),它将被冻结。你所选择的事件类型在该区块内会被取消,从而停止卡顿。没有人会被踢出服务器,玩家也可以继续游玩。
引入“警告”系统是为了防止单次突发情况(如爆炸或大型农场启动)触发冻结。
当区块被冻结时,管理员会收到一条包含世界名称、坐标、原因以及附近最后一名正在建造的玩家的消息。你也可以通过 Webhook 将相同的警报发送到 Discord。
功能
- 自动发现卡顿机器和滥用区块的行为
- 每种事件类型有独立的权重,全部可配置
- 仅冻结问题区块,世界的其余部分不受影响
- 冻结状态在重启后保留
- 支持白名单以信任的农场
- 支持聊天、控制台和 Discord Webhook 警报,并带有冷却时间以防止刷屏
- 可选的冻结后自动清理功能(默认关闭)
- 忽略特定世界
- 调试模式可查看正常农场的分数
- 所有消息均可在配置文件中编辑
自动清理
默认关闭。如果开启,插件会在短暂延迟后自行清理该区块。各项操作分别独立启用:
entities 移除除玩家、命名生物、驯服宠物以及 keep.types 中指定的类型之外的所有实体
machines 移除卡顿机器相关的方块(红石、活塞、漏斗、侦测器等,列表见配置文件)。地形和普通建筑不会受到影响
regenerate 尝试重新生成该区块。较新版本没有提供相关 API,因此插件会向控制台输出一行信息,并在启用了 machines 的情况下回退到清理机器方块
清理完成后,区块将被解冻,管理员会收到一份报告。
警告: machines 和 regenerate 会删除方块。如果误触发,可能会导致有人丢失建筑。请先设置好阈值和白名单。
命令
主命令:/chunkguard(别名:/cg, /lagshield)
| 命令 |
作用 |
/cg list |
列出已冻结的区块 |
/cg tp <id> |
传送至已冻结的区块 |
/cg unfreeze <id or all> |
解冻某个区块或全部区块 |
/cg whitelist add [world cx cz] |
将区块加入白名单(若无参数则为当前区块) |
/cg whitelist remove [world cx cz] |
从白名单中移除区块 |
/cg whitelist list |
显示白名单 |
/cg status |
简短摘要 |
/cg reload |
重载配置文件 |
权限:chunkguard.admin 用于所有命令,chunkguard.alert 用于接收警报。两者默认仅限 OP 使用。
配置文件
window-ticks: 20 # 一个统计窗口的长度(20 = 1 秒)
strikes-required: 3 # 连续超过阈值的窗口数,达到后触发冻结
threshold: 2500 # 每个窗口的负载分数阈值
weights:
redstone: 1.0
physics: 0.2
hopper: 1.5
spawn: 4.0
piston: 3.0
monitor: # 需要统计的事件类型
redstone: true
physics: false # 事件较多,默认关闭
hopper: true
spawn: true
piston: true
freeze:
duration-seconds: 0 # 0 = 手动解冻
cancel: # 冻结区块内取消哪些事件
redstone: true
physics: false
hopper: true
spawn: true
piston: true
auto:
enabled: false
delay-seconds: 5
unfreeze-after: true
actions:
entities: true
machines: false
regenerate: false
ignore-worlds: []
alerts:
chat: true
console: true
cooldown-seconds: 60
discord:
enabled: false
webhook-url: ""
debug: false
为了上手,建议先开启 debug: true 运行几天,并在控制台中查看正常农场的分数。阈值应远高于此数值。如果出现误冻结,请提高阈值。
配置文件中的消息默认使用俄语。你可以将其更改为任何你想要的语言。
兼容性
- Paper, Purpur, Spigot, Bukkit, Folia
- Minecraft 1.20 及更高版本
- Java 17+
- 仅使用基础 Bukkit API,不涉及 NMS
支持
疑问或 Bug 反馈:Discord 或 Issues 标签页。请附上你的服务器版本和配置文件。
作者:1mN1kO
ChunkGuard
When the server starts lagging because of a lag machine, you usually have to run around the world looking for whose farm it is. This plugin finds the laggy chunk for you, freezes it, and sends the coordinates to admins.
It only deals with load inside the game. It is not DDoS protection.
How it works
Every second (configurable) the plugin counts events in each chunk: redstone, hoppers, mob spawns, pistons and, optionally, block physics. Each event type has its own weight, and the sum is the chunk's load score for that window.
If a chunk stays above the threshold for several windows in a row (3 by default), it gets frozen. Events of the types you chose are cancelled there, so the chunk stops lagging. Nobody gets kicked, and the players keep playing.
The strike system is there so a single spike, like an explosion or a big farm starting up, doesn't freeze anything.
When a chunk is frozen, admins get a message with the world, coordinates, reason, and the last player who was building nearby. You can also send the same alert to Discord with a webhook.
Features
- Finds lag machines and chunk abuse automatically
- Separate weight for each event type, all of it configurable
- Freezes only the problem chunk, the rest of the world is untouched
- Frozen chunks survive a restart
- Chunk whitelist for farms you trust
- Chat, console and Discord webhook alerts, with a cooldown so it doesn't spam
- Optional auto-clean after a freeze (off by default)
- Ignore specific worlds
- Debug mode to see how much your normal farms score
- All messages are editable in the config
Auto-clean
Off by default. If you turn it on, the plugin cleans the chunk itself after a short delay. Each action is switched on separately:
entities removes all entities except players, named mobs, tamed pets and the types in keep.types
machines removes lag machine blocks (redstone, pistons, hoppers, observers and so on, the list is in the config). Terrain and normal builds are not touched
regenerate tries to regenerate the chunk. Newer versions have no API for this, so the plugin writes a line to the console and falls back to machines if it's enabled
After cleaning, the chunk is unfrozen and admins get a report.
Warning: machines and regenerate delete blocks. If it triggers by mistake, someone can lose a build. Set up the threshold and the whitelist first.
Commands
Main command: /chunkguard (aliases: /cg, /lagshield)
| Command |
What it does |
/cg list |
List frozen chunks |
/cg tp <id> |
Teleport to a frozen chunk |
/cg unfreeze <id or all> |
Unfreeze a chunk or all of them |
/cg whitelist add [world cx cz] |
Add a chunk to the whitelist (current chunk if no arguments) |
/cg whitelist remove [world cx cz] |
Remove a chunk from the whitelist |
/cg whitelist list |
Show the whitelist |
/cg status |
Short summary |
/cg reload |
Reload the config |
Permissions: chunkguard.admin for all commands, chunkguard.alert to receive alerts. Both are op-only by default.
Config
window-ticks: 20 # length of one counting window (20 = 1 second)
strikes-required: 3 # windows in a row above the threshold before freezing
threshold: 2500 # load score per window
weights:
redstone: 1.0
physics: 0.2
hopper: 1.5
spawn: 4.0
piston: 3.0
monitor: # which events to count
redstone: true
physics: false # a lot of events, off by default
hopper: true
spawn: true
piston: true
freeze:
duration-seconds: 0 # 0 = unfreeze manually
cancel: # what is cancelled in a frozen chunk
redstone: true
physics: false
hopper: true
spawn: true
piston: true
auto:
enabled: false
delay-seconds: 5
unfreeze-after: true
actions:
entities: true
machines: false
regenerate: false
ignore-worlds: []
alerts:
chat: true
console: true
cooldown-seconds: 60
discord:
enabled: false
webhook-url: ""
debug: false
To get started, turn on debug: true for a couple of days and check in the console how much your normal farms score. The threshold should be well above that. If you get false freezes, raise it.
Messages in the config are in Russian by default. You can change them to any language you want.
Compatibility
- Paper, Purpur, Spigot, Bukkit, Folia
- Minecraft 1.20 and newer
- Java 17+
- Uses only the basic Bukkit API, no NMS
Support
Questions or bugs: Discord or the issues tab. Please include your server version and config.
Author: 1mN1kO
评论 0
登录后参与评分
还没有评论,来抢沙发吧