mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-12 09:51:12 +01:00
SPIGOT-5426: isSimilar for player heads fails
This commit is contained in:
parent
4b34472ee0
commit
82322fe06c
1 changed files with 19 additions and 17 deletions
|
@ -26,6 +26,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||||
static final int MAX_OWNER_LENGTH = 16;
|
static final int MAX_OWNER_LENGTH = 16;
|
||||||
|
|
||||||
private GameProfile profile;
|
private GameProfile profile;
|
||||||
|
private NBTTagCompound serializedProfile;
|
||||||
|
|
||||||
CraftMetaSkull(CraftMetaItem meta) {
|
CraftMetaSkull(CraftMetaItem meta) {
|
||||||
super(meta);
|
super(meta);
|
||||||
|
@ -33,16 +34,16 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CraftMetaSkull skullMeta = (CraftMetaSkull) meta;
|
CraftMetaSkull skullMeta = (CraftMetaSkull) meta;
|
||||||
this.profile = skullMeta.profile;
|
this.setProfile(skullMeta.profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
CraftMetaSkull(NBTTagCompound tag) {
|
CraftMetaSkull(NBTTagCompound tag) {
|
||||||
super(tag);
|
super(tag);
|
||||||
|
|
||||||
if (tag.hasKeyOfType(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
if (tag.hasKeyOfType(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
||||||
profile = GameProfileSerializer.deserialize(tag.getCompound(SKULL_OWNER.NBT));
|
this.setProfile(GameProfileSerializer.deserialize(tag.getCompound(SKULL_OWNER.NBT)));
|
||||||
} else if (tag.hasKeyOfType(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !tag.getString(SKULL_OWNER.NBT).isEmpty()) {
|
} else if (tag.hasKeyOfType(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !tag.getString(SKULL_OWNER.NBT).isEmpty()) {
|
||||||
profile = new GameProfile(null, tag.getString(SKULL_OWNER.NBT));
|
this.setProfile(new GameProfile(null, tag.getString(SKULL_OWNER.NBT)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,30 +59,31 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||||
super.deserializeInternal(tag, context);
|
super.deserializeInternal(tag, context);
|
||||||
|
|
||||||
if (tag.hasKeyOfType(SKULL_PROFILE.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
if (tag.hasKeyOfType(SKULL_PROFILE.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
||||||
profile = GameProfileSerializer.deserialize(tag.getCompound(SKULL_PROFILE.NBT));
|
this.setProfile(GameProfileSerializer.deserialize(tag.getCompound(SKULL_PROFILE.NBT)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void serializeInternal(final Map<String, NBTBase> internalTags) {
|
void serializeInternal(final Map<String, NBTBase> internalTags) {
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
NBTTagCompound nbtData = new NBTTagCompound();
|
internalTags.put(SKULL_PROFILE.NBT, serializedProfile);
|
||||||
GameProfileSerializer.serialize(nbtData, profile);
|
|
||||||
internalTags.put(SKULL_PROFILE.NBT, nbtData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setProfile(GameProfile profile) {
|
||||||
|
this.profile = profile;
|
||||||
|
this.serializedProfile = (profile == null) ? null : GameProfileSerializer.serialize(new NBTTagCompound(), profile);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void applyToItem(NBTTagCompound tag) {
|
void applyToItem(NBTTagCompound tag) {
|
||||||
super.applyToItem(tag);
|
super.applyToItem(tag);
|
||||||
|
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
// Fill in textures
|
// Fill in textures
|
||||||
profile = TileEntitySkull.b(profile);
|
setProfile(TileEntitySkull.b(profile));
|
||||||
|
|
||||||
NBTTagCompound owner = new NBTTagCompound();
|
tag.set(SKULL_OWNER.NBT, serializedProfile);
|
||||||
GameProfileSerializer.serialize(owner, profile);
|
|
||||||
tag.set(SKULL_OWNER.NBT, owner);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,9 +154,9 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
profile = null;
|
setProfile(null);
|
||||||
} else {
|
} else {
|
||||||
profile = new GameProfile(null, name);
|
setProfile(new GameProfile(null, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -163,11 +165,11 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||||
@Override
|
@Override
|
||||||
public boolean setOwningPlayer(OfflinePlayer owner) {
|
public boolean setOwningPlayer(OfflinePlayer owner) {
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
profile = null;
|
setProfile(null);
|
||||||
} else if (owner instanceof CraftPlayer) {
|
} else if (owner instanceof CraftPlayer) {
|
||||||
profile = ((CraftPlayer) owner).getProfile();
|
setProfile(((CraftPlayer) owner).getProfile());
|
||||||
} else {
|
} else {
|
||||||
profile = new GameProfile(owner.getUniqueId(), owner.getName());
|
setProfile(new GameProfile(owner.getUniqueId(), owner.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -192,7 +194,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||||
CraftMetaSkull that = (CraftMetaSkull) meta;
|
CraftMetaSkull that = (CraftMetaSkull) meta;
|
||||||
|
|
||||||
// SPIGOT-5403: equals does not check properties
|
// SPIGOT-5403: equals does not check properties
|
||||||
return (this.profile != null ? that.profile != null && this.profile.equals(that.profile) && this.profile.getProperties().equals(that.profile.getProperties()) : that.profile == null);
|
return (this.profile != null ? that.profile != null && this.serializedProfile.equals(that.serializedProfile) : that.profile == null);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue