From 75f2382f0e0b79f4dfbb1f383221fc48eb87ec4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E9=98=94?= <1520622465@qq.com> Date: Tue, 19 May 2026 19:56:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(fake-op):=20=E4=BF=AE=E5=A4=8D=2026.1+=20?= =?UTF-8?q?=E9=9D=9E=E6=B7=B7=E6=B7=86=E6=9C=8D=E5=8A=A1=E7=AB=AF=20Entity?= =?UTF-8?q?Player=20=E7=B1=BB=E6=9F=A5=E6=89=BE=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 26.1+ 非混淆服务端的 Spigot/Paper 映射表为空,nmsClass("EntityPlayer") 会拼成 不存在的 net.minecraft.EntityPlayer。改为在 isUnobfuscated 分支直接使用 Mojang Deobf 全限定名 net.minecraft.server.level.ServerPlayer。 修复 Paper 26.1.2 上调用 dispatchCommandAsOp 抛 ClassNotFoundException 的问题。 --- .../main/kotlin/taboolib/expansion/PlayerFakeOpNMSImpl.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/module/bukkit/bukkit-fake-op/src/main/kotlin/taboolib/expansion/PlayerFakeOpNMSImpl.kt b/module/bukkit/bukkit-fake-op/src/main/kotlin/taboolib/expansion/PlayerFakeOpNMSImpl.kt index d6949d41e..078081a73 100644 --- a/module/bukkit/bukkit-fake-op/src/main/kotlin/taboolib/expansion/PlayerFakeOpNMSImpl.kt +++ b/module/bukkit/bukkit-fake-op/src/main/kotlin/taboolib/expansion/PlayerFakeOpNMSImpl.kt @@ -17,6 +17,7 @@ import org.bukkit.craftbukkit.entity.CraftPlayer import org.bukkit.entity.Player import org.bukkit.permissions.Permission import taboolib.common.util.unsafeLazy +import taboolib.module.nms.MinecraftVersion import taboolib.module.nms.nmsClass import java.lang.reflect.Constructor import java.lang.reflect.Method @@ -153,7 +154,12 @@ class PlayerFakeOpNMSImpl : PlayerFakeOpNMS() { private lateinit var tempCraftPlayer: CraftPlayer init { - val entityPlayerClass = nmsClass("EntityPlayer") + // 26.1+ 非混淆服务端,Spigot/Paper 映射表为空,直接使用 Mojang Deobf 全限定名 + val entityPlayerClass = if (MinecraftVersion.isUnobfuscated) { + Class.forName("net.minecraft.server.level.ServerPlayer") + } else { + nmsClass("EntityPlayer") + } // Generate the bytecode of the new class, which extends CraftPlayer val dynamicType = ByteBuddy() .subclass(CraftPlayer::class.java)