Package ch.njol.skript.util
Class ColorRGB
java.lang.Object
ch.njol.skript.util.ColorRGB
- All Implemented Interfaces:
Color
,YggdrasilSerializable
,YggdrasilSerializable.YggdrasilExtendedSerializable
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.njol.yggdrasil.YggdrasilSerializable
YggdrasilSerializable.YggdrasilExtendedSerializable, YggdrasilSerializable.YggdrasilRobustEnum, YggdrasilSerializable.YggdrasilRobustSerializable
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.Color
Gets Bukkit color representing this color.@Nullable org.bukkit.DyeColor
Gets Bukkit dye color representing this color, if one exists.void
deserialize
(Fields fields) Deserializes this object.static @NotNull ColorRGB
fromBukkitColor
(org.bukkit.Color bukkit) Returns a ColorRGB object from a bukkit color.static @NotNull ColorRGB
fromRGB
(int red, int green, int blue) Returns a ColorRGB object from the provided arguments.static @NotNull ColorRGB
fromRGBA
(int red, int green, int blue, int alpha) Returns a ColorRGB object from the provided arguments.static @Nullable ColorRGB
fromString
(String string) int
getAlpha()
int
getBlue()
int
getGreen()
getName()
int
getRed()
Serialises this object.
-
Constructor Details
-
ColorRGB
Deprecated.Subject to being private in the future. UsefromRGB(int, int, int)
This is to keep inline with other color classes. -
ColorRGB
Deprecated.Subject to being private in the future. UsefromBukkitColor(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() -
getRed
public int getRed() -
getGreen
public int getGreen() -
getBlue
public int getBlue() -
asBukkitColor
public org.bukkit.Color asBukkitColor()Description copied from interface:Color
Gets Bukkit color representing this color.- Specified by:
asBukkitColor
in interfaceColor
- 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 interfaceColor
- Returns:
- Dye color or null.
-
getName
-
fromString
-
serialize
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 interfaceYggdrasilSerializable.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
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 interfaceYggdrasilSerializable.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 byYggdrasilSerializable.YggdrasilExtendedSerializable.serialize()
or Yggdrasil's default serialisation.NotSerializableException
-