Solved Custom Heads Not working

Discussion in 'Spigot Plugin Development' started by olausy, Jun 17, 2020.

Thread Status:
Not open for further replies.
  1. I tried the following and it doesn't work.
    Code (Java):
            ItemStack head = new ItemStack(Material.SKULL, 1, (short) SkullType.PLAYER.ordinal());
            SkullMeta headMeta = (SkullMeta) head.getItemMeta();
            GameProfile profile = new GameProfile(UUID.randomUUID(), null);
            profile.getProperties().put("textures", new Property("textures", texture));
            Field field;
            try {
                field = headMeta.getClass().getDeclaredField("profile");
                field.setAccessible(true);
                field.set(headMeta, profile);
            } catch (NoSuchFieldException | IllegalAccessException e) {
                e.printStackTrace();
            }
            return head;
    Error:
    Code (Text):
     Could not pass event AsyncPlayerChatEvent to Captcha v1.0.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:484) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.chat(PlayerConnection.java:1084) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1022) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat$1.run(PacketPlayInChat.java:39) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_251]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_251]
            at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_251]
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_251]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_251]
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R3.inventory.CraftMetaItem cannot be cast to org.bukkit.inventory.meta.SkullMeta
            at com.SoloBedwars.DexCaptcha.UIUtil.getHead(UIUtil.java:95) ~[?:?]
            at com.SoloBedwars.DexCaptcha.UIUtil.getCustomHead(UIUtil.java:118) ~[?:?]
            at com.SoloBedwars.DexCaptcha.CaptchaUI.applyUI(CaptchaUI.java:62) ~[?:?]
            at com.SoloBedwars.DexCaptcha.Listeners.JoinEvent.onFirstJoin(JoinEvent.java:22) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_251]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_251]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_251]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_251]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
            ... 11 more
    Does anyone know why this is happening?
     
  2. Your error come from the ligne 95 of the UIUtil.java class, could you tell me which line is it ?

    Code (Text):
    ItemStack head = new ItemStack(Material.SKULL, 1, (short) SkullType.PLAYER.ordinal());
    And here you could use 3 for data :
    Code (Text):
    ItemStack head = new ItemStack(Material.SKULL, 1, (short) 3);
     
  3. Code (Java):
            SkullMeta headMeta = (SkullMeta) head.getItemMeta();
     
     
  4. I think the problem come from the import of the "org.bukkit.craftbukkit.v1_8_R3.inventory.CraftMetaItem". It should normally be "
    import org.bukkit.inventory.meta.ItemMeta;"
     
Thread Status:
Not open for further replies.