Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 20:40:08 +01:00
Various ItemMeta fixes.
Fixes BUKKIT-3408, BUKKIT-3190, BUKKIT-3191, BUKKIT-3407 These changes relate mostly to semantical changes for serialization contract, exception of changing the map scaling value from byte to boolean, what it should have been in the first place. Appropriate unit tests were added for CraftMapMeta, as they were missing.
Dieser Commit ist enthalten in:
Ursprung
43865e8e67
Commit
dd7ba4a258
@ -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);
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ class CraftMetaCharge extends CraftMetaItem implements FireworkEffectMeta {
|
||||
CraftMetaCharge(Map<String, Object> map) {
|
||||
super(map);
|
||||
|
||||
effect = SerializableMeta.getObject(FireworkEffect.class, map, EXPLOSION.BUKKIT, true);
|
||||
setEffect(SerializableMeta.getObject(FireworkEffect.class, map, EXPLOSION.BUKKIT, true));
|
||||
}
|
||||
|
||||
CraftMetaCharge(NBTTagCompound tag) {
|
||||
|
@ -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);
|
||||
|
@ -271,14 +271,16 @@ class CraftMetaItem implements ItemMeta, Repairable {
|
||||
CraftMetaItem(Map<String, Object> map) {
|
||||
setDisplayName(SerializableMeta.getString(map, NAME.BUKKIT, true));
|
||||
|
||||
if (map.containsKey(LORE.BUKKIT)) {
|
||||
lore = (List<String>) map.get(LORE.BUKKIT);
|
||||
Iterable<?> lore = SerializableMeta.getObject(Iterable.class, map, LORE.BUKKIT, true);
|
||||
if (lore != null) {
|
||||
safelyAdd(lore, this.lore = new ArrayList<String>(), 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<String> addTo, int maxItemLength) {
|
||||
static void safelyAdd(Iterable<?> addFrom, Collection<String> addTo, int maxItemLength) {
|
||||
if (addFrom == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -42,8 +42,9 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta {
|
||||
CraftMetaMap(Map<String, Object> 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;
|
||||
|
@ -64,7 +64,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {
|
||||
CraftMetaPotion(Map<String, Object> 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;
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren