diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java index 476089a1be..a2a91decc4 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java @@ -1,7 +1,6 @@ package org.bukkit.craftbukkit.inventory; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; @@ -74,7 +73,7 @@ class CraftMetaBook extends CraftMetaItem implements BookMeta { setTitle(SerializableMeta.getString(map, BOOK_TITLE.BUKKIT, true)); - Collection pages = SerializableMeta.getObject(Collection.class, map, BOOK_PAGES.BUKKIT, true); + Iterable pages = SerializableMeta.getObject(Iterable.class, map, BOOK_PAGES.BUKKIT, true); CraftMetaItem.safelyAdd(pages, this.pages, MAX_PAGE_LENGTH); } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java index 84ce4bbd41..40ac8adfb8 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java @@ -30,7 +30,7 @@ class CraftMetaCharge extends CraftMetaItem implements FireworkEffectMeta { CraftMetaCharge(Map map) { super(map); - effect = SerializableMeta.getObject(FireworkEffect.class, map, EXPLOSION.BUKKIT, true); + setEffect(SerializableMeta.getObject(FireworkEffect.class, map, EXPLOSION.BUKKIT, true)); } CraftMetaCharge(NBTTagCompound tag) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java index 0ac73e1e32..5d955ef2d3 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java @@ -172,7 +172,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta { Integer power = SerializableMeta.getObject(Integer.class, map, FLIGHT.BUKKIT, true); if (power != null) { - this.power = power; + setPower(power); } Iterable effects = SerializableMeta.getObject(Iterable.class, map, EXPLOSIONS.BUKKIT, true); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index cc976ebf6b..ea6efcaa43 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -271,14 +271,16 @@ class CraftMetaItem implements ItemMeta, Repairable { CraftMetaItem(Map map) { setDisplayName(SerializableMeta.getString(map, NAME.BUKKIT, true)); - if (map.containsKey(LORE.BUKKIT)) { - lore = (List) map.get(LORE.BUKKIT); + Iterable lore = SerializableMeta.getObject(Iterable.class, map, LORE.BUKKIT, true); + if (lore != null) { + safelyAdd(lore, this.lore = new ArrayList(), Integer.MAX_VALUE); } enchantments = buildEnchantments(map, ENCHANTMENTS); - if (map.containsKey(REPAIR.BUKKIT)) { - repairCost = (Integer) map.get(REPAIR.BUKKIT); + Integer repairCost = SerializableMeta.getObject(Integer.class, map, REPAIR.BUKKIT, true); + if (repairCost != null) { + setRepairCost(repairCost); } } @@ -556,7 +558,7 @@ class CraftMetaItem implements ItemMeta, Repairable { return SerializableMeta.Deserializers.UNSPECIFIC; } - static void safelyAdd(Collection addFrom, Collection addTo, int maxItemLength) { + static void safelyAdd(Iterable addFrom, Collection addTo, int maxItemLength) { if (addFrom == null) { return; } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java index 0bd57c035d..5bad0edf92 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java @@ -42,8 +42,9 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta { CraftMetaMap(Map map) { super(map); - if (map.containsKey(MAP_SCALING.BUKKIT)) { - this.scaling = SerializableMeta.getBoolean(map, MAP_SCALING.BUKKIT) ? SCALING_TRUE : SCALING_FALSE; + Boolean scaling = SerializableMeta.getObject(Boolean.class, map, MAP_SCALING.BUKKIT, true); + if (scaling != null) { + setScaling(scaling); } } @@ -126,7 +127,7 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta { super.serialize(builder); if (hasScaling()) { - builder.put(MAP_SCALING.BUKKIT, scaling); + builder.put(MAP_SCALING.BUKKIT, isScaling()); } return builder; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java index d8c507cb77..3d565f6412 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java @@ -64,7 +64,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { CraftMetaPotion(Map map) { super(map); - List rawEffectList = SerializableMeta.getObject(List.class, map, POTION_EFFECTS.BUKKIT, true); + Iterable rawEffectList = SerializableMeta.getObject(Iterable.class, map, POTION_EFFECTS.BUKKIT, true); if (rawEffectList == null) { return; }