Another fix to database heads.

This commit is contained in:
Olof Larsson 2015-06-05 14:48:47 +02:00
parent cc6bf1bfbb
commit 3b5e1d4499

View File

@ -33,8 +33,6 @@ public class ItemStackAdapterInnerV1_8 extends ItemStackAdapterInnerV1_7
public static final String ITEM_FLAGS = "flags"; public static final String ITEM_FLAGS = "flags";
public static final String SKULL_OWNER_ID = "skullid";
public static final String BANNER_BASE = "banner-base"; public static final String BANNER_BASE = "banner-base";
public static final String BANNER_PATTERNS = "banner"; public static final String BANNER_PATTERNS = "banner";
@ -161,6 +159,10 @@ public class ItemStackAdapterInnerV1_8 extends ItemStackAdapterInnerV1_7
// -------------------------------------------- // // -------------------------------------------- //
// SPECIFIC META: SKULL // SPECIFIC META: SKULL
// -------------------------------------------- // // -------------------------------------------- //
// When we serialize we store the minimal information possible.
// We then deserialize using cached information.
// This is done to avoid sync bouncing.
// Different servers might serialize different heads differently.
@Override @Override
public void transferSkull(SkullMeta meta, JsonObject json, boolean meta2json) public void transferSkull(SkullMeta meta, JsonObject json, boolean meta2json)
@ -168,28 +170,19 @@ public class ItemStackAdapterInnerV1_8 extends ItemStackAdapterInnerV1_7
if (meta2json) if (meta2json)
{ {
if ( ! meta.hasOwner()) return; if ( ! meta.hasOwner()) return;
String name = meta.getOwner();
// Resolve to avoid MStore sync bouncing. if (name == null) return;
Couple<String, UUID> resolved = NmsHead.resolve(meta); name = name.toLowerCase();
String name = resolved.getFirst(); json.addProperty(SKULL_OWNER, name);
UUID id = resolved.getSecond();
if (name != null) json.addProperty(SKULL_OWNER, name);
if (id != null) json.addProperty(SKULL_OWNER_ID, id.toString());
} }
else else
{ {
JsonElement element; JsonElement element = json.get(SKULL_OWNER);
if (element == null) return;
String name = null;
element = json.get(SKULL_OWNER);
if (element != null) name = element.getAsString();
String name = element.getAsString();
UUID id = null; UUID id = null;
element = json.get(SKULL_OWNER_ID);
if (element != null) id = UUID.fromString(element.getAsString());
// Resolve to avoid MStore sync bouncing.
Couple<String, UUID> resolved = NmsHead.resolve(name, id); Couple<String, UUID> resolved = NmsHead.resolve(name, id);
name = resolved.getFirst(); name = resolved.getFirst();
id = resolved.getSecond(); id = resolved.getSecond();