Enum Class O2Color

java.lang.Object
java.lang.Enum<O2Color>
net.pottercraft.ollivanders2.common.O2Color
All Implemented Interfaces:
Serializable, Comparable<O2Color>, Constable

public enum O2Color extends Enum<O2Color>
Color representation for Ollivanders2 supporting multiple Minecraft color formats.

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 red
  • getDyeColor() - 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 Constants
    Enum Constant
    Description
    aqua - Color.AQUA, ChatColor.AQUA, "§b", DyeColor.LIGHT_BLUE
    black - Color.BLACK, ChatColor.BLACK, "§0", DyeColor.BLACK
    blue - Color.BLUE, ChatColor.BLUE, "§9", DyeColor.BLUE
    brown - Color.ORANGE, ChatColor.GOLD, "§6", DyeColor.BROWN
    cyan - Color.TEAL, ChatColor.DARK_AQUA, "§3", DyeColor.CYAN
    dark blue - Color.NAVY, ChatColor.DARK_BLUE, "§1", DyeColor.BLUE
    dark gray - Color.GRAY, ChatColor.GRAY, "§8", DyeColor.GRAY
    dark green - Color.GREEN, ChatColor.DARK_GREEN, "§2", DyeColor.GREEN
    dark red - Color.RED, ChatColor.RED, "§4", DyeColor.RED
    fuschia - Color.FUCHSIA, ChatColor.LIGHT_PURPLE, "§d", DyeColor.PINK
    gold - Color.YELLOW, ChatColor.GOLD, "§6", DyeColor.YELLOW
    gray - Color.GRAY, ChatColor.GRAY, "§7", DyeColor.LIGHT_GRAY
    green - Color.GREEN, ChatColor.GREEN, "§a", DyeColor.GREEN
    light blue - Color.TEAL, ChatColor.BLUE, "§9", DyeColor.LIGHT_BLUE
    light gray - Color.SILVER, ChatColor.GRAY, "§7", DyeColor.LIGHT_GRAY
    light purple - Color.FUCHSIA, ChatColor.LIGHT_PURPLE, "§d", DyeColor.PURPLE
    lime - Color.LIME, ChatColor.GREEN, "§a", DyeColor.LIME
    magenta - Color.PURPLE, ChatColor.DARK_PURPLE, "§5", DyeColor.MAGENTA
    maroon - Color.MAROON, ChatColor.DARK_RED, "§4", DyeColor.RED
    navy - Color.NAVY, ChatColor.DARK_BLUE, "§1", DyeColor.BLUE
    olive - Color.OLIVE, ChatColor.DARK_GREEN, "§2", DyeColor.GREEN
    orange - Color.ORANGE, ChatColor.GOLD, "§6", DyeColor.ORANGE
    pink - Color.FUCHSIA, ChatColor.LIGHT_PURPLE, "§d", DyeColor.PINK
    purple - Color.PURPLE, ChatColor.DARK_PURPLE, "§5", DyeColor.PURPLE
    red - Color.RED, ChatColor.RED, "§c", DyeColor.RED
    silver - Color.SILVER, ChatColor.GRAY, "§7", DyeColor.LIGHT_GRAY
    teal - Color.TEAL, ChatColor.DARK_AQUA, "§3", DyeColor.CYAN
    white - Color.WHITE, ChatColor.WHITE, "§f", DyeColor.WHITE
    yellow - Color.YELLOW, ChatColor.YELLOW, "§e", DyeColor.YELLOW
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.bukkit.Material
    changeColor(@NotNull org.bukkit.Material material, @NotNull O2Color color)
    Change a colorable material to a new color.
    @NotNull org.bukkit.Color
    Get the Bukkit Color object for this color.
    static @NotNull O2Color
    Get the Bukkit color associated with a numeric color code.
    @NotNull org.bukkit.ChatColor
    Get the ChatColor enum value for this color.
    @NotNull String
    Get the chat format code for this color.
    @Nullable org.bukkit.Material
    getColoredMaterial(String materialBaseName)
    Get the colored material variant for this color with the given base material name.
    @NotNull org.bukkit.DyeColor
    Get the DyeColor enum value for this color.
    static @NotNull O2Color
    Get a random dyeable color.
    static @NotNull O2Color
    Get a dyeable color based on the provided seed.
    static @NotNull O2Color
    Get a random primary dyeable color.
    static @NotNull O2Color
    Get a primary dyeable color based on the provided seed.
    static boolean
    isColorable(@NotNull org.bukkit.Material material)
    Check whether a material can be dyed to different colors.
    static O2Color
    Returns the enum constant of this class with the specified name.
    static O2Color[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • AQUA

      public static final O2Color AQUA
      aqua - Color.AQUA, ChatColor.AQUA, "§b", DyeColor.LIGHT_BLUE
    • BLACK

      public static final O2Color BLACK
      black - Color.BLACK, ChatColor.BLACK, "§0", DyeColor.BLACK
    • BLUE

      public static final O2Color BLUE
      blue - Color.BLUE, ChatColor.BLUE, "§9", DyeColor.BLUE
    • BROWN

      public static final O2Color BROWN
      brown - Color.ORANGE, ChatColor.GOLD, "§6", DyeColor.BROWN
    • CYAN

      public static final O2Color CYAN
      cyan - Color.TEAL, ChatColor.DARK_AQUA, "§3", DyeColor.CYAN
    • DARK_BLUE

      public static final O2Color DARK_BLUE
      dark blue - Color.NAVY, ChatColor.DARK_BLUE, "§1", DyeColor.BLUE
    • DARK_GRAY

      public static final O2Color DARK_GRAY
      dark gray - Color.GRAY, ChatColor.GRAY, "§8", DyeColor.GRAY
    • DARK_GREEN

      public static final O2Color DARK_GREEN
      dark green - Color.GREEN, ChatColor.DARK_GREEN, "§2", DyeColor.GREEN
    • DARK_RED

      public static final O2Color DARK_RED
      dark red - Color.RED, ChatColor.RED, "§4", DyeColor.RED
    • FUCHSIA

      public static final O2Color FUCHSIA
      fuschia - Color.FUCHSIA, ChatColor.LIGHT_PURPLE, "§d", DyeColor.PINK
    • GOLD

      public static final O2Color GOLD
      gold - Color.YELLOW, ChatColor.GOLD, "§6", DyeColor.YELLOW
    • GRAY

      public static final O2Color GRAY
      gray - Color.GRAY, ChatColor.GRAY, "§7", DyeColor.LIGHT_GRAY
    • GREEN

      public static final O2Color GREEN
      green - Color.GREEN, ChatColor.GREEN, "§a", DyeColor.GREEN
    • LIGHT_BLUE

      public static final O2Color LIGHT_BLUE
      light blue - Color.TEAL, ChatColor.BLUE, "§9", DyeColor.LIGHT_BLUE
    • LIGHT_GRAY

      public static final O2Color LIGHT_GRAY
      light gray - Color.SILVER, ChatColor.GRAY, "§7", DyeColor.LIGHT_GRAY
    • LIGHT_PURPLE

      public static final O2Color LIGHT_PURPLE
      light purple - Color.FUCHSIA, ChatColor.LIGHT_PURPLE, "§d", DyeColor.PURPLE
    • LIME

      public static final O2Color LIME
      lime - Color.LIME, ChatColor.GREEN, "§a", DyeColor.LIME
    • MAGENTA

      public static final O2Color MAGENTA
      magenta - Color.PURPLE, ChatColor.DARK_PURPLE, "§5", DyeColor.MAGENTA
    • MAROON

      public static final O2Color MAROON
      maroon - Color.MAROON, ChatColor.DARK_RED, "§4", DyeColor.RED
    • OLIVE

      public static final O2Color OLIVE
      olive - Color.OLIVE, ChatColor.DARK_GREEN, "§2", DyeColor.GREEN
    • ORANGE

      public static final O2Color ORANGE
      orange - Color.ORANGE, ChatColor.GOLD, "§6", DyeColor.ORANGE
    • PINK

      public static final O2Color PINK
      pink - Color.FUCHSIA, ChatColor.LIGHT_PURPLE, "§d", DyeColor.PINK
    • PURPLE

      public static final O2Color PURPLE
      purple - Color.PURPLE, ChatColor.DARK_PURPLE, "§5", DyeColor.PURPLE
    • RED

      public static final O2Color RED
      red - Color.RED, ChatColor.RED, "§c", DyeColor.RED
    • SILVER

      public static final O2Color SILVER
      silver - Color.SILVER, ChatColor.GRAY, "§7", DyeColor.LIGHT_GRAY
    • TEAL

      public static final O2Color TEAL
      teal - Color.TEAL, ChatColor.DARK_AQUA, "§3", DyeColor.CYAN
    • WHITE

      public static final O2Color WHITE
      white - Color.WHITE, ChatColor.WHITE, "§f", DyeColor.WHITE
    • YELLOW

      public static final O2Color YELLOW
      yellow - Color.YELLOW, ChatColor.YELLOW, "§e", DyeColor.YELLOW
  • Method Details

    • values

      public static O2Color[] 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

      public static O2Color valueOf(String name)
      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 name
      NullPointerException - 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

      @NotNull public @NotNull String 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

      @Nullable public @Nullable org.bukkit.Material getColoredMaterial(String materialBaseName)
      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

      @NotNull public static @NotNull O2Color getBukkitColorByNumber(int number)
      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

      @NotNull public static @NotNull O2Color 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

      @NotNull public static @NotNull O2Color getRandomPrimaryDyeableColor(int seed)
      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

      @NotNull public static @NotNull O2Color 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

      @NotNull public static @NotNull O2Color getRandomDyeableColor(int seed)
      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