本模组的开发动机如下:
- 修改不活跃玩家(NBT)数据
- 导出库存(以及末影箱)内容
- 模拟与该玩家交互,以便在模组缺乏管理功能或权限时,无需直接操作 NBT 数据
该模组的工作原理如下:
-
让服务器检查实际加入服务器的玩家(而非其冒充的对象)是否有权限加入。
- 因此,原始玩家无法利用此功能绕过封禁或其他通常禁止加入的限制。
- 它还有一个有益的效果:在启用白名单的服务器上,你无需将你要冒充的玩家加入白名单。
-
在验证你有资格加入后,它会检查你是否正在尝试冒充他人(通过你在上次登录时使用的 /uuidimpersonate impersonate <player|uuid> 命令)。
/uuidimpersonate impersonate <player|uuid> 命令受到“未处于冒充状态”和“拥有 OP 等级 4(所有者)”两个条件的限制。
- 配套的
/uuidimpersonate clear 命令仅受“处于冒充状态”这一条件限制(因此无论你的权限如何,都可以停止冒充行为)。
- 如果由于某些原因
/uuidimpersonate clear 命令不起作用,冒充列表是非持久化的,因此你也可以重启服务器以清除所有冒充记录。
-
如果是的话,它会将原始的 GameProfile 替换为你试图冒充的玩家(生成的)GameProfile。
就是这么简单。不过,由于 GameProfile 的名称存在硬编码的 16 个字符限制,我不得不注入到诸如 ServerPlayerEntity#getPlayerListName(用于标签页列表)和 PlayerEntity#getName(用于聊天消息及其他场景)等各种位置,以获取我想要显示的名称(“冒充者名称 (被原身份冒充)”),从而在模拟玩家身份时确保对其他玩家的透明度。
尽管如此,这仍不完美。例如,我观察到某些模组(如 Fabricord)会直接检查 GameProfile 的名称(而非通过 PlayerEntity#getName),因此该玩家加入世界时只会显示为普通状态,而不会带有表明其正在冒充他人的描述信息(看起来就像是一个正常的非冒充加入)。
The motivation behind this mod was to:
- Modify Player (NBT) Data of Inactive Players
- Dump Inventories (and Ender Chests)
- Interact with mods as though you are the player so you don't need to resort to NBT manipulation if the mod does not have admin functionality/management
The way the mod functions is by
- Letting the server check if the actual player joining (not the person they are impersonating) is allowed to join the server
- So the original player cannot use this to bypass bans or other things that would inhibit joining ordinarily
- It also has the helpful side effect of making it so (on a whitelisted server) you don't need to whitelist the player you are impersonating.
- Then after it verifies you can join, it checks if you are trying to impersonate someone (via the
/uuidimpersonate impersonate <player|uuid> command you used on the previous login)
- The
/uuidimpersonate impersonate <player|uuid> command is guarded by both a not impersonated predicate and a has OP level 4 (owner) predicate.
- The accompanying
/uuidimpersonate clear command is guarded by just an impersonated predicate (so no matter what permissions you have, you can stop the impersonation)
- If for some reason the
/uuidimpersonate clear command is not working, the impersonation list is not persistent so you can also restart the server to clear ALL impersonations.
- If you are then it swaps out the original GameProfile with the player you are trying to impersonate's (generated) GameProfile.
It is that simple, however, as there is a hardcoded 16 character limit for the GameProfile's name, I had to inject into various places like the ServerPlayerEntity#getPlayerListName (for tab list) and the PlayerEntity#getName (for chat messages and others) functions to get the name I wanted to display ("ImpersonatedName (Impersonated by OriginalName)") while impersonating which ensures transparency for other players.
This is still not perfect though, for instance, I observed that some mods (like Fabricord) check the GameProfile name directly (instead of PlayerEntity#getName) and thus it will only appear as though the (Impersonated) player joined the world without the descriptor of who is impersonating them (looks like a normal non-impersonated join)
评论 0
登录后参与评分
还没有评论,来抢沙发吧