# API Getting Started

### Introduction

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

### Maven <a href="#maven" id="maven"></a>

Replace **VERSION** with the plugin version

```xml
<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

```yaml
depend: [TheItemSkin]
```

### Getting an API instance <a href="#getting-an-api-instance" id="getting-an-api-instance"></a>

```java
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

```java
/**
 * 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());
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.xshyo.us/premium-plugins/theitemskin/development-portal/api-getting-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
