Calling ItemStack.getData() or ItemStack.setData(...) causes legacy material support initialization{{}}:
Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
The server freezes for a second while it does some legacy material magic before returning a legacy material (e.g. LEGACY_DIRT, instead of{{ DIRT}}).
The documentation does not mention this behavior.
As I feel we all would prefer to work with new, better DIRT over old, horrible LEGACY_DIRT, I think the method should be annotated as deprecated and/or the documentation should be updated to make users aware of this (misleading) behavior.
One of the methods in question looks like so:
/**
{{ * Gets the MaterialData for this stack of items}}
{{ *}}
{{ * @return MaterialData for this item}}
{{ */}}
@Nullable
public MaterialData getData() {
Material mat = Bukkit.getUnsafe().toLegacy(getType());
if (data == null && mat != null && mat.getData() != null) {
data = mat.getNewData((byte) this.getDurability());
{{ }}}
return data;
}