forked from Upstream/CommandPanels
3.19.1.7
This commit is contained in:
parent
0f0d5dca84
commit
5dee0f8a93
@ -1,4 +1,4 @@
|
|||||||
version: 3.19.1.6
|
version: 3.19.1.7
|
||||||
main: me.rockyhawk.commandpanels.CommandPanels
|
main: me.rockyhawk.commandpanels.CommandPanels
|
||||||
name: CommandPanels
|
name: CommandPanels
|
||||||
author: RockyHawk
|
author: RockyHawk
|
||||||
|
@ -137,20 +137,33 @@ public class GetCustomHeads {
|
|||||||
Field profileField;
|
Field profileField;
|
||||||
Method setProfileMethod = null;
|
Method setProfileMethod = null;
|
||||||
try {
|
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");
|
profileField = headMeta.getClass().getDeclaredField("profile");
|
||||||
|
Field serializedProfileField = headMeta.getClass().getDeclaredField("serializedProfile");
|
||||||
|
|
||||||
profileField.setAccessible(true);
|
profileField.setAccessible(true);
|
||||||
|
serializedProfileField.setAccessible(true);
|
||||||
|
|
||||||
profileField.set(headMeta, profile);
|
profileField.set(headMeta, profile);
|
||||||
|
serializedProfileField.set(headMeta, profile); // Assuming serializedProfile is of the same type
|
||||||
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
|
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
|
||||||
try {
|
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);
|
setProfileMethod = headMeta.getClass().getDeclaredMethod("setProfile", GameProfile.class);
|
||||||
} catch (NoSuchMethodException ignore) {}
|
} catch (NoSuchMethodException ignore) {}
|
||||||
} catch (SecurityException ignored) {}
|
} catch (SecurityException ignored) {}
|
||||||
try {
|
try {
|
||||||
if (setProfileMethod == null) {
|
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 = headMeta.getClass().getDeclaredField("profile");
|
||||||
profileField.setAccessible(true);
|
profileField.setAccessible(true);
|
||||||
profileField.set(headMeta, profile);
|
profileField.set(headMeta, profile);
|
||||||
} else {
|
} else {
|
||||||
|
// Use the 'setProfile' method if it was found
|
||||||
setProfileMethod.setAccessible(true);
|
setProfileMethod.setAccessible(true);
|
||||||
setProfileMethod.invoke(headMeta, profile);
|
setProfileMethod.invoke(headMeta, profile);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user