API Getting Started

Introduction

TheItemSkin contains an API to get the skins and events when equipping, removing and returning skins.

Maven

Replace VERSION with the plugin version

<dependencies>
        <dependency>
            <groupId>xshyo.com</groupId>
            <artifactId>TheItemSkin</artifactId>
            <version>1.0.8-STABLE</version>
            <scope>provided</scope>
        </dependency>
</dependencies>

In your plugin.yml file you must add as a dependency

depend: [TheItemSkin]

Getting an API instance

import xshyo.com.theitemskin.TheItemSkinAPI;
import xshyo.com.theitemskin.TheItemSkin;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public class Example extends JavaPlugin {

    private TheItemSkinAPI api;    
        
    @Override
    public void onEnable() {
        if (Bukkit.getPluginManager().isPluginEnabled("TheItemSkin")) {
            this.api = TheItemSkin.getInstance().getApi();
        }

        if (this.api != null) {
    
        }
        
    }
}

API

/**
 * Retrieves a skin by name.
 *
 * @param name Name of the Skin to be searched.
 * @return The ItemSkin corresponding to the name provided, or null if not found.
 */
public ItemSkin getItemSkinByName(String name) {
    if (name == null || name.isEmpty()) return null;
    if (theItemSkin.getItemSkinManager().getItemSkinHashMap().containsKey(name)) {
        return theItemSkin.getItemSkinManager().getItemSkinHashMap().get(name);
    }
    return null;
}

/**
 * Check if a skin exists by name.
 *
 * @param name Name of the Skin you want to check.
 * @return true if the skin exists, false otherwise.
 */
public boolean isItemSkin(String name) {
    if (name == null || name.isEmpty()) return false;
    return !theItemSkin.getItemSkinManager().getItemSkinHashMap().containsKey(name);
}

/**
 * Check whether the player is in a preview
 *
 * @param player Instance of the player to be checked
 * @return true if the player is in preview, false otherwise.
 */
public boolean inPreview(Player player) {
    if (player == null) return false;
    if(!player.isOnline()) return false;
    return !theItemSkin.getArmorStandManager().getPlayerArmorStands().containsKey(player.getUniqueId());
}

Last updated