From da7f8ea3b6788ef65f9ed53dc964c6d82f7c0064 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 15 Mar 2023 16:21:15 +0100 Subject: [PATCH] Be more safe --- .../viaversion/bukkit/listeners/JoinListener.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/JoinListener.java b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/JoinListener.java index 2f395ae8f..04a52ec3f 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/JoinListener.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/JoinListener.java @@ -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; } }