From 1fe159636b58d8f7352b9b7afbb18cd9e3339e4e Mon Sep 17 00:00:00 2001 From: Kieran Wallbanks Date: Wed, 24 Mar 2021 12:51:31 +0000 Subject: [PATCH] Tidy up new color classes --- .../java/net/minestom/server/color/Color.java | 29 ++++--------------- .../net/minestom/server/color/TeamColor.java | 12 ++++---- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/src/main/java/net/minestom/server/color/Color.java b/src/main/java/net/minestom/server/color/Color.java index 56a942ae5..72f69d637 100644 --- a/src/main/java/net/minestom/server/color/Color.java +++ b/src/main/java/net/minestom/server/color/Color.java @@ -123,23 +123,6 @@ public class Color implements RGBLike { return (rgb << 8) + blue; } - /** - * Shorthand method for {@link #mixWith(Color...)}. This method converts each dye - * color to a color and then mixes this color with the new colors. - * - * @param dyeColors the dye colors - */ - public void mixWith(@NotNull DyeColor... dyeColors) { - Validate.noNullElements(dyeColors, "Colors cannot be null"); - - Color[] colors = new Color[dyeColors.length]; - for (int i = 0; i < colors.length; i++) { - colors[i] = dyeColors[i].getColor(); - } - - this.mixWith(colors); - } - /** * Mixes this color with a series of other colors, as if they were combined in a * crafting table. This function works out the average of each RGB component and then @@ -149,18 +132,18 @@ public class Color implements RGBLike { * * @param colors the colors */ - public void mixWith(@NotNull Color... colors) { + public void mixWith(@NotNull RGBLike... colors) { Validate.noNullElements(colors, "Colors cannot be null"); // store the current highest component int max = Math.max(Math.max(this.red, this.green), this.blue); // now combine all of the color components, adding to the max - for (Color color : colors) { - this.red += color.getRed(); - this.green += color.getGreen(); - this.blue += color.getBlue(); - max += Math.max(Math.max(color.getRed(), color.getGreen()), color.getBlue()); + for (RGBLike color : colors) { + this.red += color.red(); + this.green += color.green(); + this.blue += color.blue(); + max += Math.max(Math.max(color.red(), color.green()), color.blue()); } // work out the averages diff --git a/src/main/java/net/minestom/server/color/TeamColor.java b/src/main/java/net/minestom/server/color/TeamColor.java index 7f62ad4f2..0ed60484e 100644 --- a/src/main/java/net/minestom/server/color/TeamColor.java +++ b/src/main/java/net/minestom/server/color/TeamColor.java @@ -3,6 +3,8 @@ package net.minestom.server.color; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.util.RGBLike; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -34,21 +36,21 @@ public enum TeamColor implements RGBLike { } /** - * Gets the text color equivalent to this team color, if any. + * Gets the text color equivalent to this team color. * * @return the text color */ - public @Nullable TextColor getTextColor() { + public @NotNull TextColor getTextColor() { return this.color; } /** - * Gets the color equivalent to this team color, if any. + * Gets the color equivalent to this team color. * * @return the color */ - public @Nullable Color getColor() { - return this.color == null ? null : new Color(this.color); + public @NotNull Color getColor() { + return new Color(this.color); } /**