Enum Class O2Color
- All Implemented Interfaces:
Serializable,Comparable<O2Color>,Constable
Minecraft handles colors inconsistently across different contexts - chat messages use ChatColor and format codes (§), items use Color, and blocks use DyeColor. This enum provides unified access to all color representations, allowing seamless conversion between formats.
When to use each color representation:
getBukkitColor()- For items and potions (Color class)getChatColor()- For chat messages in commands and player messages (ChatColor enum)getChatColorCode()- For text formatting in books and signs using color codes like "§c" for redgetDyeColor()- For dyeable blocks like wool, concrete, and glass (DyeColor enum)
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionaqua - Color.AQUA, ChatColor.AQUA, "§b", DyeColor.LIGHT_BLUEblack - Color.BLACK, ChatColor.BLACK, "§0", DyeColor.BLACKblue - Color.BLUE, ChatColor.BLUE, "§9", DyeColor.BLUEbrown - Color.ORANGE, ChatColor.GOLD, "§6", DyeColor.BROWNcyan - Color.TEAL, ChatColor.DARK_AQUA, "§3", DyeColor.CYANdark blue - Color.NAVY, ChatColor.DARK_BLUE, "§1", DyeColor.BLUEdark gray - Color.GRAY, ChatColor.GRAY, "§8", DyeColor.GRAYdark green - Color.GREEN, ChatColor.DARK_GREEN, "§2", DyeColor.GREENdark red - Color.RED, ChatColor.RED, "§4", DyeColor.REDfuschia - Color.FUCHSIA, ChatColor.LIGHT_PURPLE, "§d", DyeColor.PINKgold - Color.YELLOW, ChatColor.GOLD, "§6", DyeColor.YELLOWgray - Color.GRAY, ChatColor.GRAY, "§7", DyeColor.LIGHT_GRAYgreen - Color.GREEN, ChatColor.GREEN, "§a", DyeColor.GREENlight blue - Color.TEAL, ChatColor.BLUE, "§9", DyeColor.LIGHT_BLUElight gray - Color.SILVER, ChatColor.GRAY, "§7", DyeColor.LIGHT_GRAYlight purple - Color.FUCHSIA, ChatColor.LIGHT_PURPLE, "§d", DyeColor.PURPLElime - Color.LIME, ChatColor.GREEN, "§a", DyeColor.LIMEmagenta - Color.PURPLE, ChatColor.DARK_PURPLE, "§5", DyeColor.MAGENTAmaroon - Color.MAROON, ChatColor.DARK_RED, "§4", DyeColor.REDnavy - Color.NAVY, ChatColor.DARK_BLUE, "§1", DyeColor.BLUEolive - Color.OLIVE, ChatColor.DARK_GREEN, "§2", DyeColor.GREENorange - Color.ORANGE, ChatColor.GOLD, "§6", DyeColor.ORANGEpink - Color.FUCHSIA, ChatColor.LIGHT_PURPLE, "§d", DyeColor.PINKpurple - Color.PURPLE, ChatColor.DARK_PURPLE, "§5", DyeColor.PURPLEred - Color.RED, ChatColor.RED, "§c", DyeColor.REDsilver - Color.SILVER, ChatColor.GRAY, "§7", DyeColor.LIGHT_GRAYteal - Color.TEAL, ChatColor.DARK_AQUA, "§3", DyeColor.CYANwhite - Color.WHITE, ChatColor.WHITE, "§f", DyeColor.WHITEyellow - Color.YELLOW, ChatColor.YELLOW, "§e", DyeColor.YELLOW -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.MaterialchangeColor(@NotNull org.bukkit.Material material, @NotNull O2Color color) Change a colorable material to a new color.@NotNull org.bukkit.ColorGet the Bukkit Color object for this color.static @NotNull O2ColorgetBukkitColorByNumber(int number) Get the Bukkit color associated with a numeric color code.@NotNull org.bukkit.ChatColorGet the ChatColor enum value for this color.@NotNull StringGet the chat format code for this color.@Nullable org.bukkit.MaterialgetColoredMaterial(String materialBaseName) Get the colored material variant for this color with the given base material name.@NotNull org.bukkit.DyeColorGet the DyeColor enum value for this color.static @NotNull O2ColorGet a random dyeable color.static @NotNull O2ColorgetRandomDyeableColor(int seed) Get a dyeable color based on the provided seed.static @NotNull O2ColorGet a random primary dyeable color.static @NotNull O2ColorgetRandomPrimaryDyeableColor(int seed) Get a primary dyeable color based on the provided seed.static booleanisColorable(@NotNull org.bukkit.Material material) Check whether a material can be dyed to different colors.static O2ColorReturns the enum constant of this class with the specified name.static O2Color[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
AQUA
aqua - Color.AQUA, ChatColor.AQUA, "§b", DyeColor.LIGHT_BLUE -
BLACK
black - Color.BLACK, ChatColor.BLACK, "§0", DyeColor.BLACK -
BLUE
blue - Color.BLUE, ChatColor.BLUE, "§9", DyeColor.BLUE -
BROWN
brown - Color.ORANGE, ChatColor.GOLD, "§6", DyeColor.BROWN -
CYAN
cyan - Color.TEAL, ChatColor.DARK_AQUA, "§3", DyeColor.CYAN -
DARK_BLUE
dark blue - Color.NAVY, ChatColor.DARK_BLUE, "§1", DyeColor.BLUE -
DARK_GRAY
dark gray - Color.GRAY, ChatColor.GRAY, "§8", DyeColor.GRAY -
DARK_GREEN
dark green - Color.GREEN, ChatColor.DARK_GREEN, "§2", DyeColor.GREEN -
DARK_RED
dark red - Color.RED, ChatColor.RED, "§4", DyeColor.RED -
FUCHSIA
fuschia - Color.FUCHSIA, ChatColor.LIGHT_PURPLE, "§d", DyeColor.PINK -
GOLD
gold - Color.YELLOW, ChatColor.GOLD, "§6", DyeColor.YELLOW -
GRAY
gray - Color.GRAY, ChatColor.GRAY, "§7", DyeColor.LIGHT_GRAY -
GREEN
green - Color.GREEN, ChatColor.GREEN, "§a", DyeColor.GREEN -
LIGHT_BLUE
light blue - Color.TEAL, ChatColor.BLUE, "§9", DyeColor.LIGHT_BLUE -
LIGHT_GRAY
light gray - Color.SILVER, ChatColor.GRAY, "§7", DyeColor.LIGHT_GRAY -
LIGHT_PURPLE
light purple - Color.FUCHSIA, ChatColor.LIGHT_PURPLE, "§d", DyeColor.PURPLE -
LIME
lime - Color.LIME, ChatColor.GREEN, "§a", DyeColor.LIME -
MAGENTA
magenta - Color.PURPLE, ChatColor.DARK_PURPLE, "§5", DyeColor.MAGENTA -
MAROON
maroon - Color.MAROON, ChatColor.DARK_RED, "§4", DyeColor.RED -
NAVY
navy - Color.NAVY, ChatColor.DARK_BLUE, "§1", DyeColor.BLUE -
OLIVE
olive - Color.OLIVE, ChatColor.DARK_GREEN, "§2", DyeColor.GREEN -
ORANGE
orange - Color.ORANGE, ChatColor.GOLD, "§6", DyeColor.ORANGE -
PINK
pink - Color.FUCHSIA, ChatColor.LIGHT_PURPLE, "§d", DyeColor.PINK -
PURPLE
purple - Color.PURPLE, ChatColor.DARK_PURPLE, "§5", DyeColor.PURPLE -
RED
red - Color.RED, ChatColor.RED, "§c", DyeColor.RED -
SILVER
silver - Color.SILVER, ChatColor.GRAY, "§7", DyeColor.LIGHT_GRAY -
TEAL
teal - Color.TEAL, ChatColor.DARK_AQUA, "§3", DyeColor.CYAN -
WHITE
white - Color.WHITE, ChatColor.WHITE, "§f", DyeColor.WHITE -
YELLOW
yellow - Color.YELLOW, ChatColor.YELLOW, "§e", DyeColor.YELLOW
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getBukkitColor
@NotNull public @NotNull org.bukkit.Color getBukkitColor()Get the Bukkit Color object for this color. Used for coloring items such as potions, leather armor, and other colorable items.- Returns:
- the Bukkit Color object
-
getChatColor
@NotNull public @NotNull org.bukkit.ChatColor getChatColor()Get the ChatColor enum value for this color. Used for chat messages, command messages, and other player-facing text.- Returns:
- the ChatColor enum value
-
getChatColorCode
Get the chat format code for this color. Format is the section symbol (§) followed by a hexadecimal character (e.g., "§c" for red). Used for formatting text in books, signs, and other text-based UI elements.- Returns:
- the chat color code as a string
-
getDyeColor
@NotNull public @NotNull org.bukkit.DyeColor getDyeColor()Get the DyeColor enum value for this color. Used for dyeable blocks such as wool, concrete, glass, banners, candles, and shulker boxes.- Returns:
- the DyeColor enum value
-
getColoredMaterial
Get the colored material variant for this color with the given base material name.Minecraft colorable materials follow the naming convention:
COLOR_MATERIAL(e.g., "RED_WOOL", "BLUE_CONCRETE", "WHITE_GLASS"). This method constructs the full material name by combining the DyeColor prefix with the provided base name.- Parameters:
materialBaseName- the base material name without color prefix (e.g., "WOOL", "CONCRETE", "GLASS")- Returns:
- the colored Material (e.g., Material.RED_WOOL), or null if the colored variant doesn't exist
-
getBukkitColorByNumber
Get the Bukkit color associated with a numeric color code.Converts numeric color codes (0-15) to their corresponding O2Color from the legacy Minecraft color palette. This is useful for working with older data formats or system that use numeric color indices.
- Parameters:
number- a number between 0-15 corresponding to the legacy Minecraft color palette- Returns:
- the O2Color at the specified index, or WHITE if the number is out of range (negative or >= 16)
-
getRandomPrimaryDyeableColor
Get a random primary dyeable color.Returns one of the six primary dye colors: red, orange, yellow, green, blue, or purple. Uses a random seed from
Ollivanders2Common.random.- Returns:
- a random O2Color from the primary dyeable colors array
- See Also:
-
getRandomPrimaryDyeableColor
Get a primary dyeable color based on the provided seed.Returns one of the six primary dye colors: red, orange, yellow, green, blue, or purple. The seed is used with modulo arithmetic to select from the available colors.
- Parameters:
seed- the base value to determine which color is selected (using modulo)- Returns:
- a primary dyeable color from the seed value
-
getRandomDyeableColor
Get a random dyeable color.Returns one of the 16 available dye colors that can be applied to dyeable blocks. Uses a random seed from
Ollivanders2Common.random.- Returns:
- a random O2Color from the complete dyeable colors array
- See Also:
-
getRandomDyeableColor
Get a dyeable color based on the provided seed.Returns one of the 16 available dye colors that can be applied to dyeable blocks like wool, concrete, and glass. The seed is used with modulo arithmetic to select from the available colors.
- Parameters:
seed- the base value to determine which color is selected (using modulo)- Returns:
- a dyeable color from the seed value
-
isColorable
public static boolean isColorable(@NotNull @NotNull org.bukkit.Material material) Check whether a material can be dyed to different colors.Colorable materials follow the naming pattern
COLOR_BASE(e.g., "RED_WOOL", "WHITE_CONCRETE"). This method checks if the material name ends with one of the known dyeable base material suffixes.- Parameters:
material- the Material to check for colorability- Returns:
- true if the material is colorable (wool, carpet, concrete, glass, bed, candle, banner, shulker box), false otherwise
-
changeColor
public static org.bukkit.Material changeColor(@NotNull @NotNull org.bukkit.Material material, @NotNull @NotNull O2Color color) Change a colorable material to a new color.Converts the material to its color variant using the provided O2Color. For example, converting WOOL with color RED produces RED_WOOL. The material name pattern is
COLOR_BASE.- Parameters:
material- the colorable Material to change the color of (e.g., WHITE_WOOL, BLUE_CONCRETE)color- the O2Color to change the material to- Returns:
- the new colored Material (e.g., RED_WOOL), or the original material if: - the material is not colorable, or - the colored variant does not exist in Minecraft
-