Class RGBColorWrapper

java.lang.Object
de.eldoria.jacksonbukkit.entities.RGBColorWrapper
Direct Known Subclasses:
RGBAColorWrapper

public class RGBColorWrapper extends Object
Class for wrapping a Color.

It also allows transformation to hex code and parsing of hex code.

  • Constructor Details

    • RGBColorWrapper

      public RGBColorWrapper(int red, int green, int blue)
      Create a new color wrapper for RGB colors
      Parameters:
      red - red value
      green - green value
      blue - blue value
  • Method Details

    • of

      public static RGBColorWrapper of(Color color)
      Create a new RGBColorWrapper based on a Color.
      Parameters:
      color - color instance
      Returns:
      new RGBColorWrapper instance
    • of

      public static RGBColorWrapper of(String hex)
      Create a new RGBColorWrapper based on a hex string with RGBA or RGB.
      Parameters:
      hex - color as hex string
      Returns:
      new RGBColorWrapper instance
    • asHex

      public String asHex()
      Get the string as hex string with RGBA.
      Returns:
      hex color as RGBA
    • toBukkitColor

      public Color toBukkitColor()
      Constructs a new color instance based on wrapper values.
      Returns:
      new color instance
    • red

      public int red()
      Value of color red
      Returns:
      red
    • green

      public int green()
      Value of color green
      Returns:
      green
    • blue

      public int blue()
      Value of color blue
      Returns:
      blue
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object