Set libraryLoader to null & clear classes in PluginClassLoader (bukkit)
This commit is contained in:
parent
870e2bcae5
commit
fd69f74b22
5 changed files with 23 additions and 18 deletions
|
|
@ -15,8 +15,8 @@ import java.lang.reflect.Proxy;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import net.frankheijden.serverutils.common.utils.ReflectionUtils;
|
||||
import net.frankheijden.serverutils.velocity.ServerUtils;
|
||||
import net.frankheijden.serverutils.velocity.utils.ReflectionUtils;
|
||||
|
||||
public class RVelocityCommandManager {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
package net.frankheijden.serverutils.velocity.utils;
|
||||
|
||||
import dev.frankheijden.minecraftreflection.Reflection;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.function.Consumer;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
public class ReflectionUtils {
|
||||
|
||||
private static MethodHandle theUnsafeFieldMethodHandle;
|
||||
|
||||
static {
|
||||
try {
|
||||
theUnsafeFieldMethodHandle = MethodHandles.lookup().unreflectGetter(Reflection.getAccessibleField(
|
||||
Unsafe.class,
|
||||
"theUnsafe"
|
||||
));
|
||||
} catch (Throwable th) {
|
||||
th.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private ReflectionUtils() {}
|
||||
|
||||
/**
|
||||
* Performs a privileged action while accessing {@link Unsafe}.
|
||||
*/
|
||||
public static void doPrivilegedWithUnsafe(Consumer<Unsafe> privilegedAction) {
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
try {
|
||||
privilegedAction.accept((Unsafe) theUnsafeFieldMethodHandle.invoke());
|
||||
} catch (Throwable th) {
|
||||
th.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue