1.15.2 Skull owner - Legacy??

Discussion in 'Spigot Plugin Development' started by Maxx_Qc, Feb 9, 2020.

  1. Hey guys, so I'm building a gui with the player's skull in it and I realized that everytime I opened the gui the console would say something like "Initiliazing legacy support" and that's not really what I want so I did some debug and found out that my method to set the skull owner turns the itemstack into a Legacy itemstack??

    Here's my method:
    Code (Java):
    SkullMeta im = (SkullMeta) is.getItemMeta();
                assert im != null;
                im.setOwner(owner);
                is.setItemMeta(im);
    Any help would be appreciated :)
    I don't want to use Legacy materials.
     
  2. What is your item? ItemStack is = ?
     
  3. api-version: 1.13 in plugin.yml
     
    • Like Like x 1
    • Agree Agree x 1
  4. Material.PLAYER_HEAD
     
  5. That's what I already have, but would like to remove and make it totally 1.15.2 you know
     
  6. To use a skull, you have to set the damage always to 3 (idk why).
    Like this:
    Code (Java):
    ItemStack is = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
     
  7. No you don’t.

    You can start by using https://hub.spigotmc.org/javadocs/b...tml#setOwningPlayer-org.bukkit.OfflinePlayer- instead.

    Don’t use assertions in your code if you aren’t going to use -ea when running the server.
     
    • Agree Agree x 1
  8. The assert is because intellij is bugging me lol I don’t know what -ea does. Also, I don’t even use the getOfflinePlayer() method, I just pass the player directly as the parameter.
     
  9. md_5

    Administrator Developer

    Sounds like it could be a spigot bug, like the message says
     
  10. @xTrollxDudex suggested using the #setOwningPlayer method that is the updated version of #setOwner. setOwner takes in a String, rather than a Player object. So your code wouldn't work as, assuming you're not getting any errors, it is setting the owner to [email protected] rather than setting it to the proper player. setOwningPlayer takes in an OfflinePlayer which also accepts Player as Player is an extension/implementation of OfflinePlayer.
     
    • Winner Winner x 1
  11. [Server thread/WARN]: Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!

    Still not working

    Code (Java):
    try
            {
                SkullMeta im = (SkullMeta) is.getItemMeta();
                assert im != null;
                im.setOwningPlayer(owner);
                is.setItemMeta(im);
            } catch (ClassCastException ignored) { }
     
  12. Make sure you have api-version set to 1.13 or greater in the plugin.yml?
     
  13. md_5

    Administrator Developer

     
    • Funny Funny x 1
  14. Where should I report this?