diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/HMCCosmeticsPlugin.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/HMCCosmeticsPlugin.java index c5a5f0fd..d0a26de3 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/HMCCosmeticsPlugin.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/HMCCosmeticsPlugin.java @@ -116,7 +116,11 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin { // HMCColor if (Hooks.isActiveHook("HMCColor")) { - DyeMenuProvider.setDyeMenuProvider(new HMCColorDyeMenu()); + try { + DyeMenuProvider.setDyeMenuProvider(new HMCColorDyeMenu()); + } catch (IllegalStateException e) { + getLogger().warning("Unable to set HMCColor as the dye menu. There is likely another plugin registering another dye menu."); + } } } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/special/DyeMenuProvider.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/special/DyeMenuProvider.java index b24e692b..67095e75 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/special/DyeMenuProvider.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/gui/special/DyeMenuProvider.java @@ -27,8 +27,12 @@ public class DyeMenuProvider { * @param viewer The viewer of the menu * @param cosmeticHolder The cosmetic holder that the player viewer wishing to modify (could be themselves or another CosmeticHolder) * @param cosmetic The cosmetic the user wishes to dye + * @throws IllegalStateException IllegalStateException will be thrown if the dye menu instance is null (Check {@link DyeMenuProvider#hasMenuProvider()} before calling) */ - public static void openMenu(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, @NotNull Cosmetic cosmetic) { + public static void openMenu(@NotNull Player viewer, @NotNull CosmeticHolder cosmeticHolder, @NotNull Cosmetic cosmetic) throws IllegalStateException { + if (instance == null) { + throw new IllegalStateException("Unable to open a dye menu without instance of it."); + } instance.openMenu(viewer, cosmeticHolder, cosmetic); }