diff --git a/build.gradle.kts b/build.gradle.kts index 46ca1710..eb00082d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -69,6 +69,8 @@ allprojects { // Hibiscus Commons maven("https://repo.hibiscusmc.com/releases") + + mavenLocal() } dependencies { @@ -86,7 +88,7 @@ allprojects { compileOnly("io.github.toxicity188:BetterCommand:1.3") //BetterCommand library //compileOnly("it.unimi.dsi:fastutil:8.5.14") compileOnly("org.projectlombok:lombok:1.18.34") - compileOnly("me.lojosho:HibiscusCommons:0.6.3-d97e5686") + compileOnly("me.lojosho:HibiscusCommons:0.6.3-7ef40c1") // Handled by Spigot Library Loader compileOnly("net.kyori:adventure-api:4.19.0") diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/special/DyeMenu.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/special/DyeMenu.java index 2813d89e..0ef75aee 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/special/DyeMenu.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/special/DyeMenu.java @@ -9,14 +9,14 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticHolder; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import me.lojosho.hibiscuscommons.hooks.Hooks; -import me.lojosho.hibiscuscommons.nms.MinecraftVersion; import me.lojosho.hibiscuscommons.nms.NMSHandlers; import me.lojosho.hibiscuscommons.util.AdventureUtils; import me.lojosho.hibiscuscommons.util.StringUtils; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -37,30 +37,7 @@ public class DyeMenu { ItemStack item = event.getInventory().getItem(Settings.getDyeMenuOutputSlot()); if (item == null) return; - Color color = null; - try { - // Uses Idofront Colorable logic as 1.21.4+ lets any item be dyed - // Requires NMS or Paper's DataComponent API - // If it fails it will fall back to getting it from ItemMeta - // with an extra fallback here in-case HMCColor is old - color = HMCColorApi.getItemColor(item); - } catch (Exception e) { - ItemMeta meta = item.getItemMeta(); - switch (meta) { - case null -> { return; } - case LeatherArmorMeta leatherMeta -> color = leatherMeta.getColor(); - case PotionMeta potionMeta -> color = potionMeta.getColor(); - case MapMeta mapMeta -> color = mapMeta.getColor(); - case FireworkEffectMeta fireworkEffectMeta -> { - FireworkEffect effect = fireworkEffectMeta.getEffect(); - if (effect != null) { - color = effect.getColors().stream().findFirst().isPresent() ? effect.getColors().stream().findFirst().get() : null; - } - } - default -> {} - } - - } + Color color = NMSHandlers.getHandler().getUtilHandler().getColor(item); if (color == null) return; addCosmetic(viewer, cosmeticHolder, cosmetic, color); diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java index d53b8631..f23dd804 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/CosmeticUser.java @@ -22,8 +22,10 @@ import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager; import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils; import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager; +import com.ticxo.modelengine.api.nms.NMSHandler; import lombok.Getter; import me.lojosho.hibiscuscommons.hooks.Hooks; +import me.lojosho.hibiscuscommons.nms.NMSHandlers; import me.lojosho.hibiscuscommons.util.InventoryUtils; import me.lojosho.hibiscuscommons.util.packets.PacketManager; import org.bukkit.Bukkit; @@ -405,29 +407,15 @@ public class CosmeticUser implements CosmeticHolder { } - if (colors.containsKey(cosmetic.getSlot())) { - Color color = colors.get(cosmetic.getSlot()); - if (itemMeta instanceof LeatherArmorMeta leatherMeta) { - leatherMeta.setColor(color); - } else if (itemMeta instanceof PotionMeta potionMeta) { - potionMeta.setColor(color); - } else if (itemMeta instanceof MapMeta mapMeta) { - mapMeta.setColor(color); - } else if (itemMeta instanceof FireworkEffectMeta fireworkMeta) { - fireworkMeta.setEffect( - FireworkEffect.builder() - .with(FireworkEffect.Type.BALL) - .withColor(color) - .trail(false) - .flicker(false) - .build() - ); - } - } itemMeta.getPersistentDataContainer().set(HMCCInventoryUtils.getCosmeticKey(), PersistentDataType.STRING, cosmetic.getId()); itemMeta.getPersistentDataContainer().set(InventoryUtils.getOwnerKey(), PersistentDataType.STRING, getEntity().getUniqueId().toString()); item.setItemMeta(itemMeta); + + if (colors.containsKey(cosmetic.getSlot())) { + Color color = colors.get(cosmetic.getSlot()); + NMSHandlers.getHandler().getUtilHandler().setColor(item, color); + } } return item; }