GameruleLock
将你的游戏规则锁定为你选择的值——永久生效。
GameruleLock 会在服务器启动和每次世界加载时,验证配置中固定的每一个游戏规则;一旦发现偏离,便会写回配置的数值,并记录每一次修正。再也不用在重启、导入世界或好心的管理员执行了 /gamerule 命令后,惊慌失措地大喊“为什么 keepInventory 又关了?”。
✨ 功能特性
- ? 基于配置的锁定 — 可以为每个世界固定游戏规则值,也可以通过
default 块一次性为所有世界固定。配置中未列出的游戏规则绝不会受到干扰。
- ? 启动时强制应用 — 插件启用时会检查所有已加载的世界;任何偏差都会立即被纠正。
- ? 加载世界时强制应用 — 后续加载的世界(例如通过 Multiverse)会通过
WorldLoadEvent 进行相同的检查。
- ?️ 可选的运行时保护 — 当
enforce-on-change: true 时,任何与锁定值冲突的更改都会在一刻钟(tick)内被撤销,无论该更改来自玩家的 /gamerule、控制台、RCON 还是其他插件。执行了冲突命令的玩家会收到其更改被撤销的原因说明;但命令本身不会被阻止。
- ? 变更日志 — 每一次修正都会写入控制台,并且(可选地)追加到
plugins/GameruleLock/changes.log 文件中,包含时间戳、世界名称、发现的值、写入的值以及触发检查的原因。
- ? 快照命令 —
/grl capture 会将某个世界(或所有世界)当前的游戏规则直接写入 config.yml,这样你就不必手动编写 YAML 文件了。
? 安装方法
- 下载 GameruleLock jar 文件。
- 将其放入服务器的
plugins/ 文件夹中。
- 重启服务器。默认的
plugins/GameruleLock/config.yml 文件将被创建。
- 你可以手动编辑
config.yml,或者在游戏中按照你希望的方式设置游戏规则,然后运行 /grl capture all 将所有内容按当前状态锁定。
要求: Minecraft 1.20.x–1.21.x 的 Paper(或 Paper 分支),Java 21。仅使用稳定的 Bukkit/Paper API —— 不涉及 NMS,也不使用反射。
⌨️ 命令
主命令:/grl(别名:/gamerulelock)。
| 命令 |
描述 |
权限 |
/grl check [world] |
将当前值与锁定值进行比较,列出偏差(不会修改任何内容) |
gamerulelock.check |
/grl enforce [world] |
立即执行强制应用,并纠正任何偏差 |
gamerulelock.enforce |
/grl capture <world|all> |
将当前的游戏规则值快照保存到 config.yml 并保存文件 |
gamerulelock.capture |
/grl reload |
重新加载 config.yml,然后执行强制应用 |
gamerulelock.reload |
所有权限默认授予 op(操作员)。
⚙️ 配置
# 是否撤销与锁定值冲突的运行时更改(玩家 /gamerule、控制台、RCON、其他插件)?
# 命令不会被阻止;该值将在一刻钟(tick)内被纠正。
enforce-on-change: true
# 是否将修正记录追加到 plugins/GameruleLock/changes.log?
# (控制台日志始终开启。)
log-to-file: true
# 是否在做出修正时向在线的操作员发送简短摘要?
notify-ops: true
# 应用于所有世界的锁定规则。
default:
keepInventory: true
doFireTick: false
# 针对特定世界的锁定规则。这些规则会覆盖该世界的 "default" 块。
worlds:
world_nether:
doMobSpawning: false
注意:
- 值必须匹配游戏规则的类型 —— 布尔规则使用
true/false,整数规则使用整数(例如 randomTickSpeed: 3)。
- 如果游戏规则名称未知或值类型错误,则会被跳过并附带控制台警告;配置的其他部分仍正常工作。
- 某个世界的有效锁定规则是
default 块与该世界在 worlds 下的条目合并而成,若存在冲突,则以该世界条目的值为准。
- 配置中完全未出现的游戏规则将完全不受影响。
? 变更日志文件
当启用 log-to-file 时,每一次修正都会作为一行纯文本追加到 plugins/GameruleLock/changes.log 中:
2026-07-21 14:03:12 [startup] world: keepInventory false -> true
触发标签可以是以下之一:startup(启动)、world-load(世界加载)、runtime(运行时更改被撤销)或 manual(/grl enforce 或 /grl reload)。文件写入操作在非主线程上进行,因此日志记录不会占用你的游戏刻(ticks)。
? GameruleLock 故意不做的事情
不提供图形界面(GUI)、不使用数据库、没有网页面板,也不会锁定非游戏规则的设置(如难度或生成标志)。它只做一件事:让你的游戏规则保持在你设定的位置。
GameruleLock
Lock your gamerules to the values you chose — permanently.
GameruleLock verifies every gamerule you pin in its config on server startup and on every world load, writes the configured value back whenever it deviates, and logs each correction. No more "why is keepInventory off again?" panic after a restart, a world import, or a well-meaning admin's /gamerule command.
✨ Features
- ? Config-based locking — pin gamerule values per world, or for all worlds at once via a
default block. Gamerules not listed in the config are never touched.
- ? Startup enforcement — all loaded worlds are checked when the plugin enables; any drift is reverted immediately.
- ? World-load enforcement — worlds loaded later (e.g. through Multiverse) go through the same check via
WorldLoadEvent.
- ?️ Optional runtime protection — with
enforce-on-change: true, any conflicting change is reverted within one tick, whether it came from a player's /gamerule, the console, RCON, or another plugin. Whoever ran a conflicting command is told why their change was reverted; the command itself is never blocked.
- ? Change log — every correction is written to the console and (optionally) appended to
plugins/GameruleLock/changes.log with a timestamp, the world, the value found, the value written, and what triggered the check.
- ? Snapshot command —
/grl capture writes the current gamerules of a world (or all worlds) straight into config.yml, so you never have to hand-write YAML.
? Installation
- Download the GameruleLock jar.
- Drop it into your server's
plugins/ folder.
- Restart the server. The default
plugins/GameruleLock/config.yml is created.
- Either edit
config.yml by hand, or set your gamerules in game the way you want them and run /grl capture all to lock everything in as-is.
Requirements: Paper (or a Paper fork) for Minecraft 1.20.x–1.21.x, Java 21. Only stable Bukkit/Paper API is used — no NMS, no reflection.
⌨️ Commands
Main command: /grl (alias: /gamerulelock).
| Command |
Description |
Permission |
/grl check [world] |
Compare current values against the locked ones and list deviations (changes nothing) |
gamerulelock.check |
/grl enforce [world] |
Run enforcement now and revert any deviations |
gamerulelock.enforce |
/grl capture <world|all> |
Snapshot current gamerule values into config.yml and save the file |
gamerulelock.capture |
/grl reload |
Reload config.yml, then run enforcement |
gamerulelock.reload |
All permissions default to op.
⚙️ Configuration
# Revert runtime changes (player /gamerule, console, RCON, other plugins)
# that conflict with a locked value? Commands are not blocked; the value is
# corrected within one tick.
enforce-on-change: true
# Also append corrections to plugins/GameruleLock/changes.log?
# (Console logging is always on.)
log-to-file: true
# Send a short summary to online operators whenever corrections are made?
notify-ops: true
# Locks applied to every world.
default:
keepInventory: true
doFireTick: false
# Per-world locks. These override the "default" block for that world.
worlds:
world_nether:
doMobSpawning: false
Notes:
- Values must match the gamerule's type —
true/false for boolean rules, whole numbers for integer rules (e.g. randomTickSpeed: 3).
- An unknown gamerule name or a wrong value type is skipped with a console warning; the rest of the config keeps working.
- The effective locks for a world are the
default block merged with that world's entry under worlds, with the world entry winning on conflicts.
- Gamerules that appear nowhere in the config are left completely alone.
? Change log file
When log-to-file is enabled, every correction is appended to plugins/GameruleLock/changes.log as one plain-text line:
2026-07-21 14:03:12 [startup] world: keepInventory false -> true
The trigger tag is one of startup, world-load, runtime (a runtime change was reverted) or manual (/grl enforce / /grl reload). File writes happen off the main thread, so logging never costs you ticks.
? What GameruleLock deliberately does not do
No GUI, no database, no web panel, and no locking of non-gamerule settings such as difficulty or spawn flags. It does one thing: keep your gamerules where you put them.
评论 0
登录后参与评分
还没有评论,来抢沙发吧