Skip to content

Commit

Permalink
Bukkit color conversion: support alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
tal5 committed May 12, 2023
1 parent 21975ee commit e6d7c76
Showing 1 changed file with 7 additions and 2 deletions.
@@ -1,5 +1,7 @@
package com.denizenscript.denizen.objects.properties.bukkit;

import com.denizenscript.denizen.nms.NMSHandler;
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.objects.LocationTag;
import com.denizenscript.denizencore.objects.core.ColorTag;
import org.bukkit.Color;
Expand All @@ -8,15 +10,18 @@
public class BukkitColorExtensions {

public static ColorTag fromColor(Color color) {
return new ColorTag(color.getRed(), color.getGreen(), color.getBlue(), 255);
return new ColorTag(color.getRed(), color.getGreen(), color.getBlue(), NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19) ? color.getAlpha() : 255);
}

public ColorTag fromDyeColor(DyeColor dyeColor) {
return fromColor(dyeColor.getColor());
}

public static Color getColor(ColorTag tag) {
return Color.fromRGB(tag.red, tag.green, tag.blue);
if (!NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) {
return Color.fromRGB(tag.red, tag.green, tag.blue);
}
return Color.fromARGB(tag.alpha, tag.red, tag.green, tag.blue);
}

public static void register() {
Expand Down

0 comments on commit e6d7c76

Please sign in to comment.