Developer API
Add mcCosmetics as a provided dependency and softdepend: [mcCosmetics] in your plugin.yml. Call the API from the main thread.
McCosmeticsAPI api = McCosmeticsAPI.get(); // null if mcCosmetics is not enabled
Cosmetic crown = api.getCosmetic("beacon_crown").orElseThrow();
api.unlock(player.getUniqueId(), crown); // permanent, works offline
api.unlock(player.getUniqueId(), crown, Duration.ofDays(7)); // rental
api.lock(player.getUniqueId(), crown); // take the stored unlock away
api.owns(player, crown); api.isEquipped(player, crown); api.getEquipped(player);
api.equip(player, crown); api.unequip(player, crown); api.preview(player, crown);
api.getCosmetics(); api.getCosmetics(CosmeticType.PET);
Events#
| Event | When |
|---|---|
CosmeticEquipEvent | Before a cosmetic is equipped or taken off. Cancellable. isEquipping() tells which. |
CosmeticUnlockEvent | Before a cosmetic is added to a player. Cancellable. getSource() is PURCHASE, RENTAL, COMMAND or API; getExpiresAt() is 0 for a permanent unlock. |
Both are in dev.technotypist.mccosmetics.api and fire on the main thread.