Universal Perms
你是否曾在服务器上遇到需要安装不提供命令权限节点的模组的情况?
是否曾因为某个模组不允许你屏蔽其根命令的访问权限而困扰(说的就是你,LuckPerms)?
这个模组解决了这个问题,以及更多问题。
使用方法
首先,你需要安装另一个模组来为你管理权限。我推荐使用 LuckPerms,但 Player Roles 也能很好地工作。
在使用此模组之前,建议先登录一次,以便 LuckPerms 能够识别所有节点,这样你就可以在 Web 编辑器中看到它们了。
现在我们来设置权限。此模组为每个命令提供两个权限节点,一个以 universal_perms:use/ 开头,另一个以 universal_perms:view/ 开头。
如果设置了 use 权限,它将覆盖命令的正常要求,使任何将其设置为 true 的用户能够使用该命令,同时拒绝任何将其设置为 false 的用户的访问。
view 权限很有用,如果你只想隐藏自动补全功能,但仍允许宏或其他功能的运作。
对于所有原版命令(是的,甚至包括 execute),子命令和参数会显示为各自的子节点。例如,要禁用 /help <command> 的使用,但不禁用 /help,你可以使用 universal_perms:use/help.command 节点。然而,这对于使用自己子命令系统的模组不起作用(为什么是 LuckPerms?)。
你还可以通过使用 universal_perms:use 和 universal_perms:view 作为权限节点来影响所有命令,但我并不觉得这样做有什么好处。
杂项权限
此模组还添加了一些非命令但仍使用权限检查的权限节点。
- (26.2 版本之前)
universal_perms.misc.selector 允许使用如 @a 和 @e 这样的选择器。在原版的游戏中,这需要权限级别 2。
(26.2 版本之后,这由 Minecraft 添加为 minecraft:commands/entity_selectors)
universal_perms:misc/query_block_nbt 允许客户端在使用 F3 + I 时从服务器查询一些方块数据。在原版的游戏中,这需要权限级别 2。
universal_perms:misc/query_entity_nbt 与上述相同,但是针对实体。
universal_perms:misc/update_difficulty 允许更改暂停菜单中的难度。
universal_perms:misc/update_difficulty_lock 允许更改难度锁定状态,默认为 universal_perms:misc/update_difficulty。
universal_perms:misc/use_admin_blocks 如果玩家处于创造模式,则允许通过 Minecraft 的 isCreativeLevelTwoOp 检查。
这主要用于管理员工具,如命令方块和调试棒。
- (1.21.11+ 版本)
universal_perms:misc/gamemode_switcher 导致服务器接受玩家的切换游戏模式请求。
客户端必须通过模组或提高的权限级别额外意识到这种权力。
还有一个 universal_perms:misc/forced_permission_level 元权限,可以设置为给予玩家一个原版的权限级别。
权限级别用作此模组添加的所有检查的默认值。它们也被发送到客户端,并在客户端进行某些功能(如游戏模式切换器)的检查。
它们应该涵盖所有尚未被覆盖的权限检查。
关于权限语法
随着 Fabric API 中引入权限 API,UniversalPerms 权限的语法发生了变化。
所有权限节点现在都以标识符的形式存在,正如 Minecraft 中其他地方所使用的形式一样。
这一变化发生在 26.2 更新期间。在此版本之前的版本中,将所有权限节点中的 : 和 / 替换为 .。
另外请注意,LuckPerms 对标识符权限名称的解释有些奇怪:LuckPerms 会将 : 替换为 .。
这意味着例如 universal_perms:use/help 会变成 universal_perms.use/help。
陷阱和怪癖
- 在发送客户端可用命令时,
view 权限比 use 权限更具优势。这意味着你可以创建命令可见但不可用的情况。
- 当目标被禁止/隐藏但命令本身可见时,别名命令的行为会很奇怪。以下是一些需要注意的原版别名的列表:
tell 和 w 重定向到 msg
tp 重定向到 teleport
xp 重定向到 experiance
tm 重定向到 teammsg
- 如果其他模组在其命令通常添加的时间点之后才添加它们的命令,或在 Universal Perms 之后修改它们的要求,则与其他模组的兼容性无法保证。
- 许多杂项权限在没有客户端修改或更高的报告权限级别的情况下无法正常工作。
Universal Perms
Have you ever had to install mod that doesn't provide permission nodes for its commands on a server?
Have you had trouble with a mod not allowing you to block access to their root command (looking at you luckperms)?
Well, this mod fixes that, and more.
Usage
First, you'll need to install another mod to manage permissions for you. I recommend luckperms, but player roles should work just as well.
Before you start using this mod, I recommend logging in once so that luckperms gets to know all the nodes, so you can see them in the web editor.
Now we get to setting up the permissions. This mod provides two permissions for each command, one beginning with universal_perms:use/ and one with universal_perms:view/.
If set, the use permissions overrides the commands normal requirements making anyone with it set to true able to use the command while denying access to anyone with it set to false.
The view permissions is useful if you just want to hide the autocompletion, but still allow functionality for macros or something else.
For all vanilla commands (yes, even execute), subcommands and arguments are visible as their own sub-nodes, for example, to disable the use of /help <command>, but not /help you would use the universal_perms:use/help.command node. However, this doesn't work with mods that use their own subcommand system (why luckperms?).
You can even affect all commands by using universal_perms:use and universal_perms:view as permission nodes, but I don't really see the benefit in that.
Misc Permissions
This mod also adds some permission nodes for things that aren't commands, but still use permission checks.
- (before 26.2)
universal_perms.misc.selector allows the use of selectors like @a and @e. In vanilla this requires permission level 2.
(after 26.2, this is now added by Minecraft as minecraft:commands/entity_selectors)
universal_perms:misc/query_block_nbt allows clients to query some block data from the server when using F3 + I. In vanilla this requires permission level 2
universal_perms:misc/query_entity_nbt is the same as above but for entities
universal_perms:misc/update_difficulty allows changing the difficulty in the pause menu.
universal_perms:misc/update_difficulty_lock allows changing the difficulty lock status, defaults to universal_perms:misc/update_difficulty
universal_perms:misc/use_admin_blocks allows minecrafts isCreativeLevelTwoOp check to pass if the player is in creative mode.
This is mostly used for admin tools like command blocks and debug sticks
- (1.21.11+)
universal_perms:misc/gamemode_switcher causes the server to accept gamemode switching by players.
The client must additionally be made aware of this power through a mod or raised permission level.
There's also a universal_perms:misc/forced_permission_level meta permission that can be set to give a player a vanilla permission level.
Permission levels are used as defaults for all checks this mod adds. They are also sent to the client and are checked there for certain features like the gamemode switcher
They should cover all permissions checks that aren't already covered.
Note on permission syntax
With the introduction of a permissions api into Fabric API, the syntax of UniversalPerms permissions has changed.
All permission nodes are now in the form of identifiers, as use elsewhere in Minecraft.
This change occurred during the 26.2 update. On versions before that, replace the : and / in all permission nodes with a ..
Also note that LuckPerms interprets identifier permission names somewhat weirdly: LuckPerms replaces the : with a ..
This means that for example universal_perms:use/help becomes universal_perms.use/help.
Pitfalls and Quirks
- The
view permission has power over the use one when it comes to sending the client the available commands. This means that you can create scenarios where a command is visible, but unusable.
- Commands that are aliases to other commands behave weirdly when their target is forbidden/hidden, but they are visible. Here is a list of vanilla aliases to watch out for:
tell and w redirect to msg
tp redirects to teleport
xp redirects to experiance
tm redirects to teammsg
- Compatibility with other mods isn't guaranteed if the other mods add their commands later than usual or mess with their requirements after universal perms does.
- Many of the misc permissions don't work without modifications to the client, or higher reported permission levels.
评论 0
登录后参与评分
还没有评论,来抢沙发吧