[SPIGOT-5588] Setting owning player of a skull initialize legacy support Created: 18/Feb/20  Updated: 19/Feb/20  Resolved: 19/Feb/20

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Maxime Deraiche Jenkins Assignee: Unassigned
Resolution: Invalid Votes: 1
Labels: bug, spigot

Attachments: Text File latest.log     File testPlugin.jar    
Version: 1.15.2
Guidelines Read: Yes

 Description   

When setting the owning player of a skull item and giving that item using a command, whenever I type in the command to receive that skull then the server console logs "Initializing 1.13 legacy support...". I had to put api-version: 1.13 into my plugin yaml and it still does this sometimes.



 Comments   
Comment by md_5 [ 19/Feb/20 ]

NMS is not supported.
Please follow the reporting instructions and include the minimal API based plugin to trigger the bug.
You can enable debug in server.properties to see what is triggering legacy support.

Comment by Maxime Deraiche Jenkins [ 19/Feb/20 ]

Sorry for the mislead. Apparently, after some hard debugging, this item isn't causing the legacy initialization.

There's something about the dirt block though...

So, using a gui, 

ownedChunks.addOption(new ItemBuilder(Material.DIRT).toItemStack()); // Causes legacy
ownedChunks.addOption(Material.DIRT, "", 2); // Works

My gui manager:

public MenuGUI addOption(ItemStack is)
{
   addOption(is, -1);
   return this;
}

public MenuGUI addOption(Material mat, String name, int position, String... desc)
{
   ItemStack is = new ItemStack(mat, 1);
   ItemMeta im = is.getItemMeta();
   assert im != null;
   im.setDisplayName(Helper.colorize(name));
   if (desc != null)
      im.setLore(Arrays.asList(Helper.colorize(desc)));
   is.setItemMeta(im);
   addOption(is, position);
   return this;
}

public MenuGUI addOption(ItemStack is, int position)
{

   if (Math.floor(position / 9) > 5)
      return this;
   
   if (position < 0)
      inv.addItem(is);
   else
      inv.setItem(position, is);

   return this;
}

And my itembuilder:

package com.maxx.themcsurvival.util;

import java.util.*;

import net.minecraft.server.v1_15_R1.NBTTagCompound;
import net.minecraft.server.v1_15_R1.NBTTagString;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;

/**
 * Easily create itemstacks, without messing your hands. <i>Note that if you do
 * use this in one of your projects, leave this notice.</i> <i>Please do credit
 * me if you do use this in one of your projects.</i>
 *
 * @author NonameSL
 */
public class ItemBuilder {
   private ItemStack is;

   /**
    * Create a new ItemBuilder from scratch.
    *
    * @param m The material to create the ItemBuilder with.
    */
   public ItemBuilder(Material m) { this(m, 1); }

   /**
    * Create a new ItemBuilder over an existing itemstack.
    *
    * @param is The itemstack to create the ItemBuilder over.
    */
   public ItemBuilder(ItemStack is) { this.is = is; }

   /**
    * Create a new ItemBuilder from scratch.
    *
    * @param m      The material of the item.
    * @param amount The amount of the item.
    */
   public ItemBuilder(Material m, int amount) { is = new ItemStack(m, amount); }

   /**
    * Clone the ItemBuilder into a new one.
    *
    * @return The cloned instance.
    */
   @Override
   public ItemBuilder clone() { return new ItemBuilder(is); }

   /**
    * Set the displayname of the item.
    *
    * @param name The name to change it to.
    */
   public ItemBuilder setName(String name)
   {
      ItemMeta im = is.getItemMeta();
      assert im != null;
      im.setDisplayName(Helper.colorize(name));
      is.setItemMeta(im);
      return this;
   }

   /**
    * Set the skull owner for the item. Works on skulls only.
    *
    * @param owner The name of the skull's owner.
    */
   public ItemBuilder setSkullOwner(final OfflinePlayer owner)
   {
      try
      {
         SkullMeta im = (SkullMeta) is.getItemMeta();
         assert im != null;
         im.setOwningPlayer(owner);
         is.setItemMeta(im);
      } catch (ClassCastException ignored) {}
      return this;
   }

   /**
    * Sets infinity durability on the item by setting the durability to
    * Short.MAX_VALUE.
    */
   public ItemBuilder setInfinityDurability()
   {
      ItemMeta im = is.getItemMeta();
      assert im != null;
      im.setUnbreakable(true);
      is.setItemMeta(im);
      return this;
   }

   /**
    * Re-sets the lore.
    *
    * @param lore The lore to set it to.
    */
   public ItemBuilder setLore(String... lore)
   {
      ItemMeta im = is.getItemMeta();
      assert im != null;
      im.setLore(Arrays.asList(Helper.colorize(lore)));
      is.setItemMeta(im);
      return this;
   }

   public ItemBuilder addNBTTag(String id, String value)
   {
      net.minecraft.server.v1_15_R1.ItemStack nmsIs = CraftItemStack.asNMSCopy(is);
      NBTTagCompound nmsCompound = (nmsIs.hasTag()) ? nmsIs.getTag() : new NBTTagCompound();
      assert nmsCompound != null;
      nmsCompound.set(id, NBTTagString.a(value));
      nmsIs.setTag(nmsCompound);
      is = CraftItemStack.asBukkitCopy(nmsIs);
      return this;
   }

   /**
    * Remove a lore line.
    *
    * @param line The lore to remove.
    */
   public ItemBuilder removeLoreLine(String line)
   {
      ItemMeta im = is.getItemMeta();
      assert im != null;
      List<String> lore = new ArrayList<>(Objects.requireNonNull(im.getLore()));
      if (!lore.contains(line))
         return this;
      lore.remove(line);
      im.setLore(lore);
      is.setItemMeta(im);
      return this;
   }

   /**
    * Remove a lore line.
    *
    * @param index The index of the lore line to remove.
    */
   public ItemBuilder removeLoreLine(int index)
   {
      ItemMeta im = is.getItemMeta();
      assert im != null;
      List<String> lore = new ArrayList<>(Objects.requireNonNull(im.getLore()));
      if (index < 0 || index > lore.size())
         return this;
      lore.remove(index);
      im.setLore(lore);
      is.setItemMeta(im);
      return this;
   }

   /**
    * Add a lore line.
    *
    * @param line The lore line to add.
    */
   public ItemBuilder addLoreLine(String line)
   {
      ItemMeta im = is.getItemMeta();
      List<String> lore = new ArrayList<>();
      assert im != null;
      if (im.hasLore())
         lore = new ArrayList<>(Objects.requireNonNull(im.getLore()));
      lore.add(Helper.colorize(line));
      im.setLore(lore);
      is.setItemMeta(im);
      return this;
   }

   /**
    * Add a lore line.
    *
    * @param line The lore line to add.
    * @param pos  The index of where to put it.
    */
   public ItemBuilder addLoreLine(String line, int pos)
   {
      ItemMeta im = is.getItemMeta();
      assert im != null;
      List<String> lore = new ArrayList<>(Objects.requireNonNull(im.getLore()));
      lore.set(pos, Helper.colorize(line));
      im.setLore(lore);
      is.setItemMeta(im);
      return this;
   }

   /**
    * Retrieves the itemstack from the ItemBuilder.
    *
    * @return The itemstack created/modified by the ItemBuilder instance.
    */
   public ItemStack toItemStack() { return is; }

   public void clearLoreLines()
   {
      ItemMeta im = is.getItemMeta();
      assert im != null;
      im.setLore(new ArrayList<>());
      is.setItemMeta(im);
   }
}

All it does is return a new ItemStack with the Material.DIRT, I'm kinda lost here honestly...

Comment by TheCreeperCow [ 19/Feb/20 ]

Just tested this with my own test plugin and it worked fine no legacy try using api-version: 1.15 in your plugin.yml

Comment by TheCreeperCow [ 19/Feb/20 ]

Can you post the plugin you used to try this it will help in the debug process 

Comment by md_5 [ 18/Feb/20 ]

https://www.spigotmc.org/threads/skull-owner-legacy.416979

Generated at Sat Dec 13 11:51:40 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.