mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-10 10:28:27 +01:00
Tidy up new color classes
This commit is contained in:
parent
9490f1f9da
commit
1fe159636b
@ -123,23 +123,6 @@ public class Color implements RGBLike {
|
|||||||
return (rgb << 8) + blue;
|
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
|
* 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
|
* 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
|
* @param colors the colors
|
||||||
*/
|
*/
|
||||||
public void mixWith(@NotNull Color... colors) {
|
public void mixWith(@NotNull RGBLike... colors) {
|
||||||
Validate.noNullElements(colors, "Colors cannot be null");
|
Validate.noNullElements(colors, "Colors cannot be null");
|
||||||
|
|
||||||
// store the current highest component
|
// store the current highest component
|
||||||
int max = Math.max(Math.max(this.red, this.green), this.blue);
|
int max = Math.max(Math.max(this.red, this.green), this.blue);
|
||||||
|
|
||||||
// now combine all of the color components, adding to the max
|
// now combine all of the color components, adding to the max
|
||||||
for (Color color : colors) {
|
for (RGBLike color : colors) {
|
||||||
this.red += color.getRed();
|
this.red += color.red();
|
||||||
this.green += color.getGreen();
|
this.green += color.green();
|
||||||
this.blue += color.getBlue();
|
this.blue += color.blue();
|
||||||
max += Math.max(Math.max(color.getRed(), color.getGreen()), color.getBlue());
|
max += Math.max(Math.max(color.red(), color.green()), color.blue());
|
||||||
}
|
}
|
||||||
|
|
||||||
// work out the averages
|
// work out the averages
|
||||||
|
@ -3,6 +3,8 @@ package net.minestom.server.color;
|
|||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import net.kyori.adventure.util.RGBLike;
|
import net.kyori.adventure.util.RGBLike;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
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
|
* @return the text color
|
||||||
*/
|
*/
|
||||||
public @Nullable TextColor getTextColor() {
|
public @NotNull TextColor getTextColor() {
|
||||||
return this.color;
|
return this.color;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the color equivalent to this team color, if any.
|
* Gets the color equivalent to this team color.
|
||||||
*
|
*
|
||||||
* @return the color
|
* @return the color
|
||||||
*/
|
*/
|
||||||
public @Nullable Color getColor() {
|
public @NotNull Color getColor() {
|
||||||
return this.color == null ? null : new Color(this.color);
|
return new Color(this.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user