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:
@@ -116,7 +116,11 @@ public final class HMCCosmeticsPlugin extends HibiscusPlugin {
|
|||||||
|
|
||||||
// HMCColor
|
// HMCColor
|
||||||
if (Hooks.isActiveHook("HMCColor")) {
|
if (Hooks.isActiveHook("HMCColor")) {
|
||||||
|
try {
|
||||||
DyeMenuProvider.setDyeMenuProvider(new HMCColorDyeMenu());
|
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.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,12 @@ public class DyeMenuProvider {
|
|||||||
* @param viewer The viewer of the menu
|
* @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 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
|
* @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);
|
instance.openMenu(viewer, cosmeticHolder, cosmetic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user