允许任何拥有 /gamemode 权限的人使用热键 F3 + N(以及 F3+F4 游戏模式切换器)。
对于 1.21.5 之前的版本,请使用原版:
已在 Paper Server 1.21.11 上测试。其他服务器软件可能也能正常工作。(请报告错误)
简介
如果在具有 /gamemode 权限但未获得 op(管理员权限)的 Bukkit 服务器上按下 F3 + N 或使用游戏模式切换器(F3 + F4),你的 Minecraft 客户端将不允许你实际更改游戏模式。这是因为 Minecraft 客户端需要确认你是服务器操作员。此插件正是为了解决这一问题而构建的。
从 Minecraft 1.21.6 开始,游戏模式切换器还会发送其专用的数据包,服务器会将其与玩家的 真实 op 等级进行比对,这完全独立于上述客户端端的解锁机制。此插件也会拦截该数据包并自行执行切换操作,因此 F3+N/F3+F4 在 1.21.6 及更高版本中仍能像以前一样正常工作(参见 PaperMC/Paper#13489 —— 目前尚无针对此功能的官方 Paper API)。
用法
将下载的 jar 文件放入你的 plugins 文件夹即可正常运行。如果你已安装 ProtocolLib,插件会尝试使用它;但即使没有安装,插件也能正常工作。
如果你不希望所有能使用 /gamemode 的人都能访问这些调试热键,可以通过在此插件的 config.yml 中将 "enable-permission-check" 设置为 "true" 来自定义该行为。启用此选项后,你可以赋予用户 f3nperm.use 权限以授予他们访问热键的权限。
自定义游戏模式动作
除了直接切换游戏模式外,你还可以为四种 F3+N 选项(生存/创造/冒险/旁观者)中的任意一种配置要运行的命令——当设置了命令时,切换操作本身将被跳过。每种模式都可以要求额外的专属权限(在基础权限之上),并且命令支持 %player% 占位符,如果安装了 PlaceholderAPI,还支持其完整的占位符集。命令由控制台执行,因此它们可以执行普通玩家无法执行的操作(例如 /time set day)。
这在 config.yml 的 gamemode-actions 下进行配置,且为可选功能——默认情况下,没有任何变化,F3+N 的行为始终如一。
组合键
对于更高级的设置,F3+N(或原则上任何其他支持的动作)可以变成一次性“激活”以执行完全不同的动作。选择一种模式即激活一个切换;接下来来自该玩家的匹配动作(丢弃物品、交换手持物品、潜行、疾跑、离开床、骑乘马鞍马匹跳跃、或 - 实验性 - 移动方向)将“消耗”它并运行命令,在重新解除激活之前,可选择取消它所劫持的动作。任何识别出的动作都可以作为激活或消耗的触发器,因此组合键不限于那四个游戏模式按钮。
这在 config.yml 的 key-combos 下进行配置,默认禁用,并且完全独立于上述自定义游戏模式动作(尽管两者会相互作用:用于激活组合键的模式优先于为其配置的任何命令)。
支持的版本
支持从 1.9 到当前 26.x 版本的 Paper(以及其他基于 Spigot 的分叉),包括 Mojang 切换到未混淆的服务器 jar 包以及自 26.1 起采用的基于年份的版本编号。一些较新的功能(1.21.6+ 的游戏模式切换数据包处理,以及移动方向组合键触发器)依赖于反射目标,无法针对每个版本在实时服务器上进行验证——如果在你的设置中某些功能未按预期工作,请提交包含你的服务器版本和任何控制台输出的问题报告。
Allows to use Hotkey F3 + N (and the F3+F4 Gamemode Switcher) for anyone that has /gamemode permissions.
For Versions pre 1.21.5 use the original here:
Tested on a Paper Server 1.21.11. Other serversoftware might work, too. (please report bugs)
Introduction
If you press F3 + N or use the gamemode switcher (F3 + F4) on a Bukkit server with permissions for /gamemode, but without op, your Minecraft client will not allow you to actually change your gamemode. This is because the minecraft client requires to know that you are a server operator. This plugin was built solely to mitigate that issue.
As of Minecraft 1.21.6, the gamemode switcher additionally sends its own dedicated packet that the server checks against the player's real op level, completely independent of the client-side unlock above. This plugin intercepts that packet as well and performs the switch itself, so F3+N/F3+F4 keeps working exactly as before on 1.21.6 and newer (see PaperMC/Paper#13489 - there is currently no official Paper API for this).
Usage
Dropping the downloaded jar file in your plugins folder should be enough for everything to work. The plugin will attempt to use ProtocolLib if you have it installed, but should work without it as well.
If you don't want everyone with access to /gamemode to also have access to those debug hotkeys, you can customize that behavior by setting "enable-permission-check" to "true" in the "config.yml" of this plugin. With this enabled, you should be able to give people the f3nperm.use permission to give access to the hotkeys.
Custom gamemode actions
Instead of just switching gamemode, you can configure a command to run for any of the four F3+N options (Survival/Creative/Adventure/Spectator) - the switch itself is skipped when a command is set. Each mode can require its own extra permission (on top of the base one), and commands support both a %player% placeholder and, if PlaceholderAPI is installed, its full placeholder set. Commands are run from console, so they can do things a normal player couldn't (e.g. /time set day).
This is configured under gamemode-actions in config.yml and is opt-in - by default, nothing changes and F3+N behaves exactly as it always has.
Key combos
For more advanced setups, F3+N (or, in principle, any other supported action) can be turned into a one-shot "arm" for a completely different action instead. Selecting a mode arms a switch; the next matching action from that player (dropping an item, swapping hands, sneaking, sprinting, leaving a bed, jumping on a saddled horse, or - experimentally - a movement direction) "consumes" it and runs a command, optionally cancelling the action it hijacked, before disarming again. Any recognized action can serve as either the arming or the consuming trigger, so combos aren't limited to the four gamemode buttons.
This is configured under key-combos in config.yml, disabled by default, and fully independent from the custom gamemode actions above (though the two interact: a mode used to arm a combo takes priority over any command configured for it).
Supported versions
Supports Paper (and likely other Spigot-based forks) from 1.9 through the current 26.x releases, including Mojang's switch to unobfuscated server jars and year-based versioning as of 26.1. Some newer features (the 1.21.6+ gamemode-switch packet handling, and the movement-direction key combo trigger) rely on reflection targets that couldn't be verified against a live server for every version - if something doesn't work as expected on your setup, please open an issue with your server version and any console output.
评论 0
登录后参与评分
还没有评论,来抢沙发吧