Class Color
java.lang.Object
org.bukkit.Color
- All Implemented Interfaces:
ARGBLike, RGBLike, ConfigurationSerializable
A container for a color palette. This class is immutable; the set methods
return a new color. The color names listed as fields are HTML4 standards,
but subject to change.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ColorAqua, or (0x00,0xFF,0xFF) in (R,G,B)static final ColorBlack, or (0x00,0x00,0x00) in (R,G,B)static final ColorBlue, or (0x00,0x00,0xFF) in (R,G,B)static final ColorFuchsia, or (0xFF,0x00,0xFF) in (R,G,B)static final ColorGray, or (0x80,0x80,0x80) in (R,G,B)static final ColorGreen, or (0x00,0x80,0x00) in (R,G,B)static final ColorLime, or (0x00,0xFF,0x00) in (R,G,B)static final ColorMaroon, or (0x80,0x00,0x00) in (R,G,B)static final ColorNavy, or (0x00,0x00,0x80) in (R,G,B)static final ColorOlive, or (0x80,0x80,0x00) in (R,G,B)static final ColorOrange, or (0xFF,0xA5,0x00) in (R,G,B)static final ColorPurple, or (0x80,0x00,0x80) in (R,G,B)static final ColorRed, or (0xFF,0x00,0x00) in (R,G,B)static final ColorSilver, or (0xC0,0xC0,0xC0) in (R,G,B)static final ColorTeal, or (0x00,0x80,0x80) in (R,G,B)static final ColorWhite, or (0xFF,0xFF,0xFF) in (R,G,B)static final ColorYellow, or (0xFF,0xFF,0x00) in (R,G,B) -
Method Summary
Modifier and TypeMethodDescriptionalpha()Gets the alpha component.intasARGB()Gets the color as an ARGB integer.intasBGR()Gets the color as an BGR integer.intasRGB()Gets the color as an RGB integer.blue()Gets the blue component.deserialize(@NotNull Map<String, Object> map) booleanfromARGB(@Range(from=0L,to=255L) int alpha, @Range(from=0L,to=255L) int red, @Range(from=0L,to=255L) int green, @Range(from=0L,to=255L) int blue) Creates a new Color object from an alpha, red, green, and bluefromARGB(int argb) Creates a new color object from an integer that contains the alpha, red, green, and blue bytes.fromBGR(@Range(from=0L,to=255L) int blue, @Range(from=0L,to=255L) int green, @Range(from=0L,to=255L) int red) Creates a new Color object from a blue, green, and redfromBGR(int bgr) Creates a new color object from an integer that contains the blue, green, and red bytes in the lowest order 24 bits.fromRGB(@Range(from=0L,to=255L) int red, @Range(from=0L,to=255L) int green, @Range(from=0L,to=255L) int blue) Creates a new Color object from a red, green, and bluefromRGB(int rgb) Creates a new color object from an integer that contains the red, green, and blue bytes in the lowest order 24 bits.getAlpha()Gets the alpha component.getBlue()Gets the blue component.getGreen()Gets the green component.getRed()Gets the red component.green()Gets the green component.inthashCode()Creates a new color with its RGB components changed as if it was dyed with the colors passed in, replicating vanilla workbench dyeing.Creates a new color with its RGB components changed as if it was dyed with the colors passed in, replicating vanilla workbench dyeing.red()Gets the red component.Creates a Map representation of this class.Creates a new Color object with a specified component.Creates a new Color object with a specified component.Creates a new Color object with a specified component.Creates a new Color object with a specified component.toString()
-
Field Details
-
WHITE
White, or (0xFF,0xFF,0xFF) in (R,G,B) -
SILVER
Silver, or (0xC0,0xC0,0xC0) in (R,G,B) -
GRAY
Gray, or (0x80,0x80,0x80) in (R,G,B) -
BLACK
Black, or (0x00,0x00,0x00) in (R,G,B) -
RED
Red, or (0xFF,0x00,0x00) in (R,G,B) -
MAROON
Maroon, or (0x80,0x00,0x00) in (R,G,B) -
YELLOW
Yellow, or (0xFF,0xFF,0x00) in (R,G,B) -
OLIVE
Olive, or (0x80,0x80,0x00) in (R,G,B) -
LIME
Lime, or (0x00,0xFF,0x00) in (R,G,B) -
GREEN
Green, or (0x00,0x80,0x00) in (R,G,B) -
AQUA
Aqua, or (0x00,0xFF,0xFF) in (R,G,B) -
TEAL
Teal, or (0x00,0x80,0x80) in (R,G,B) -
BLUE
Blue, or (0x00,0x00,0xFF) in (R,G,B) -
NAVY
Navy, or (0x00,0x00,0x80) in (R,G,B) -
FUCHSIA
Fuchsia, or (0xFF,0x00,0xFF) in (R,G,B) -
PURPLE
Purple, or (0x80,0x00,0x80) in (R,G,B) -
ORANGE
Orange, or (0xFF,0xA5,0x00) in (R,G,B)
-
-
Method Details
-
fromARGB
@NotNull public static @NotNull Color fromARGB(@Range(from=0L,to=255L) int alpha, @Range(from=0L,to=255L) int red, @Range(from=0L,to=255L) int green, @Range(from=0L,to=255L) int blue) throws IllegalArgumentException Creates a new Color object from an alpha, red, green, and blue- Parameters:
alpha- integer from 0-255red- integer from 0-255green- integer from 0-255blue- integer from 0-255- Returns:
- a new Color object for the alpha, red, green, blue
- Throws:
IllegalArgumentException- if any value is strictly >255 or <0
-
fromRGB
@NotNull public static @NotNull Color fromRGB(@Range(from=0L,to=255L) int red, @Range(from=0L,to=255L) int green, @Range(from=0L,to=255L) int blue) throws IllegalArgumentException Creates a new Color object from a red, green, and blue- Parameters:
red- integer from 0-255green- integer from 0-255blue- integer from 0-255- Returns:
- a new Color object for the red, green, blue
- Throws:
IllegalArgumentException- if any value is strictly >255 or <0
-
fromBGR
@NotNull public static @NotNull Color fromBGR(@Range(from=0L,to=255L) int blue, @Range(from=0L,to=255L) int green, @Range(from=0L,to=255L) int red) throws IllegalArgumentException Creates a new Color object from a blue, green, and red- Parameters:
blue- integer from 0-255green- integer from 0-255red- integer from 0-255- Returns:
- a new Color object for the blue, green, red
- Throws:
IllegalArgumentException- if any value is strictly >255 or <0
-
fromRGB
Creates a new color object from an integer that contains the red, green, and blue bytes in the lowest order 24 bits.- Parameters:
rgb- the integer storing the red, green, and blue values- Returns:
- a new color object for specified values
- Throws:
IllegalArgumentException- if any data is in the highest order 8 bits
-
fromARGB
-
fromBGR
Creates a new color object from an integer that contains the blue, green, and red bytes in the lowest order 24 bits.- Parameters:
bgr- the integer storing the blue, green, and red values- Returns:
- a new color object for specified values
- Throws:
IllegalArgumentException- if any data is in the highest order 8 bits
-
getAlpha
-
alpha
-
setAlpha
-
getRed
-
red
-
setRed
-
getGreen
-
green
-
setGreen
-
getBlue
-
blue
-
setBlue
-
asRGB
public int asRGB()Gets the color as an RGB integer.- Returns:
- An integer representation of this color, as 0xRRGGBB
-
asARGB
public int asARGB()Gets the color as an ARGB integer.- Returns:
- An integer representation of this color, as 0xAARRGGBB
-
asBGR
public int asBGR()Gets the color as an BGR integer.- Returns:
- An integer representation of this color, as 0xBBGGRR
-
mixDyes
Creates a new color with its RGB components changed as if it was dyed with the colors passed in, replicating vanilla workbench dyeing.- Parameters:
colors- The DyeColors to dye with- Returns:
- A new color with the changed rgb components
-
mixColors
Creates a new color with its RGB components changed as if it was dyed with the colors passed in, replicating vanilla workbench dyeing.
Note that this method does not currently take into account alpha components.- Parameters:
colors- The colors to dye with- Returns:
- A new color with the changed rgb components
-
equals
-
hashCode
-
serialize
Description copied from interface:ConfigurationSerializableCreates a Map representation of this class.This class must provide a method to restore this class, as defined in the
ConfigurationSerializableinterface javadocs. nb: It is not intended for this method to be called directly, this will be called by theConfigurationSerializationclass.- Specified by:
serializein interfaceConfigurationSerializable- Returns:
- Map containing the current state of this class
-
deserialize
-
toString
-