# API Examples

## Step 1. Add the SimpleClans API to your plugin

There are two ways to do this: via Maven or locally. \
We strongly **recommend** doing this via Maven.

### Maven

Add the following lines to `pom.xml`:

```markup
<repositories>
    <repository>
        <id>roinujnosde-repo</id>
        <url>https://repo.roinujnosde.me/releases/</url>
    </repository>
</repositories>
```

```markup
<dependencies>
    <dependency>
        <groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
        <artifactId>SimpleClans</artifactId>
        <version>2.19.2</version> 
        <!-- You can find out the latest available version in the note below -->
        <scope>provided</scope>
    </dependency>
</dependencies>
```

{% hint style="info" %}
**Note**\
The latest version can be found here: [link](https://github.com/RoinujNosde/SimpleClans/releases)
{% endhint %}

### Locally

In this example, we will use the IntelliJ IDEA, but the following actions also work in other IDEs.

1. Open the structure of your project (`F4`)
2. Select Libraries, click on the cross, select "New Project Library -> Java" in the window that appears and add SimpleClans.

![](/files/-MdwUWt3zBLiI4pamGtX)

Return to the project structure, then go to Project Settings - > Modules, set the compilation mode to "Provided".

![](/files/-MdwUjSRzRAXP7fqoQD7)

* [x] Congratulations, you have added the SimpleClans API to your project. 😃

## Step 2. Use the SimpleClans API

#### What do you need to know?

* [**ClanPlayer**](https://ci.roinujnosde.me/job/SimpleClans/Javadoc/net/sacredlabyrinth/phaed/simpleclans/ClanPlayer.html) is a class that represents a player object. This class contains information about the player, his clan, etc.
* [**Clan**](https://ci.roinujnosde.me/job/SimpleClans/Javadoc/net/sacredlabyrinth/phaed/simpleclans/Clan.html) is a class that presents a clan object. It has methods for getting clan players, clan tag, allies, leaders, etc.
* [**ClanManager**](https://ci.roinujnosde.me/job/SimpleClans/Javadoc/net/sacredlabyrinth/phaed/simpleclans/managers/ClanManager.html) is a class that allows you to retrieve **Clan** and **ClanPlayer**.

#### Example of using SimpleClans API

You can hook into SimpleClans plugin like so:

{% tabs %}
{% tab title="MyPlugin.class" %}

```java
public class MyPlugin extends JavaPlugin {
    private static MyPlugin instance;
    private SimpleClans sc;
     
    @Override   
    public void onEnable() {
      instance = this;
      
      Plugin plug = getServer().getPluginManager().getPlugin("SimpleClans");
      if (plug != null) {
          sc = (SimpleClans) plug;
      }
    }
    
    public SimpleClans getSCPlugin() {
        return sc;
    }
    
    public static getInstance() {
        return instance;
    }
}
```

{% endtab %}

{% tab title="Example.class" %}

```java
public class Example {

    public void doClanStuff(Player player) {
        UUID playerUuid = player.getUniqueId();
        
        // Get a ClanManager object
        ClanManager cm = MyPlugin.getInstance().getSCPlugin().getClanManager();
        
        // Get a ClanPlayer object
        ClanPlayer cp = cm.getClanPlayer(playerUuid);
            
        if (cp != null) {
            Clan clan = cp.getClan();
        } else {
            // Player is not in a clan
        }
    
        // Get a clan from a clan tag
        Clan clan = cm.getClan("staff");
    
        if (clan != null) {
            // Clan exists
        }
    }
}
```

{% endtab %}
{% endtabs %}

If you don't want to specify a check for the presence of SimpleClans, you can always specify a dependency in `plugin.yml`:

{% tabs %}
{% tab title="plugin.yml" %}

```yaml
depend:
    - SimpleClans
```

{% endtab %}
{% endtabs %}

## Step 3. Continue your learning

Don't stop in your beginnings, feel free to learn our API: [javadocs](https://ci.roinujnosde.me/job/SimpleClans/Javadoc/).


---

# 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://wiki.roinujnosde.me/simpleclans/other/simpleclans-api.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.
