3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 13:30:05 +01:00

SPIGOT-5428: Better handling of some ItemMeta

Dieser Commit ist enthalten in:
md_5 2019-12-14 10:54:12 +11:00
Ursprung 16dc5758ae
Commit 61d4b09023
4 geänderte Dateien mit 21 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -53,7 +53,12 @@ public class CraftMetaBanner extends CraftMetaItem implements BannerMeta {
NBTTagList patterns = entityTag.getList(PATTERNS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND); NBTTagList patterns = entityTag.getList(PATTERNS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND);
for (int i = 0; i < Math.min(patterns.size(), 20); i++) { for (int i = 0; i < Math.min(patterns.size(), 20); i++) {
NBTTagCompound p = patterns.getCompound(i); NBTTagCompound p = patterns.getCompound(i);
this.patterns.add(new Pattern(DyeColor.getByWoolData((byte) p.getInt(COLOR.NBT)), PatternType.getByIdentifier(p.getString(PATTERN.NBT)))); DyeColor color = DyeColor.getByWoolData((byte) p.getInt(COLOR.NBT));
PatternType pattern = PatternType.getByIdentifier(p.getString(PATTERN.NBT));
if (color != null && pattern != null) {
this.patterns.add(new Pattern(color, pattern));
}
} }
} }
} }

Datei anzeigen

@ -33,7 +33,11 @@ class CraftMetaCharge extends CraftMetaItem implements FireworkEffectMeta {
super(tag); super(tag);
if (tag.hasKey(EXPLOSION.NBT)) { if (tag.hasKey(EXPLOSION.NBT)) {
effect = CraftMetaFirework.getEffect(tag.getCompound(EXPLOSION.NBT)); try {
effect = CraftMetaFirework.getEffect(tag.getCompound(EXPLOSION.NBT));
} catch (IllegalArgumentException ex) {
// Ignore invalid effects
}
} }
} }

Datei anzeigen

@ -63,7 +63,11 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta {
} }
if (display.hasKey(MAP_COLOR.NBT)) { if (display.hasKey(MAP_COLOR.NBT)) {
color = Color.fromRGB(display.getInt(MAP_COLOR.NBT)); try {
color = Color.fromRGB(display.getInt(MAP_COLOR.NBT));
} catch (IllegalArgumentException ex) {
// Invalid colour
}
} }
} }
} }

Datei anzeigen

@ -58,7 +58,11 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {
type = CraftPotionUtil.toBukkit(tag.getString(DEFAULT_POTION.NBT)); type = CraftPotionUtil.toBukkit(tag.getString(DEFAULT_POTION.NBT));
} }
if (tag.hasKey(POTION_COLOR.NBT)) { if (tag.hasKey(POTION_COLOR.NBT)) {
color = Color.fromRGB(tag.getInt(POTION_COLOR.NBT)); try {
color = Color.fromRGB(tag.getInt(POTION_COLOR.NBT));
} catch (IllegalArgumentException ex) {
// Invalid colour
}
} }
if (tag.hasKey(POTION_EFFECTS.NBT)) { if (tag.hasKey(POTION_EFFECTS.NBT)) {
NBTTagList list = tag.getList(POTION_EFFECTS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND); NBTTagList list = tag.getList(POTION_EFFECTS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND);