GlowstoneMC / Glowstone

A fast, customizable and compatible open source server for Minecraft: Java Edition
https://glowstone.net
Other
1.9k stars 273 forks source link

GlowPlayerProfile returns invalid string and issues relating to custom heads #977

Closed crashdemons closed 5 years ago

crashdemons commented 5 years ago

I'm trying to port a bukkit plugin which needs to set a custom texture and uuid on heads, as you know there is no authlib here so I've been trying to get GlowPlayerProfile (or PlayerProfile) with SkullMeta#setPlayerProfile to do this for me without any success.

Example valid owner tag for an item in vanilla: {Id:"01bf9227-95fd-413f-af29-4ace675801bc",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODZhZGRiZDVkZWRhZDQwOTk5NDczYmU0YTdmNDhmNjIzNmE3OWEwZGNlOTcxYjVkYmQ3MzcyMDE0YWUzOTRkIn19fQ=="}]}} (note: this UUID will fail lookup and is assigned for the purpose of this specific head)

toNBT() output excerpt [after creating the profile and setting properties and completing]:

    Id: TAG_String: java.util.concurrent.CompletableFuture@6cb7eec3[Completed normally]
    Name: TAG_String: null
    Properties: TAG_Compound: 1 entries
    {
        textures: ...

from https://github.com/GlowstoneMC/Glowstone/blob/262218fc1fa774ca34484efe6a44b9dc02678483/src/main/java/net/glowstone/entity/meta/profile/GlowPlayerProfile.java#L194

This occurs when creating a custom textured head with a UUID and textures properties, but no name - either from the constructor or fromNBT() using the normal set of tags.

Then when the server attempts to send this to the user:

I don't see any other facility for setting this information on heads without a name, or else I wouldn't have made an issue. I've also been trying to use Bukkit.createProfile() instead and then set properties but running into similar errors in the log.

Is there a better/correct way to create these heads?

Thank you for your time.

Pr0methean commented 5 years ago

This issue arises because CompletableFuture.toString() doesn't delegate to the result object.

crashdemons commented 5 years ago

If this change is included in glowstone-2018.10.0-20181118.030314-8 (based on the -sources, it is) then I still do have console errors mentioned above relating to this, and not just on custom heads. So I don't know how "fixed" this is... or maybe this is a different issue?

https://pastebin.com/d3kMesmX

Here's a rough set of steps that you can use to reproduce the error:

(create an item stack of skulltype PLAYER and get the SkullMeta of the stack)
...
PlayerProfile profile = Bukkit.createProfile("MHF_Chicken");//create a basic name playerhead with a good uuid.
profile.complete();//doesn't seem to matter in this case
skullMeta.setPlayerProfile(profile);
stack.setItemMeta(skullMeta);
....
(add the stack to the player's inventory)
(have the player open their inventory and try to move the stack - or logout/login)
(the console errors occur)

I know you explained why this occurs, but the commit didn't really fix the issue when the value is valid, only when it shouldn't exist. (which I guess was kind of a secondary issue...)

I did delete my world, etc before testing this build.