diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java index 2f72f0ce5c..7541e95b2b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java @@ -53,7 +53,12 @@ public class CraftMetaBanner extends CraftMetaItem implements BannerMeta { NBTTagList patterns = entityTag.getList(PATTERNS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND); for (int i = 0; i < Math.min(patterns.size(), 20); 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)); + } } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java index 62b3dcc23c..1ff9ff3f2e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java @@ -33,7 +33,11 @@ class CraftMetaCharge extends CraftMetaItem implements FireworkEffectMeta { super(tag); 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 + } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java index bb0c062b9e..15bc3b3566 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java @@ -63,7 +63,11 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta { } 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 + } } } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java index bb921c928f..9fd4c2bc7f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java @@ -58,7 +58,11 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { type = CraftPotionUtil.toBukkit(tag.getString(DEFAULT_POTION.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)) { NBTTagList list = tag.getList(POTION_EFFECTS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND);