diff --git a/resource/plugin.yml b/resource/plugin.yml index 910ea9c..3eeb21c 100644 --- a/resource/plugin.yml +++ b/resource/plugin.yml @@ -1,4 +1,4 @@ -version: 3.19.1.6 +version: 3.19.1.7 main: me.rockyhawk.commandpanels.CommandPanels name: CommandPanels author: RockyHawk diff --git a/src/me/rockyhawk/commandpanels/classresources/GetCustomHeads.java b/src/me/rockyhawk/commandpanels/classresources/GetCustomHeads.java index 02be3ef..fd0076c 100644 --- a/src/me/rockyhawk/commandpanels/classresources/GetCustomHeads.java +++ b/src/me/rockyhawk/commandpanels/classresources/GetCustomHeads.java @@ -137,20 +137,33 @@ public class GetCustomHeads { Field profileField; Method setProfileMethod = null; try { + // Attempt to access the 'profile' field directly + // Also writes to 'serializedProfile' field as one cannot be null while the other is not + // This block is mainly for 1.20.2+ versions profileField = headMeta.getClass().getDeclaredField("profile"); + Field serializedProfileField = headMeta.getClass().getDeclaredField("serializedProfile"); + profileField.setAccessible(true); + serializedProfileField.setAccessible(true); + profileField.set(headMeta, profile); + serializedProfileField.set(headMeta, profile); // Assuming serializedProfile is of the same type } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) { try { + // This block covers versions that have a 'setProfile' method instead of direct field access + // Likely for versions prior to 1.20.2 setProfileMethod = headMeta.getClass().getDeclaredMethod("setProfile", GameProfile.class); } catch (NoSuchMethodException ignore) {} } catch (SecurityException ignored) {} try { if (setProfileMethod == null) { + // Attempt to access the 'profile' field directly + // This block is a generic fallback for versions lacking the 'setProfile' method profileField = headMeta.getClass().getDeclaredField("profile"); profileField.setAccessible(true); profileField.set(headMeta, profile); } else { + // Use the 'setProfile' method if it was found setProfileMethod.setAccessible(true); setProfileMethod.invoke(headMeta, profile); }