程序包 org.bukkit

类 Color

java.lang.Object
org.bukkit.Color
所有已实现的接口:
ConfigurationSerializable

public final class Color extends Object implements ConfigurationSerializable
这是一个调色板的容器。该类是不可更改的; 使用set方法可以返回一个新的自定义颜色。 这里颜色名字的列表为 HTML4 标准色, 但是随时可能更改
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    static final Color
    浅绿,或(R,G,B) 表示为 0x00,0xFF,0xFF)
    static final Color
    黑色,或(R,G,B) 表示为 0x00,0x00,0x00)
    static final Color
    蓝色,或(R,G,B) 表示为 0x00,0x00,0xFF)
    static final Color
    樱红色,或(R,G,B) 表示为 0xFF,0x00,0xFF)
    static final Color
    灰色,或(R,G,B) 表示为 0x80,0x80,0x80)
    static final Color
    绿色,或(R,G,B) 表示为 0x00,0x80,0x00)
    static final Color
    黄绿色,或(R,G,B) 表示为 0x00,0xFF,0x00)
    static final Color
    栗色,或(R,G,B) 表示为 0x80,0x00,0x00)
    static final Color
    海军色,或(R,G,B) 表示为 0x00,0x00,0x80)
    static final Color
    橄榄色,或(R,G,B) 表示为 0x80,0x80,0x00)
    static final Color
    橙色,或(R,G,B) 表示为 0xFF,0xA5,0x00)
    static final Color
    紫色,或(R,G,B) 表示为 0x80,0x00,0x80)
    static final Color
    红色,或(R,G,B) 表示为 0xFF,0x00,0x00)
    static final Color
    银色,或(R,G,B) 表示为 0xC0,0xC0,0xC0)
    static final Color
    蓝绿色,或(R,G,B) 表示为 0x00,0x80,0x80)
    static final Color
    白色,或(R,G,B) 表示为 0xFF,0xFF,0xFF)
    static final Color
    黄色,或(R,G,B) 表示为 0xFF,0xFF,0x00)
  • 方法概要

    修饰符和类型
    方法
    说明
    int
    获取此颜色的ARGB整数表示.
    int
    获取此颜色的BGR整数表示.
    int
    获取此颜色的RGB整数表示.
     
    boolean
     
    fromARGB(int argb)
    从一个包含透明度、红、绿、蓝字节的整数中创建一个新的颜色对象.
    fromARGB(int alpha, int red, int green, int blue)
    用透明度、红、绿、蓝创建一个新的颜色对象.
    fromBGR(int bgr)
    从一个包含蓝、绿、红字节的整数中创建一个新的颜色对象,该整数在最低24位中存储.
    fromBGR(int blue, int green, int red)
    用蓝、绿、红创建一个新的颜色对象.
    fromRGB(int rgb)
    从一个RGB整数中创建一个新的颜色对象,该对象包含最低24位.
    fromRGB(int red, int green, int blue)
    用红、绿、蓝创建一个新的颜色对象.
    int
    获取透明度分量.
    int
    获取蓝色分量.
    int
    获取绿色分量.
    int
    获取红色分量.
    int
     
    使用传入的颜色对当前颜色的RGB分量进行染色,创建一个新的颜色,模拟原版工作台染色.
    使用传入的染料颜色对当前颜色的RGB分量进行染色,创建一个新的颜色,模拟原版工作台染色.
    创建此类的 Map 表示。
    setAlpha(int alpha)
    用指定的透明度分量创建一个新的颜色对象.
    setBlue(int blue)
    用指定的蓝色分量创建一个新的颜色对象.
    setGreen(int green)
    用指定的绿色分量创建一个新的颜色对象.
    setRed(int red)
    用指定的红色分量创建一个新的颜色对象.
     

    从类继承的方法 java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 字段详细资料

    • WHITE

      public static final Color WHITE
      白色,或(R,G,B) 表示为 0xFF,0xFF,0xFF)
    • SILVER

      public static final Color SILVER
      银色,或(R,G,B) 表示为 0xC0,0xC0,0xC0)
    • GRAY

      public static final Color GRAY
      灰色,或(R,G,B) 表示为 0x80,0x80,0x80)
    • BLACK

      public static final Color BLACK
      黑色,或(R,G,B) 表示为 0x00,0x00,0x00)
    • RED

      public static final Color RED
      红色,或(R,G,B) 表示为 0xFF,0x00,0x00)
    • MAROON

      public static final Color MAROON
      栗色,或(R,G,B) 表示为 0x80,0x00,0x00)
    • YELLOW

      public static final Color YELLOW
      黄色,或(R,G,B) 表示为 0xFF,0xFF,0x00)
    • OLIVE

      public static final Color OLIVE
      橄榄色,或(R,G,B) 表示为 0x80,0x80,0x00)
    • LIME

      public static final Color LIME
      黄绿色,或(R,G,B) 表示为 0x00,0xFF,0x00)
    • GREEN

      public static final Color GREEN
      绿色,或(R,G,B) 表示为 0x00,0x80,0x00)
    • AQUA

      public static final Color AQUA
      浅绿,或(R,G,B) 表示为 0x00,0xFF,0xFF)
    • TEAL

      public static final Color TEAL
      蓝绿色,或(R,G,B) 表示为 0x00,0x80,0x80)
    • BLUE

      public static final Color BLUE
      蓝色,或(R,G,B) 表示为 0x00,0x00,0xFF)
    • FUCHSIA

      public static final Color FUCHSIA
      樱红色,或(R,G,B) 表示为 0xFF,0x00,0xFF)
    • PURPLE

      public static final Color PURPLE
      紫色,或(R,G,B) 表示为 0x80,0x00,0x80)
    • ORANGE

      public static final Color ORANGE
      橙色,或(R,G,B) 表示为 0xFF,0xA5,0x00)
  • 方法详细资料

    • fromARGB

      @NotNull public static @NotNull Color fromARGB(int alpha, int red, int green, int blue) throws IllegalArgumentException
      用透明度、红、绿、蓝创建一个新的颜色对象.

      原文:Creates a new Color object from an alpha, red, green, and blue

      参数:
      alpha - 0-255的整数
      red - 0-255的整数
      green - 0-255的整数
      blue - 0-255的整数
      返回:
      一个包含指定透明度、红、绿、蓝值的新颜色对象
      抛出:
      IllegalArgumentException - 如果任何值严格 >255 或 <0
    • fromRGB

      @NotNull public static @NotNull Color fromRGB(int red, int green, int blue) throws IllegalArgumentException
      用红、绿、蓝创建一个新的颜色对象.

      原文:Creates a new Color object from an alpha, red, green, and blue

      参数:
      red - 0-255的整数
      green - 0-255的整数
      blue - 0-255的整数
      返回:
      一个RGB颜色对象
      抛出:
      IllegalArgumentException - 如果任何值严格 >255 或 <0
    • fromBGR

      @NotNull public static @NotNull Color fromBGR(int blue, int green, int red) throws IllegalArgumentException
      用蓝、绿、红创建一个新的颜色对象.

      原文:Creates a new Color object from an alpha, red, green, and blue

      参数:
      blue - 0-255的整数
      green - 0-255的整数
      red - 0-255的整数
      返回:
      一个包含指定红、绿、蓝值的新颜色对象
      抛出:
      IllegalArgumentException - 任何一个参数超出 >255 或 <0 范围
    • fromRGB

      @NotNull public static @NotNull Color fromRGB(int rgb) throws IllegalArgumentException
      从一个RGB整数中创建一个新的颜色对象,该对象包含最低24位.

      原文:Creates a new Color object from an integer that contains the alpha, red, green, and blue bytes.

      参数:
      rgb - 存储红、绿、蓝值的整数
      返回:
      一个包含指定值的新颜色对象
      抛出:
      IllegalArgumentException - 如果最高8位有任何数据
    • fromARGB

      @NotNull public static @NotNull Color fromARGB(int argb)
      从一个包含透明度、红、绿、蓝字节的整数中创建一个新的颜色对象.

      原文:Creates a new color object from an integer that contains the alpha, red, green, and blue bytes.

      参数:
      argb - 存储透明度、红、绿、蓝值的整数
      返回:
      一个包含指定值的新颜色对象
    • fromBGR

      @NotNull public static @NotNull Color fromBGR(int bgr) throws IllegalArgumentException
      从一个包含蓝、绿、红字节的整数中创建一个新的颜色对象,该整数在最低24位中存储.

      原文:Creates a new color object from an integer that contains the blue, green, and red bytes in the lowest order 24 bits.

      参数:
      bgr - 存储蓝、绿、红值的整数
      返回:
      一个包含指定值的新颜色对象
      抛出:
      IllegalArgumentException - 如果最高8位有任何数据
    • getAlpha

      public int getAlpha()
      获取透明度分量.

      原文:Gets the alpha component

      返回:
      透明度分量,范围0-255
    • setAlpha

      @NotNull public @NotNull Color setAlpha(int alpha)
      用指定的透明度分量创建一个新的颜色对象.

      原文:Creates a new Color object with specified component

      参数:
      alpha - 透明度分量,范围0-255
      返回:
      一个包含指定透明度分量的新颜色对象
    • getRed

      public int getRed()
      获取红色分量.

      原文:Gets the red component

      返回:
      红色分量,范围0-255
    • setRed

      @NotNull public @NotNull Color setRed(int red)
      用指定的红色分量创建一个新的颜色对象.

      原文:Creates a new Color object with specified component

      参数:
      red - 红色分量,范围0-255
      返回:
      一个包含指定红色分量的新颜色对象
    • getGreen

      public int getGreen()
      获取绿色分量.

      原文:Gets the green component

      返回:
      绿色分量,范围0-255
    • setGreen

      @NotNull public @NotNull Color setGreen(int green)
      用指定的绿色分量创建一个新的颜色对象.

      原文:Creates a new Color object with specified component

      参数:
      green - 绿色分量,范围0-255
      返回:
      一个包含指定绿色分量的新颜色对象
    • getBlue

      public int getBlue()
      获取蓝色分量.

      原文:Gets the blue component

      返回:
      蓝色分量,范围0-255
    • setBlue

      @NotNull public @NotNull Color setBlue(int blue)
      用指定的蓝色分量创建一个新的颜色对象.

      原文:Creates a new Color object with specified component

      参数:
      blue - 蓝色分量,范围0-255
      返回:
      一个包含指定蓝色分量的新颜色对象
    • asRGB

      public int asRGB()
      获取此颜色的RGB整数表示.

      原文:Gets the color as an RGB integer.

      返回:
      此颜色的整数表示,格式为0xRRGGBB
    • asARGB

      public int asARGB()
      获取此颜色的ARGB整数表示.

      原文:Gets the color as an ARGB integer.

      返回:
      此颜色的整数表示,格式为0xAARRGGBB
    • asBGR

      public int asBGR()
      获取此颜色的BGR整数表示.

      原文:Gets the color as an BGR integer.

      返回:
      此颜色的整数表示,格式为0xBBGGRR
    • mixDyes

      @NotNull public @NotNull Color mixDyes(@NotNull @NotNull DyeColor... colors)
      使用传入的染料颜色对当前颜色的RGB分量进行染色,创建一个新的颜色,模拟原版工作台染色.

      原文:Creates a new color with its RGB components changed as if it was dyed with the colors passed in, replicating vanilla workbench dyeing

      参数:
      colors - 用于染色的染料颜色
      返回:
      一个RGB分量改变后的新颜色
    • mixColors

      @NotNull public @NotNull Color mixColors(@NotNull @NotNull Color... colors)
      使用传入的颜色对当前颜色的RGB分量进行染色,创建一个新的颜色,模拟原版工作台染色.

      原文: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.

      参数:
      colors - 用于染色的颜色
      返回:
      一个RGB分量改变后的新颜色
    • equals

      public boolean equals(Object o)
      覆盖:
      equals 在类中 Object
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object
    • serialize

      @NotNull public @NotNull Map<String,Object> serialize()
      从接口复制的说明: ConfigurationSerializable
      创建此类的 Map 表示。

      此类必须提供一个方法来恢复此类,具体定义见 ConfigurationSerializable 接口的 javadoc。

      原文:Creates a Map representation of this class.

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

      指定者:
      serialize 在接口中 ConfigurationSerializable
      返回:
      包含此类当前状态的 Map
    • deserialize

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

      public String toString()
      覆盖:
      toString 在类中 Object