summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2017-07-19 09:56:35 +1000
committermd_5 <git@md-5.net>2017-07-19 09:56:35 +1000
commit9a82fa7785843e56b8799ca2b495b0ce115d79d6 (patch)
tree586d10f3201f18a2f9fbda7f0dbb20a29cb9d6ee
parent3819f8dbec3b5967b4e242c5a1d57ed6c986b64c (diff)
downloadcraftbukkit-9a82fa7785843e56b8799ca2b495b0ce115d79d6.tar
craftbukkit-9a82fa7785843e56b8799ca2b495b0ce115d79d6.tar.gz
craftbukkit-9a82fa7785843e56b8799ca2b495b0ce115d79d6.tar.lz
craftbukkit-9a82fa7785843e56b8799ca2b495b0ce115d79d6.tar.xz
craftbukkit-9a82fa7785843e56b8799ca2b495b0ce115d79d6.zip
SPIGOT-3428: Recover from invalid firework data
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java
index 8bcc476e..8a668e9e 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java
@@ -103,7 +103,15 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta {
.trail(explosion.getBoolean(EXPLOSION_TRAIL.NBT))
.with(getEffectType(0xff & explosion.getByte(EXPLOSION_TYPE.NBT)));
- for (int color : explosion.getIntArray(EXPLOSION_COLORS.NBT)) {
+ int[] colors = explosion.getIntArray(EXPLOSION_COLORS.NBT);
+ // People using buggy command generators specify a list rather than an int here, so recover with dummy data.
+ // Wrong: Colors: [1234]
+ // Right: Colors: [I;1234]
+ if (colors.length == 0) {
+ effect.withColor(Color.WHITE);
+ }
+
+ for (int color : colors) {
effect.withColor(Color.fromRGB(color));
}