Skip to content

Commit 0182506

Browse files
Fix SkullBuilder not setting serializedProfile in SkullMeta
1 parent e660c26 commit 0182506

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

inventoryaccess/inventory-access/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@
3131
<version>1.16.4-R0.1-SNAPSHOT</version>
3232
<scope>provided</scope>
3333
</dependency>
34+
<dependency>
35+
<groupId>com.mojang</groupId>
36+
<artifactId>authlib</artifactId>
37+
<version>1.5.21</version>
38+
<scope>provided</scope>
39+
<exclusions>
40+
<exclusion>
41+
<groupId>*</groupId>
42+
<artifactId>*</artifactId>
43+
</exclusion>
44+
</exclusions>
45+
</dependency>
3446
<dependency>
3547
<groupId>net.kyori</groupId>
3648
<artifactId>adventure-api</artifactId>

inventoryaccess/inventory-access/src/main/java/xyz/xenondevs/inventoryaccess/util/ReflectionRegistry.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package xyz.xenondevs.inventoryaccess.util;
22

3+
import com.mojang.authlib.GameProfile;
4+
35
import java.lang.reflect.Field;
6+
import java.lang.reflect.Method;
47

58
import static xyz.xenondevs.inventoryaccess.util.ReflectionUtils.*;
69

@@ -13,12 +16,15 @@ public class ReflectionRegistry {
1316
public static final String BUKKIT_PACKAGE_PATH = "org.bukkit.";
1417

1518
// Classes
19+
public static final Class<?> PLUGIN_CLASS_LOADER_CLASS = getBukkitClass("plugin.java.PluginClassLoader");
1620
public static final Class<?> CB_CRAFT_META_SKULL_CLASS = getCBClass("inventory.CraftMetaSkull");
21+
public static final Class<?> CB_CRAFT_META_ITEM_CLASS = getCBClass("inventory.CraftMetaItem");
22+
23+
// Methods
24+
public static final Method CB_CRAFT_META_SKULL_SET_PROFILE_METHOD = getMethod(CB_CRAFT_META_SKULL_CLASS, true, "setProfile", GameProfile.class);
25+
1726
// Fields
18-
public static final Field CB_CRAFT_META_SKULL_PROFILE_FIELD = getField(CB_CRAFT_META_SKULL_CLASS, true, "profile");
19-
public static final Class<?> PLUGIN_CLASS_LOADER_CLASS = getBukkitClass("plugin.java.PluginClassLoader");
2027
public static final Field PLUGIN_CLASS_LOADER_PLUGIN_FIELD = getField(PLUGIN_CLASS_LOADER_CLASS, true, "plugin");
21-
public static final Class<?> CB_CRAFT_META_ITEM_CLASS = getCBClass("inventory.CraftMetaItem");
2228
public static final Field CB_CRAFT_META_ITEM_DISPLAY_NAME_FIELD = getField(CB_CRAFT_META_ITEM_CLASS, true, "displayName");
2329
public static final Field CB_CRAFT_META_ITEM_LORE_FIELD = getField(CB_CRAFT_META_ITEM_CLASS, true, "lore");
2430

invui-core/src/main/java/xyz/xenondevs/invui/item/builder/SkullBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private void setGameProfile(@NotNull HeadTexture texture) {
6868
ItemMeta meta = item.getItemMeta();
6969

7070
if (gameProfile != null)
71-
ReflectionUtils.setFieldValue(ReflectionRegistry.CB_CRAFT_META_SKULL_PROFILE_FIELD, meta, gameProfile);
71+
ReflectionUtils.invokeMethod(ReflectionRegistry.CB_CRAFT_META_SKULL_SET_PROFILE_METHOD, meta, gameProfile);
7272

7373
item.setItemMeta(meta);
7474

0 commit comments

Comments
 (0)