Package org.bukkit

Class Color

java.lang.Object
org.bukkit.Color
All Implemented Interfaces:
ConfigurationSerializable

public final class Color extends 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 final Color
    Aqua, or (0x00,0xFF,0xFF) in (R,G,B)
    static final Color
    Black, or (0x00,0x00,0x00) in (R,G,B)
    static final Color
    Blue, or (0x00,0x00,0xFF) in (R,G,B)
    static final Color
    Fuchsia, or (0xFF,0x00,0xFF) in (R,G,B)
    static final Color
    Gray, or (0x80,0x80,0x80) in (R,G,B)
    static final Color
    Green, or (0x00,0x80,0x00) in (R,G,B)
    static final Color
    Lime, or (0x00,0xFF,0x00) in (R,G,B)
    static final Color
    Maroon, or (0x80,0x00,0x00) in (R,G,B)
    static final Color
    Navy, or (0x00,0x00,0x80) in (R,G,B)
    static final Color
    Olive, or (0x80,0x80,0x00) in (R,G,B)
    static final Color
    Orange, or (0xFF,0xA5,0x00) in (R,G,B)
    static final Color
    Purple, or (0x80,0x00,0x80) in (R,G,B)
    static final Color
    Red, or (0xFF,0x00,0x00) in (R,G,B)
    static final Color
    Silver, or (0xC0,0xC0,0xC0) in (R,G,B)
    static final Color
    Teal, or (0x00,0x80,0x80) in (R,G,B)
    static final Color
    White, or (0xFF,0xFF,0xFF) in (R,G,B)
    static final Color
    Yellow, or (0xFF,0xFF,0x00) in (R,G,B)
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the color as an ARGB integer.
    int
    Gets the color as an BGR integer.
    int
    Gets the color as an RGB integer.
    static Color
     
    boolean
     
    static Color
    fromARGB(int argb)
    Creates a new color object from an integer that contains the alpha, red, green, and blue bytes.
    static Color
    fromARGB(int alpha, int red, int green, int blue)
    Creates a new Color object from an alpha, red, green, and blue
    static Color
    fromBGR(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 Color
    fromBGR(int blue, int green, int red)
    Creates a new Color object from a blue, green, and red
    static Color
    fromRGB(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 Color
    fromRGB(int red, int green, int blue)
    Creates a new Color object from a red, green, and blue
    int
    Gets the alpha component
    int
    Gets the blue component
    int
    Gets the green component
    int
    Gets the red component
    int
     
    mixColors(Color... colors)
    Creates a new color with its RGB components changed as if it was dyed with the colors passed in, replicating vanilla workbench dyeing.
    mixDyes(DyeColor... colors)
    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 Map representation of this class.
    setAlpha(int alpha)
    Creates a new Color object with specified component
    setBlue(int blue)
    Creates a new Color object with specified component
    setGreen(int green)
    Creates a new Color object with specified component
    setRed(int red)
    Creates a new Color object with specified component
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • WHITE

      public static final Color WHITE
      White, or (0xFF,0xFF,0xFF) in (R,G,B)
    • SILVER

      public static final Color SILVER
      Silver, or (0xC0,0xC0,0xC0) in (R,G,B)
    • GRAY

      public static final Color GRAY
      Gray, or (0x80,0x80,0x80) in (R,G,B)
    • BLACK

      public static final Color BLACK
      Black, or (0x00,0x00,0x00) in (R,G,B)
    • RED

      public static final Color RED
      Red, or (0xFF,0x00,0x00) in (R,G,B)
    • MAROON

      public static final Color MAROON
      Maroon, or (0x80,0x00,0x00) in (R,G,B)
    • YELLOW

      public static final Color YELLOW
      Yellow, or (0xFF,0xFF,0x00) in (R,G,B)
    • OLIVE

      public static final Color OLIVE
      Olive, or (0x80,0x80,0x00) in (R,G,B)
    • LIME

      public static final Color LIME
      Lime, or (0x00,0xFF,0x00) in (R,G,B)
    • GREEN

      public static final Color GREEN
      Green, or (0x00,0x80,0x00) in (R,G,B)
    • AQUA

      public static final Color AQUA
      Aqua, or (0x00,0xFF,0xFF) in (R,G,B)
    • TEAL

      public static final Color TEAL
      Teal, or (0x00,0x80,0x80) in (R,G,B)
    • BLUE

      public static final Color BLUE
      Blue, or (0x00,0x00,0xFF) in (R,G,B)
    • FUCHSIA

      public static final Color FUCHSIA
      Fuchsia, or (0xFF,0x00,0xFF) in (R,G,B)
    • PURPLE

      public static final Color PURPLE
      Purple, or (0x80,0x00,0x80) in (R,G,B)
    • ORANGE

      public static final Color ORANGE
      Orange, or (0xFF,0xA5,0x00) in (R,G,B)
  • Method Details

    • fromARGB

      @NotNull public static Color fromARGB(int alpha, int red, int green, int blue) throws IllegalArgumentException
      Creates a new Color object from an alpha, red, green, and blue
      Parameters:
      alpha - integer from 0-255
      red - integer from 0-255
      green - integer from 0-255
      blue - 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 Color fromRGB(int red, int green, int blue) throws IllegalArgumentException
      Creates a new Color object from a red, green, and blue
      Parameters:
      red - integer from 0-255
      green - integer from 0-255
      blue - 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 Color fromBGR(int blue, int green, int red) throws IllegalArgumentException
      Creates a new Color object from a blue, green, and red
      Parameters:
      blue - integer from 0-255
      green - integer from 0-255
      red - integer from 0-255
      Returns:
      a new Color object for the red, green, blue
      Throws:
      IllegalArgumentException - if any value is strictly >255 or <0
    • fromRGB

      @NotNull public static Color fromRGB(int rgb) throws IllegalArgumentException
      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

      @NotNull public static Color fromARGB(int argb)
      Creates a new color object from an integer that contains the alpha, red, green, and blue bytes.
      Parameters:
      argb - the integer storing the alpha, red, green, and blue values
      Returns:
      a new color object for specified values
    • fromBGR

      @NotNull public static Color fromBGR(int bgr) throws IllegalArgumentException
      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

      public int getAlpha()
      Gets the alpha component
      Returns:
      alpha component, from 0 to 255
    • setAlpha

      @NotNull public Color setAlpha(int alpha)
      Creates a new Color object with specified component
      Parameters:
      alpha - the alpha component, from 0 to 255
      Returns:
      a new color object with the red component
    • getRed

      public int getRed()
      Gets the red component
      Returns:
      red component, from 0 to 255
    • setRed

      @NotNull public Color setRed(int red)
      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

      @NotNull public Color setGreen(int green)
      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

      @NotNull public Color setBlue(int blue)
      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()
      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

      @NotNull public Color mixDyes(@NotNull DyeColor... colors)
      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

      @NotNull public Color mixColors(@NotNull Color... colors)
      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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • serialize

      @NotNull public Map<String,Object> serialize()
      Description copied from interface: ConfigurationSerializable
      Creates a Map representation of this class.

      This class must provide a method to restore this class, as defined in the ConfigurationSerializable interface javadocs.

      Specified by:
      serialize in interface ConfigurationSerializable
      Returns:
      Map containing the current state of this class
    • deserialize

      @NotNull public static Color deserialize(@NotNull Map<String,Object> map)
    • toString

      public String toString()
      Overrides:
      toString in class Object