Skip to content

Commit 65dafe5

Browse files
Accept both java.awt.Color and org.bukkit.Color in ItemBuilder
1 parent 0350b07 commit 65dafe5

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

invui/src/main/java/xyz/xenondevs/invui/item/ItemBuilder.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
import net.kyori.adventure.text.Component;
1212
import net.kyori.adventure.text.minimessage.MiniMessage;
1313
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
14+
import org.bukkit.Color;
1415
import org.bukkit.Material;
1516
import org.bukkit.inventory.ItemStack;
1617
import org.jspecify.annotations.Nullable;
1718
import xyz.xenondevs.invui.i18n.Languages;
1819
import xyz.xenondevs.invui.internal.util.ComponentUtils;
1920

20-
import java.awt.*;
21-
import java.util.List;
2221
import java.util.*;
2322
import java.util.function.Function;
2423
import java.util.stream.Collectors;
@@ -430,6 +429,16 @@ public ItemBuilder addCustomModelData(Color value) {
430429
return this;
431430
}
432431

432+
/**
433+
* Adds the given custom model data entry to the `colors` section.
434+
*
435+
* @param value The value to add
436+
* @return The builder instance
437+
*/
438+
public ItemBuilder addCustomModelData(java.awt.Color value) {
439+
return addCustomModelData(Color.fromARGB(value.getRGB()));
440+
}
441+
433442
/**
434443
* Sets the custom model data entry in `floats` at the given index to the given value,
435444
* filling smaller indices with zeros if necessary.
@@ -546,6 +555,18 @@ public ItemBuilder setCustomModelData(int index, Color value) {
546555
return this;
547556
}
548557

558+
/**
559+
* Sets the custom model data entry in `colors` at the given index to the given value,
560+
* filling smaller indices with white if necessary.
561+
*
562+
* @param index The index
563+
* @param value The value
564+
* @return The builder instance
565+
*/
566+
public ItemBuilder setCustomModelData(int index, java.awt.Color value) {
567+
return setCustomModelData(index, Color.fromARGB(value.getRGB()));
568+
}
569+
549570
/**
550571
* Sets all custom model data entries.
551572
*

0 commit comments

Comments
 (0)