Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update effect #12169

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions paper-api/src/main/java/org/bukkit/Color.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static Color fromRGB(int red, int green, int blue) throws IllegalArgument
* @param blue integer from 0-255
* @param green integer from 0-255
* @param red integer from 0-255
* @return a new Color object for the red, green, blue
* @return a new Color object for the blue, green, red
* @throws IllegalArgumentException if any value is strictly {@literal >255 or <0}
*/
@NotNull
Expand Down Expand Up @@ -201,10 +201,10 @@ private Color(int red, int green, int blue) {
}

private Color(int alpha, int red, int green, int blue) {
Preconditions.checkArgument(alpha >= 0 && alpha <= BIT_MASK, "Alpha[%s] is not between 0-255", alpha);
Preconditions.checkArgument(red >= 0 && red <= BIT_MASK, "Red[%s] is not between 0-255", red);
Preconditions.checkArgument(green >= 0 && green <= BIT_MASK, "Green[%s] is not between 0-255", green);
Preconditions.checkArgument(blue >= 0 && blue <= BIT_MASK, "Blue[%s] is not between 0-255", blue);
Preconditions.checkArgument(alpha >= 0 && alpha <= 0xff, "Alpha[%s] is not between 0-255", alpha);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's up with this diff? Why use the Value directly instead of BIT_MASK?

Copy link
Contributor

@lynxplay lynxplay Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am semi inclined to agree here.
I guess the intention is that "comparing a value to a mask makes no sense".

The more correct precondition I guess would be (alpha & BITMASK) == alpha.

Preconditions.checkArgument(red >= 0 && red <= 0xff, "Red[%s] is not between 0-255", red);
Preconditions.checkArgument(green >= 0 && green <= 0xff, "Green[%s] is not between 0-255", green);
Preconditions.checkArgument(blue >= 0 && blue <= 0xff, "Blue[%s] is not between 0-255", blue);

this.alpha = (byte) alpha;
this.red = (byte) red;
Expand All @@ -225,7 +225,7 @@ public int getAlpha() {
* Creates a new Color object with specified component
*
* @param alpha the alpha component, from 0 to 255
* @return a new color object with the red component
* @return a new color object with the alpha component
*/
@NotNull
public Color setAlpha(int alpha) {
Expand Down Expand Up @@ -264,8 +264,8 @@ public int getGreen() {
/**
* Creates a new Color object with specified component
*
* @param green the red component, from 0 to 255
* @return a new color object with the red component
* @param green the green component, from 0 to 255
* @return a new color object with the green component
*/
@NotNull
public Color setGreen(int green) {
Expand All @@ -284,8 +284,8 @@ public int getBlue() {
/**
* Creates a new Color object with specified component
*
* @param blue the red component, from 0 to 255
* @return a new color object with the red component
* @param blue the blue component, from 0 to 255
* @return a new color object with the blue component
*/
@NotNull
public Color setBlue(int blue) {
Expand Down Expand Up @@ -401,7 +401,6 @@ public Map<String, Object> serialize() {
);
}

@SuppressWarnings("javadoc")
@NotNull
public static Color deserialize(@NotNull Map<String, Object> map) {
return fromARGB(
Expand Down
Loading
Loading