From 7b986cb6da345dca3be30c244af1791e92cb10bc Mon Sep 17 00:00:00 2001 From: Ali Date: Mon, 9 Dec 2024 22:33:30 +0300 Subject: [PATCH] fix issue in NMS class fetching --- .../commands/bukkit/brigadier/BukkitVersion.java | 2 +- .../commands/bukkit/brigadier/ReflectionCommodore.java | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/BukkitVersion.java b/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/BukkitVersion.java index a6324b19..b04e04fd 100644 --- a/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/BukkitVersion.java +++ b/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/BukkitVersion.java @@ -121,7 +121,7 @@ public static int patchNumber() { @SneakyThrows public static @NotNull Class findNmsClass(@NotNull String name) { if (supports(1, UNVERSION_NMS)) { - return Class.forName("net.minecraft.server." + name); + return Class.forName("net.minecraft." + name); } int dotIndex = name.lastIndexOf('.'); if (dotIndex == -1) diff --git a/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/ReflectionCommodore.java b/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/ReflectionCommodore.java index 237f84d5..b9f5c93c 100644 --- a/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/ReflectionCommodore.java +++ b/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/ReflectionCommodore.java @@ -64,14 +64,8 @@ final class ReflectionCommodore extends Commodore { final Class minecraftServer; final Class commandDispatcher; - if (BukkitVersion.supports(1, 16)) { - minecraftServer = BukkitVersion.findNmsClass("server.MinecraftServer"); - commandDispatcher = BukkitVersion.findNmsClass("commands.CommandDispatcher"); - } else { - minecraftServer = BukkitVersion.findNmsClass("MinecraftServer"); - commandDispatcher = BukkitVersion.findNmsClass("CommandDispatcher"); - } - + minecraftServer = BukkitVersion.findNmsClass("server.MinecraftServer"); + commandDispatcher = BukkitVersion.findNmsClass("commands.CommandDispatcher"); Class craftServer = BukkitVersion.findOcbClass("CraftServer"); CONSOLE_FIELD = craftServer.getDeclaredField("console"); CONSOLE_FIELD.setAccessible(true);