# API Getting Started

### Introduction

NameGradient contains an API&#x20;

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

Replace **VERSION** with the plugin version

```xml
<dependencies>
        <dependency>
            <groupId>xshyo.us</groupId>
            <artifactId>NameGradient</artifactId>
            <version>1.4.3-STABLE</version>
            <scope>provided</scope>
        </dependency>
</dependencies>
```

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

```yaml
depend: [NameGradient]
```

### Getting an API instance

```java
import xshyo.us.thegradient.NameGradientAPI;
import xshyo.us.therewards.NameGradient;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public class Example extends JavaPlugin {

    private NameGradientAPI api;    
        
    @Override
    public void onEnable() {
        if (Bukkit.getPluginManager().isPluginEnabled("NameGradient")) {
            this.api = NameGradient.getInstance().getAPI();
        }

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

## API

<pre class="language-java"><code class="lang-java">
/**
 * Checks if the player is in a preview
 *
 * @param Player The Player instance of the player 
 * @return true If the player is in a preview or false if it is not
 */
 public boolean isInPreview(Player player)
 
<strong>/**
</strong> * Checks if a player has a gradient applied in the specified type.
 *
 * @param uuid The unique ID of the player.
 * @param gradientType The type of gradient to check (CHAT or NAME).
 * @return true if the player has a gradient applied in the specified type, false otherwise.
 */
public boolean hasGradientApplied(UUID uuid, GradientType gradientType)

/**
 * Checks if a gradient with the given ID exists for the specified type.
 *
 * @param gradientType The type of gradient (CHAT or NAME) to search in.
 * @param id The ID of the gradient to check.
 * @return true if a gradient with the specified ID exists, false otherwise.
 */
public boolean existsId(GradientType gradientType, String id) 

 /**
  * Retrieves the data of a gradient by its type and ID.
  *
  * @param gradientType The type of gradient (CHAT or NAME) to retrieve data from.
  * @param id The ID of the gradient to get data for.
  * @return A map containing the gradient data, or an empty map if the gradient type is invalid.
  */

public GradientCacheData getGradientData(GradientType gradientType, String id) 


</code></pre>


---

# 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/namegradient/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.
