Be more safe

This commit is contained in:
Nassim Jahnke 2023-03-15 16:21:15 +01:00
parent 81c4e530e9
commit da7f8ea3b6
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B

View File

@ -49,9 +49,6 @@ public class JoinListener implements Listener {
conn = findField(gh.getReturnType(), "PlayerConnection", "ServerGamePacketListenerImpl");
nm = findField(conn.getType(), "NetworkManager", "Connection");
ch = findField(nm.getType(), "Channel");
if (!Modifier.isPublic(nm.getModifiers())) {
nm.setAccessible(true);
}
} catch (NoSuchMethodException | NoSuchFieldException | ClassNotFoundException e) {
Via.getPlatform().getLogger().log(
Level.WARNING,
@ -70,6 +67,9 @@ public class JoinListener implements Listener {
for (Field field : cl.getDeclaredFields()) {
for (String type : types) {
if (field.getType().getSimpleName().equals(type)) {
if (!Modifier.isPublic(field.getModifiers())) {
field.setAccessible(true);
}
return field;
}
}