API - File14/ProCosmetics GitHub Wiki

The ProCosmetics API

Adding ProCosmetics to your project

To import ProCosmetics, you must add it as a local JAR dependency. You can do this with Maven as such:

<!-- ProCosmetics -->
<dependency>
    <groupId>se.file14.procosmetics</groupId>
    <artifactId>procosmetics</artifactId>
    <version>LATEST</version>
    <systemPath>path/of/ProCosmetics.jar</systemPath>
    <scope>system</scope>
</dependency>

Gradle:

dependencies {
     compileOnly files('path/of/ProCosmetics.jar')
}

Gradle (Kotlin):

dependencies {
    compileOnly(files("path/of/ProCosmetics.jar"))
}

Obtaining an instance of the API

The root API interface is ProCosmetics. You need to obtain an instance of this interface to do anything. It can be contained by static access. When the plugin is enabled, an instance of ProCosmetics can be obtained statically from the ProCosmeticsPovider class. Note: This method will throw an IllegalStateException if the API is not loaded.

ProCosmetics api = ProCosmeticsProvider.get();

Registering custom economy hook

Please read this


Creating a Cosmetic

When creating a cosmetic, you need to create two classes. One that contains the data of the cosmetic and one that is instanced for each player who equips it. In the following example, we will create a particle effect.

The class that is instanced for every equipment of the cosmetic:

public class Enchanted extends AbstractParticleEffect {

    public Enchanted(ProCosmetics plugin, User user, ParticleEffectType particleEffectType) {
        super(plugin, user, particleEffectType);
    }

    @Override
    public void onUpdate() {
        if (user.isMoving()) {
            location.getWorld().spawnParticle(Particle.ENCHANTMENT_TABLE, location.add(0.0d, 0.8d, 0.0d), 5, 0, 0, 0, 0.2d);
        } else {
            location.getWorld().spawnParticle(Particle.ENCHANTMENT_TABLE, location.add(0.0d, 1.5d, 0.0d), 5, 0, 0, 0, 1.0d);
        }
    }
}
}

The data holder of the cosmetic:

new ParticleEffectType("Enchanted", Enchanted::new);

Note: This instance is stored internally by the plugin, so you only need to instance it ONCE. Please make sure to enter the data of the custom cosmetic in the proper config type based on the type. Example here.


Events

CosmeticEntitySpawnEvent

Called when a ProCosmetics entity is spawned (Mounts and Pets only).

PlayerEquipComseticEvent

Called when a player equips a cosmetic.

PlayerOpenTreasureEvent

Called when a player opens a treasure.

PlayerPreEquipCosmeticEvent

Called when a player tries to equip a cosmetic (cancelable).

PlayerPurchaseCosmeticEvent

Called when a player buys a cosmetic.

PlayerPurchaseTreasureEvent

Called when a player buys a treasure.

PlayerUnequipCosmeticEvent

Called when a player unequips a cosmetic.

PlayerUseGadgetEvent

Called when a player tries to use a gadget (cancelable).


Metadata Identifiers

Entity

All non-client-sided entities such as pets & mounts have the PROCOSMETICS_ENTITY metadata.

Block

All non-client-sided blocks have the PROCOSMETICS_BLOCK metadata.

Items

All non-client-sided items have the PROCOSMETICS_ITEM metadata.

⚠️ **GitHub.com Fallback** ⚠️