diff --git a/src/main/java/net/minestom/server/item/firework/FireworkEffect.java b/src/main/java/net/minestom/server/item/firework/FireworkEffect.java index c9aad763c..dcb8008b4 100644 --- a/src/main/java/net/minestom/server/item/firework/FireworkEffect.java +++ b/src/main/java/net/minestom/server/item/firework/FireworkEffect.java @@ -2,44 +2,32 @@ package net.minestom.server.item.firework; import net.minestom.server.chat.ChatColor; import net.minestom.server.color.Color; +import net.minestom.server.exception.ExceptionManager; +import org.apache.commons.lang3.Validate; import org.jetbrains.annotations.NotNull; -import org.jglrxavpok.hephaistos.nbt.NBTCompound; +import org.jglrxavpok.hephaistos.nbt.*; -import java.util.Objects; +import java.util.*; public class FireworkEffect { private final boolean flicker; private final boolean trail; private final FireworkEffectType type; - private final Color color; - private final Color fadeColor; + private final List color; + private final List fadeColor; + //FIXME: fix javadoc /** * Initializes a new firework effect. * * @param flicker {@code true} if this explosion has the Twinkle effect (glowstone dust), otherwise {@code false}. * @param trail {@code true} if this explosion hsa the Trail effect (diamond), otherwise {@code false}. * @param type The shape of this firework's explosion. - * @param color The primary color of this firework effect. - * @param fadeColor The secondary color of this firework effect. - * @deprecated Use {@link #FireworkEffect(boolean, boolean, FireworkEffectType, Color, Color)} + * @param color The primary colors of this firework effect. + * @param fadeColor The secondary colors of this firework effect. */ - @Deprecated - public FireworkEffect(boolean flicker, boolean trail, FireworkEffectType type, ChatColor color, ChatColor fadeColor) { - this(flicker, trail, type, color.asColor(), fadeColor.asColor()); - } - - /** - * Initializes a new firework effect. - * - * @param flicker {@code true} if this explosion has the Twinkle effect (glowstone dust), otherwise {@code false}. - * @param trail {@code true} if this explosion hsa the Trail effect (diamond), otherwise {@code false}. - * @param type The shape of this firework's explosion. - * @param color The primary color of this firework effect. - * @param fadeColor The secondary color of this firework effect. - */ - public FireworkEffect(boolean flicker, boolean trail, FireworkEffectType type, Color color, Color fadeColor) { + public FireworkEffect(boolean flicker, boolean trail, FireworkEffectType type, List color, List fadeColor) { this.flicker = flicker; this.trail = trail; this.type = type; @@ -55,18 +43,21 @@ public class FireworkEffect { */ public static FireworkEffect fromCompound(@NotNull NBTCompound compound) { - Color primaryColor = null; - Color secondaryColor = null; + List primaryColor = new ArrayList<>(); + List secondaryColor = new ArrayList<>(); if (compound.containsKey("Colors")) { int[] color = compound.getIntArray("Colors"); - primaryColor = new Color(color[0], color[1], color[2]); + for (int i = 0; i < color.length; i++) { + primaryColor.add(new Color(color[i])); + } } if (compound.containsKey("FadeColors")) { int[] fadeColor = compound.getIntArray("FadeColors"); - secondaryColor = new Color(fadeColor[0], fadeColor[1], fadeColor[2]); - + for (int i = 0; i < fadeColor.length; i++) { + secondaryColor.add(new Color(fadeColor[i])); + } } boolean flicker = compound.containsKey("Flicker") && compound.getByte("Flicker") == 1; @@ -118,11 +109,11 @@ public class FireworkEffect { * @return An array of integer values corresponding to the primary colors of this firework's explosion. */ public int[] getColors() { - return new int[]{ - this.color.getRed(), - this.color.getGreen(), - this.color.getBlue() - }; + int[] primary = new int[color.size()]; + for (int i = 0; i < color.size(); i++) { + primary[i] = color.get(i).asRGB(); + } + return primary; } /** @@ -133,11 +124,11 @@ public class FireworkEffect { * @return An array of integer values corresponding to the fading colors of this firework's explosion. */ public int[] getFadeColors() { - return new int[]{ - this.fadeColor.getRed(), - this.fadeColor.getGreen(), - this.fadeColor.getBlue() - }; + int[] secondary = new int[fadeColor.size()]; + for (int i = 0; i < fadeColor.size(); i++) { + secondary[i] = fadeColor.get(i).asRGB(); + } + return secondary; } /**