Class ColorUtil

java.lang.Object
com.ranull.graves.util.ColorUtil

public final class ColorUtil extends Object
Utility class for handling color operations, including particle dust colors.
  • Constructor Details

    • ColorUtil

      private ColorUtil()
  • Method Details

    • getColor

      public static org.bukkit.Color getColor(String colorName)
      Gets the Color corresponding to the given color name.
      Parameters:
      colorName - The name of the color as a string.
      Returns:
      The Color corresponding to the given name, or null if no match is found.
    • getColorFromHex

      public static org.bukkit.Color getColorFromHex(String hex)
      Parses a hex color code to a Color for use with particle dust options.

      Minecraft 1.16+ supports hex color codes for particle dust. This method parses a hex color code in the format #RRGGBB and returns the corresponding Color.

      Parameters:
      hex - The hex color code as a string (e.g., "#FF5733").
      Returns:
      The Color corresponding to the hex color code, or null if the code is invalid.
    • createDustOptionsFromHex

      public static org.bukkit.Particle.DustOptions createDustOptionsFromHex(String hexColor, float size)
      Creates a Particle.DustOptions object using a hex color code.
      Parameters:
      hexColor - The hex color code as a string (e.g., "#FF5733").
      size - The size of the dust particle.
      Returns:
      A Particle.DustOptions object with the specified color and size, or null if the color code is invalid.