Class ColorRGB

java.lang.Object
ch.njol.skript.util.ColorRGB
All Implemented Interfaces:
Color, YggdrasilSerializable, YggdrasilSerializable.YggdrasilExtendedSerializable

public class ColorRGB extends Object implements Color
  • Constructor Details

    • ColorRGB

      @Deprecated @Internal public ColorRGB(int red, int green, int blue)
      Deprecated.
      Subject to being private in the future. Use fromRGB(int, int, int) This is to keep inline with other color classes.
    • ColorRGB

      @Deprecated @Internal public ColorRGB(org.bukkit.Color bukkit)
      Deprecated.
      Subject to being private in the future. Use fromBukkitColor(org.bukkit.Color) This is to keep inline with other color classes.
  • Method Details

    • fromRGBA

      @Contract("_,_,_,_ -> new") @NotNull public static @NotNull ColorRGB fromRGBA(int red, int green, int blue, int alpha)
      Returns a ColorRGB object from the provided arguments. Versions lower than 1.19 will not support alpha values.
      Parameters:
      red - red value (0 to 255)
      green - green value (0 to 255)
      blue - blue value (0 to 255)
      alpha - alpha value (0 to 255)
      Returns:
      ColorRGB
    • fromRGB

      @Contract("_,_,_ -> new") @NotNull public static @NotNull ColorRGB fromRGB(int red, int green, int blue)
      Returns a ColorRGB object from the provided arguments.
      Parameters:
      red - red value (0 to 255)
      green - green value (0 to 255)
      blue - blue value (0 to 255)
      Returns:
      ColorRGB
    • fromBukkitColor

      @Contract("_ -> new") @NotNull public static @NotNull ColorRGB fromBukkitColor(org.bukkit.Color bukkit)
      Returns a ColorRGB object from a bukkit color.
      Parameters:
      bukkit - the bukkit color to replicate
      Returns:
      ColorRGB
    • getAlpha

      public int getAlpha()
      Specified by:
      getAlpha in interface Color
      Returns:
      The alpha component of this color.
    • getRed

      public int getRed()
      Specified by:
      getRed in interface Color
      Returns:
      The red component of this color.
    • getGreen

      public int getGreen()
      Specified by:
      getGreen in interface Color
      Returns:
      The green component of this color.
    • getBlue

      public int getBlue()
      Specified by:
      getBlue in interface Color
      Returns:
      The blue component of this color.
    • asBukkitColor

      public org.bukkit.Color asBukkitColor()
      Description copied from interface: Color
      Gets Bukkit color representing this color.
      Specified by:
      asBukkitColor in interface Color
      Returns:
      Bukkit color.
    • asDyeColor

      @Nullable public @Nullable org.bukkit.DyeColor asDyeColor()
      Description copied from interface: Color
      Gets Bukkit dye color representing this color, if one exists.
      Specified by:
      asDyeColor in interface Color
      Returns:
      Dye color or null.
    • getName

      public String getName()
      Specified by:
      getName in interface Color
      Returns:
      Name of the color.
    • fromString

      @Nullable public static @Nullable ColorRGB fromString(String string)
    • serialize

      public Fields serialize() throws NotSerializableException
      Description copied from interface: YggdrasilSerializable.YggdrasilExtendedSerializable
      Serialises this object. Only fields contained in the returned Fields object will be written to stream.

      You can use return new Fields(this); to emulate the default behaviour.

      Specified by:
      serialize in interface YggdrasilSerializable.YggdrasilExtendedSerializable
      Returns:
      A Fields object containing all fields that should be written to stream
      Throws:
      NotSerializableException - If this object or one of its fields is not serializable
    • deserialize

      public void deserialize(Fields fields) throws StreamCorruptedException, NotSerializableException
      Description copied from interface: YggdrasilSerializable.YggdrasilExtendedSerializable
      Deserializes this object. No fields have been set when this method is called, use fields.setFields(this, yggdrasil) to set all compatible non-transient and non-static fields (and call incompatible/missing field handlers if applicable – this implies that errors will be thrown if the fields object is invalid).

      You can use fields.setFields(this); to emulate the default behaviour.

      Specified by:
      deserialize in interface YggdrasilSerializable.YggdrasilExtendedSerializable
      Parameters:
      fields - A Fields object containing all fields read from stream
      Throws:
      StreamCorruptedException - If the Fields object is invalid, i.e. was not written by YggdrasilSerializable.YggdrasilExtendedSerializable.serialize() or Yggdrasil's default serialisation.
      NotSerializableException