1.8.8 Help Skulls

Discussion in 'Spigot Plugin Development' started by mrkino99, Jan 17, 2020.

  1. Hi, i get this error:
    [ERROR] Could not pass event InventoryClickEvent to KStaffMode v1.2.0

    org.bukkit.event.EventException

    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:305) ~[spigot-1.8.jar:git-Spigot-550ebac-7019900]

    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.8.jar:git-Spigot-550ebac-7019900]

    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.8.jar:git-Spigot-550ebac-7019900]

    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.8.jar:git-Spigot-550ebac-7019900]

    at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:1588) [spigot-1.8.jar:git-Spigot-550ebac-7019900]

    at net.minecraft.server.v1_8_R1.PacketPlayInWindowClick.a(SourceFile:31) [spigot-1.8.jar:git-Spigot-550ebac-7019900]

    at net.minecraft.server.v1_8_R1.PacketPlayInWindowClick.a(SourceFile:9) [spigot-1.8.jar:git-Spigot-550ebac-7019900]

    at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spigot-1.8.jar:git-Spigot-550ebac-7019900]

    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_212]

    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_212]

    at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:696) [spigot-1.8.jar:git-Spigot-550ebac-7019900]

    at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot-1.8.jar:git-Spigot-550ebac-7019900]

    at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:634) [spigot-1.8.jar:git-Spigot-550ebac-7019900]

    at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:537) [spigot-1.8.jar:git-Spigot-550ebac-7019900]

    at java.lang.Thread.run(Thread.java:813) [?:1.8.0_212]

    Caused by: java.lang.NoSuchMethodError: org/bukkit/inventory/meta/SkullMeta.setOwningPlayer(Lorg/bukkit/OfflinePlayer;)Z (loaded from file:/pro/bin/mc/spigot/1.8/spigot-1.8.jar by [email protected]) called from class mrkino99.kstaffmode.sm.menus.StaffList (loaded from file:/home/gs-40050/plugins/KStaffMode.jar by [email protected]).

    at mrkino99.kstaffmode.sm.menus.StaffList.openStaffMode(StaffList.java:59) ~[?:?]

    at mrkino99.kstaffmode.sm.menus.StaffList.onClick(StaffList.java:126) ~[?:?]

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]

    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]

    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) ~[spigot-1.8.jar:git-Spigot-550ebac-7019900]

    ... 14 more

    and this is my StaffList class
    Code (Java):
    public static void openStaffMode(Player p){
            int i = 0;
            for(UUID pl : StaffModeCommand.staffmode){
                ItemStack head = new ItemStack(397, 1, (short) 3);
                SkullMeta meta = (SkullMeta) head.getItemMeta();
              line 59 --->  meta.setOwningPlayer(Bukkit.getPlayer(pl));
                meta.setDisplayName(ChatColor.YELLOW + Bukkit.getOfflinePlayer(pl).getName());
                head.setItemMeta(meta);
                if(!staffmodelist.contains(head)) {
                    staffmodelist.setItem(i, head);
                }
                i++;
                if(i == 54){
                    break;
                }
            }
            p.openInventory(staffmodelist);
        }
     
  2. In 1.8.8, you change the skull textures by using the player’s username. If you read the exception, it says that the method which accepts an OfflinePlayer didn’t exist back then.

    The solution is to use the 1.8.8 spigot API when writing your plugin. If you want it to work across multiple versions, you should look up how to do “maven abstraction.”
     
  3. Ok ty Man :))) il try it