mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-10 18:37:57 +01:00
Catch NullPointerException thrown by some server class loaders
Affects issues: - Fixed #2074
This commit is contained in:
parent
b3674dfbda
commit
5dc3b39741
@ -38,7 +38,7 @@ public class ReflectiveLevelEntityPlayerLatencyFieldMethod implements PingMethod
|
||||
private static void setMethods() throws IllegalAccessException, NoSuchFieldException, NoSuchMethodException, ClassNotFoundException {
|
||||
MethodHandle[] methodHandles = PingMethodReflection.getMethods(
|
||||
Reflection.getCraftBukkitClass("entity.CraftPlayer"),
|
||||
Class.forName("net.minecraft.server.level.EntityPlayer"),
|
||||
getEntityPlayer(),
|
||||
"getHandle",
|
||||
"latency"
|
||||
);
|
||||
@ -46,6 +46,14 @@ public class ReflectiveLevelEntityPlayerLatencyFieldMethod implements PingMethod
|
||||
pingField = methodHandles[1];
|
||||
}
|
||||
|
||||
private static Class<?> getEntityPlayer() throws ClassNotFoundException {
|
||||
try {
|
||||
return Class.forName("net.minecraft.server.level.EntityPlayer");
|
||||
} catch (NullPointerException classLoaderError) {
|
||||
throw new ClassNotFoundException("net.minecraft.server.level.EntityPlayer");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
try {
|
||||
|
@ -38,7 +38,7 @@ public class ReflectiveUnmappedLatencyFieldMethod implements PingMethod {
|
||||
private static void setMethods() throws IllegalAccessException, NoSuchFieldException, NoSuchMethodException, ClassNotFoundException {
|
||||
MethodHandle[] methodHandles = PingMethodReflection.getMethods(
|
||||
Reflection.getCraftBukkitClass("entity.CraftPlayer"),
|
||||
Class.forName("net.minecraft.server.level.EntityPlayer"),
|
||||
getEntityPlayer(),
|
||||
"getHandle",
|
||||
"e"
|
||||
);
|
||||
@ -46,6 +46,14 @@ public class ReflectiveUnmappedLatencyFieldMethod implements PingMethod {
|
||||
pingField = methodHandles[1];
|
||||
}
|
||||
|
||||
private static Class<?> getEntityPlayer() throws ClassNotFoundException {
|
||||
try {
|
||||
return Class.forName("net.minecraft.server.level.EntityPlayer");
|
||||
} catch (NullPointerException classLoaderError) {
|
||||
throw new ClassNotFoundException("net.minecraft.server.level.EntityPlayer");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
try {
|
||||
|
@ -140,7 +140,7 @@ public final class Reflection {
|
||||
private static Class<?> getCanonicalClass(String canonicalName) {
|
||||
try {
|
||||
return Class.forName(canonicalName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
} catch (ClassNotFoundException | NullPointerException e) {
|
||||
throw new IllegalArgumentException("Cannot find " + canonicalName, e);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user