Skip to content

Commit

Permalink
Properly add 1.20.4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Test-Account666 committed Dec 30, 2023
1 parent 80213d9 commit 8e08631
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/main/java/com/rylinaux/plugman/util/BukkitCommandWrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,22 @@ public void wrap(Command command, String alias) {
}

if (this.bField == null) try {
this.bField = Class.forName("net.minecraft.commands.CommandDispatcher").getDeclaredField("g");
this.bField = Class.forName("net.minecraft.server." + this.nmsVersion + ".CommandDispatcher").getDeclaredField("b");
this.bField.setAccessible(true);
} catch (NoSuchFieldException | ClassNotFoundException e) {
e.printStackTrace();
return;
if (this.bField == null) try {
Class<?> commandDispatcherClass = Class.forName("net.minecraft.commands.CommandDispatcher");
if (commandDispatcherClass.getDeclaredField("g").getType() == com.mojang.brigadier.CommandDispatcher.class) {
this.bField = commandDispatcherClass.getDeclaredField("g");
} else {
this.bField = commandDispatcherClass.getDeclaredField("h");
}
this.bField.setAccessible(true);
} catch (NoSuchFieldException | ClassNotFoundException ex) {
ex.addSuppressed(e);
e.printStackTrace();
return;
}
}

com.mojang.brigadier.CommandDispatcher b;
Expand Down

0 comments on commit 8e08631

Please sign in to comment.