mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2026-01-06 15:42:03 +00:00
Fix Velocity modern forwarding with 1.19
Fixes https://github.com/GeyserMC/Geyser/issues/3039, #321
This commit is contained in:
@@ -255,6 +255,25 @@ public final class ReflectionUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of a boolean field. This method first makes the field accessible and then gets
|
||||
* the value.<br> This method will return false instead of throwing an exception, but it'll log
|
||||
* the stacktrace to the console.
|
||||
*
|
||||
* @param instance the instance to get the value from
|
||||
* @param field the field to get the value from
|
||||
* @return the value when succeeded, otherwise null
|
||||
*/
|
||||
public static boolean getBooleanValue(Object instance, Field field) {
|
||||
makeAccessible(field);
|
||||
try {
|
||||
return field.getBoolean(instance);
|
||||
} catch (IllegalArgumentException | IllegalAccessException exception) {
|
||||
exception.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the given field by finding the field and then get the value of it.
|
||||
*
|
||||
@@ -300,6 +319,16 @@ public final class ReflectionUtils {
|
||||
return getCastedValue(null, field);
|
||||
}
|
||||
|
||||
public static boolean castedStaticBooleanValue(Field field) {
|
||||
makeAccessible(field);
|
||||
try {
|
||||
return field.getBoolean(null);
|
||||
} catch (IllegalArgumentException | IllegalAccessException exception) {
|
||||
exception.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of a field. This method make the field accessible and then sets the value.<br>
|
||||
* This method doesn't throw an exception when failed, but it'll log the error to the console.
|
||||
|
||||
Reference in New Issue
Block a user