Paper: 1.15: NPE when toString on a custom skull item

Created on 19 Jan 2020  路  8Comments  路  Source: PaperMC/Paper

When I create a custom skull using the HeadsDatabase plugin, the "toString" method on the ItemStack as well as "isSimilar" will start crashing.

I understand you won't fix a third party plugin. But i'd like to raise awareness if this can be worked around or silenced in Paper.

a

Plugin list:

Boss, ChatControl, Essentials, FastAsyncWorldEdit, HeadDatabase*, LuckPerms, Vault, WorldEdit, WorldGuard, Zara-Survival

Paper build number:

Latest lol. (git-Paper-58 (MC: 1.15.1))

Anything else:

Thanks for everything guys, it's been a long journey!

Most helpful comment

It would be great if you could list the steps to reproduce without requiring us to use a paid, probably GPL-violating plugin.

All 8 comments

It would be great if you could list the steps to reproduce without requiring us to use a paid, probably GPL-violating plugin.

This can be reproduced with the freely available HeadsDatabase API as found on the Spigot page.

Spigot Page Link:
https://www.spigotmc.org/resources/head-database.14280/

Direct HeadsDatabaseAPI download link found on Spigot for your convinence

https://mega.nz/#!aoUCVI6C!REDes99H-UUtpG5Ot-eKXzHZ8HtHF8uKaaiBK7VvOgg

NMS is unsupported, plugins creating invalid NBT structures (NBT should not have null values, ever; best we could do to retain proper compat is to blow up on the creation of such broken stacks in general) are not something we really have that much inclination to try dealing with, all we do is end up going deeper down the rabbits nest of issues such broken item stacks cause

This can be reproduced with the freely available HeadsDatabase API as found on the Spigot page.

Spigot Page Link:
https://www.spigotmc.org/resources/head-database.14280/

Direct HeadsDatabaseAPI download link found on Spigot for your convinence

https://mega.nz/#!aoUCVI6C!REDes99H-UUtpG5Ot-eKXzHZ8HtHF8uKaaiBK7VvOgg

Are you sure? The implementation in that jar simply returns null. It causes an NPE as well, just a totally different one :)

This is an issue that Head Database has to fix. The plugin probably just sets the profile field within the CraftMetaSkull. md_5 recently added another field that contains the serialized profile for the similarity check which points to null in this case and leads to the NullPointerException. To fix this issue plugins should use the setProfile method which was added and sets both fields.

This is what the HeadsDatabase API plugin does, where specifically does it go wrong.

ItemStack item = new ItemStack(Material.SKULL_ITEM, amount, (short) 3);
SkullMeta headMeta = (SkullMeta)item.getItemMeta();
GameProfile profile = new GameProfile(id, name);
profile.getProperties().put("textures", new Property("textures", String.valueOf(data)));
Field profileField;
try
{
profileField = headMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(headMeta, profile);
}
catch (Exception e){}
item.setItemMeta(headMeta);

just use papers player profile api.....

as already noted, the part where it sets the profile field and doesn't use the setProfile method which also populates some other critical data properly

Was this page helpful?
0 / 5 - 0 ratings