From ae522264d60385f5edcf1d29ca16092a8a49a867 Mon Sep 17 00:00:00 2001 From: Ali Date: Mon, 9 Dec 2024 21:24:36 +0300 Subject: [PATCH 1/4] fix issue in NMS class fetching --- .../revxrsal/commands/bukkit/brigadier/BukkitVersion.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 d4a5de18..a6324b19 100644 --- a/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/BukkitVersion.java +++ b/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/BukkitVersion.java @@ -123,7 +123,10 @@ public static int patchNumber() { if (supports(1, UNVERSION_NMS)) { return Class.forName("net.minecraft.server." + name); } - return Class.forName("net.minecraft.server." + VERSION + "." + name); + int dotIndex = name.lastIndexOf('.'); + if (dotIndex == -1) + return Class.forName("net.minecraft.server." + VERSION + "." + name); + return Class.forName("net.minecraft.server." + VERSION + "." + name.substring(dotIndex + 1)); } /** From 7b986cb6da345dca3be30c244af1791e92cb10bc Mon Sep 17 00:00:00 2001 From: Ali Date: Mon, 9 Dec 2024 22:33:30 +0300 Subject: [PATCH 2/4] 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); From 4bfff015b3e605a49730724dad647ca1f4589d0f Mon Sep 17 00:00:00 2001 From: Ali Date: Sat, 14 Dec 2024 14:06:08 +0300 Subject: [PATCH 3/4] fix issue in NMS class fetching --- .../commands/bukkit/brigadier/MinecraftArgumentType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/MinecraftArgumentType.java b/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/MinecraftArgumentType.java index 05603426..794e26f3 100644 --- a/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/MinecraftArgumentType.java +++ b/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/MinecraftArgumentType.java @@ -373,7 +373,7 @@ public boolean requiresParameters() { private static @Nullable Class resolveArgumentClass(String name) { try { - if (BukkitVersion.supports(1, 16)) { + if (BukkitVersion.supports(1, 17)) { try { return BukkitVersion.findNmsClass("commands.arguments." + name); } catch (Throwable ignored) { From a14d364e4e68d7e90aa51d811fa4d8b84cc8e246 Mon Sep 17 00:00:00 2001 From: Ali Date: Sat, 14 Dec 2024 14:06:19 +0300 Subject: [PATCH 4/4] bump version (v3) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e2a2748d..bd9095d2 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ subprojects { apply plugin: "maven-publish" group = "io.github.revxrsal" - version = "3.3.2" + version = "3.3.3" if (name != "velocity") { sourceCompatibility = 1.8