Skip to content

Commit

Permalink
rollback changes
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Jan 6, 2025
1 parent 035c0a4 commit 2d80e99
Showing 1 changed file with 1 addition and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand All @@ -25,9 +24,8 @@ public final class BukkitCommandWrap {
private final boolean nmsVersioning;
private String nmsVersion;
private Class minecraftServerClass;
private Method aMethod, getServerMethod, registerMethod, syncCommandsMethod, removeCommandMethod;
private Method getServerMethod, syncCommandsMethod, removeCommandMethod;
private Field bField, vanillaCommandDispatcherField, commandMapField, knownCommandsField;
private Constructor bukkitcommandWrapperConstructor;

public BukkitCommandWrap() {
String prefix = getCraftBukkitPrefix();
Expand Down Expand Up @@ -264,58 +262,4 @@ private boolean resolveBField() {
}
}

private boolean resolveRegisterCommandMethod() {
if (this.registerMethod != null) return true;
try {
this.registerMethod = Class.forName(getCraftBukkitPrefix("command.BukkitCommandWrapper"))
.getMethod("register", CommandDispatcher.class, String.class);
this.registerMethod.setAccessible(true);
return true;
} catch (NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace();
return false;
}
}

private Object getAInstance(Object commandDispatcher) {
try {
return this.aMethod.invoke(commandDispatcher);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return null;
}
}

private @Nullable Object getCommandWrapper(Command command) {
try {
return this.bukkitcommandWrapperConstructor.newInstance(Bukkit.getServer(), command);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return null;
}
}

private boolean resolveBukkitCmdWrapperConstructor() {
if (this.bukkitcommandWrapperConstructor != null) return true;
try {
this.bukkitcommandWrapperConstructor = Class.forName(getCraftBukkitPrefix("command.BukkitCommandWrapper")).getDeclaredConstructor(Class.forName("org.bukkit.craftbukkit." + this.nmsVersion + ".CraftServer"), Command.class);
this.bukkitcommandWrapperConstructor.setAccessible(true);
return true;
} catch (NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace();
return false;
}
}

private boolean resolveAMethod(Object commandDispatcher) {
if (this.aMethod != null) return true;
try {
this.aMethod = commandDispatcher.getClass().getDeclaredMethod("a");
this.aMethod.setAccessible(true);
return true;
} catch (NoSuchMethodException e) {
e.printStackTrace();
return false;
}
}
}

0 comments on commit 2d80e99

Please sign in to comment.