9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-19 15:09:19 +00:00

feat: better handling of custom dye implementations with HMCColor

This commit is contained in:
Logan
2025-08-18 20:41:26 -05:00
parent 3907bc5839
commit bb08fb108c
2 changed files with 10 additions and 2 deletions

View File

@@ -116,7 +116,11 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
// HMCColor
if (Hooks.isActiveHook("HMCColor")) {
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.");
}
}
}

View File

@@ -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);
}