Package org.bukkit
Class Color
java.lang.Object
org.bukkit.Color
- All Implemented Interfaces:
ConfigurationSerializable
public final class Color extends java.lang.Object implements 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
Fields Modifier and Type Field Description static ColorAQUAAqua, or (0x00,0xFF,0xFF) in (R,G,B)static ColorBLACKBlack, or (0x00,0x00,0x00) in (R,G,B)static ColorBLUEBlue, or (0x00,0x00,0xFF) in (R,G,B)static ColorFUCHSIAFuchsia, or (0xFF,0x00,0xFF) in (R,G,B)static ColorGRAYGray, or (0x80,0x80,0x80) in (R,G,B)static ColorGREENGreen, or (0x00,0x80,0x00) in (R,G,B)static ColorLIMELime, or (0x00,0xFF,0x00) in (R,G,B)static ColorMAROONMaroon, or (0x80,0x00,0x00) in (R,G,B)static ColorNAVYNavy, or (0x00,0x00,0x80) in (R,G,B)static ColorOLIVEOlive, or (0x80,0x80,0x00) in (R,G,B)static ColorORANGEOrange, or (0xFF,0xA5,0x00) in (R,G,B)static ColorPURPLEPurple, or (0x80,0x00,0x80) in (R,G,B)static ColorREDRed, or (0xFF,0x00,0x00) in (R,G,B)static ColorSILVERSilver, or (0xC0,0xC0,0xC0) in (R,G,B)static ColorTEALTeal, or (0x00,0x80,0x80) in (R,G,B)static ColorWHITEWhite, or (0xFF,0xFF,0xFF) in (R,G,B)static ColorYELLOWYellow, or (0xFF,0xFF,0x00) in (R,G,B) -
Method Summary
Modifier and Type Method Description intasBGR()intasRGB()static Colordeserialize(java.util.Map<java.lang.String,java.lang.Object> map)booleanequals(java.lang.Object o)static ColorfromBGR(int bgr)Creates a new color object from an integer that contains the blue, green, and red bytes in the lowest order 24 bits.static ColorfromBGR(int blue, int green, int red)Creates a new Color object from a blue, green, and redstatic ColorfromRGB(int rgb)Creates a new color object from an integer that contains the red, green, and blue bytes in the lowest order 24 bits.static ColorfromRGB(int red, int green, int blue)Creates a new Color object from a red, green, and blueintgetBlue()Gets the blue componentintgetGreen()Gets the green componentintgetRed()Gets the red componentinthashCode()ColormixColors(Color... colors)Creates a new color with its RGB components changed as if it was dyed with the colors passed in, replicating vanilla workbench dyeingColormixDyes(DyeColor... colors)Creates a new color with its RGB components changed as if it was dyed with the colors passed in, replicating vanilla workbench dyeingjava.util.Map<java.lang.String,java.lang.Object>serialize()Creates a Map representation of this class.ColorsetBlue(int blue)Creates a new Color object with specified componentColorsetGreen(int green)Creates a new Color object with specified componentColorsetRed(int red)Creates a new Color object with specified componentjava.lang.StringtoString()
-
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
-
fromRGB
public static Color fromRGB(int red, int green, int blue) throws java.lang.IllegalArgumentExceptionCreates 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:
java.lang.IllegalArgumentException- if any value is strictly >255 or <0
-
fromBGR
public static Color fromBGR(int blue, int green, int red) throws java.lang.IllegalArgumentExceptionCreates 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 red, green, blue
- Throws:
java.lang.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:
java.lang.IllegalArgumentException- if any data is in the highest order 8 bits
-
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:
java.lang.IllegalArgumentException- if any data is in the highest order 8 bits
-
getRed
public int getRed()Gets the red component- Returns:
- red component, from 0 to 255
-
setRed
Creates a new Color object with specified component- Parameters:
red- the red component, from 0 to 255- Returns:
- a new color object with the red component
-
getGreen
public int getGreen()Gets the green component- Returns:
- green component, from 0 to 255
-
setGreen
Creates a new Color object with specified component- Parameters:
green- the red component, from 0 to 255- Returns:
- a new color object with the red component
-
getBlue
public int getBlue()Gets the blue component- Returns:
- blue component, from 0 to 255
-
setBlue
Creates a new Color object with specified component- Parameters:
blue- the red component, from 0 to 255- Returns:
- a new color object with the red component
-
asRGB
public int asRGB()- Returns:
- An integer representation of this color, as 0xRRGGBB
-
asBGR
public int asBGR()- 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- Parameters:
colors- The colors to dye with- Returns:
- A new color with the changed rgb components
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
serialize
public java.util.Map<java.lang.String,java.lang.Object> 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.- Specified by:
serializein interfaceConfigurationSerializable- Returns:
- Map containing the current state of this class
-
deserialize
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-