# Developer API

## Gucci Developer API's

Please also see [Developer API](/important-information/developer-api.md) for more information about how Gucci provides developer API's and how to better support your team. **Please do not share or use product jars for development.**&#x20;

## Adding Guilds as a dependency

{% hint style="info" %}
Please note the versions on this page may not be the most up-to-date! Please check our [Nexus server](https://nexus.supremeventures.ca/#browse/browse:maven-releases:me%2Fsavag3%2FGucciCommons) for the latest build versions.&#x20;
{% endhint %}

{% tabs %}
{% tab title="Maven" %}

```xml
<repositories>
    <repository> <!-- Supreme Ventures Nexus -->
        <id>supreme-ventures-nexus</id>
        <url>https://nexus.supremeventures.ca/repository/maven-releases/</url>
    </repository>
</repositories>

<dependencies>
    <dependency> <!-- SVLib -->
        <groupId>not.savage</groupId>
        <artifactId>SVCommonLib</artifactId>
        <version>1.0.8</version>
        <scope>provided</scope>
    </dependency>
    <dependency> <!-- SMP Guilds -->
        <groupId>not.savage</groupId>
        <artifactId>ShockGuilds</artifactId>
        <version>1.0.3</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
```

{% endtab %}

{% tab title="Gradle" %}

```gradle
repositories {
    maven {
        url "https://nexus.supremeventures.ca/repository/maven-releases/"
    }
}

dependencies {
    // Gucci Commons
    compileOnly group: 'not.savage', name: 'SVCommonLib', version: '1.0.8'
    
    // Gucci Guilds
    compileOnly group: 'not.savage', name: 'ShockGuilds', version: '1.0.3'
}
```

{% endtab %}
{% endtabs %}

## Guilds API

Interacting with `Guild` object - Stores info about a given guild. Members, Roles, Leader and more.

```java
// Getting a Guild from the database (cached)
Guild guild = Guilds.getInstance()
                    .get("guild-id")
                    .orElse(Guilds.getInstance().getWilderness());

if (guildOne.isWilderness()) { 
    // No Guild Check
}

// Create a new guild
Guild guildTwo = Guilds.getInstance().createNewPlayerGuild(String tag, UUID creator);

// Creating a System Guild:
guildTwo.setLeaderName("System"); // optional
guildTwo.setSystemGuild(true);

// Comparing Guilds
if (guildTwo.getIdentifier().equals(guildOne.get().getIdentifier())) {} // Tags change

// Checking Permissions
boolean hasAccessToAction = guildTwo.hasPermission(GuildPlayer, PermissibleAction);

// Checking Relations
Relation relation = guildOne.getRelationTo(guildTwo); // Relation or Peaceful
```

Interacting with `GuildPlayer` - Stores guild data about a given player.

```java
// Getting a GuildPlayer from the database (cached)
Optional<GuildPlayer> guildPlayerOne = GuildPlayers.getInstance().get(UUID uuid);

// Async API
GuildPlayers.getInstance().getByFieldAsync("username", context.getArgument(0).parse(String.class).get())
        .thenAcceptSync(playerQuery -> {
            if (playerQuery.isEmpty()) {
                Language.sendMessage(context.getPlayer(), Core.getInstance().getLang().getGeneric().getGenericMemberNotInGuild());
                return;
            }
            
            GuildPlayer gp = playerQuery.get();
            // Do something - This method is executed "sync" once complete.
        });

// GuildPlayer should never return empty optionals as the player is created when joining
// Still safe to check if the optional is present as errors or poor execution could
// result in a empty optional for a player.

if (guildPlayerOne.isEmpty()) {
    // Error/Bug - Should report to us if this happens
}

GuildPlayer gp = guildPlayerOne.get();
Guild guild = gp.getGuild(); // Guild or wilderness
boolean isAdminBypassing = gp.isAdminBypassing();
boolean isGuildChatting = gp.isGuildChatting();
```

Interacting with the claim board `Board` - Stores info about claims and the map.

```java
// Getting the guild that claims a specific chunk 
Guild guildAt = Board.getInstance().getGuildAt(e.getBlock().getLocation());

// Side Note, ChunkCoords How-To
new ChunkCoords(Block)
new ChunkCoords(Location)
new ChunkCoords(Player)
new ChunkCoords(String worldName, int x, int z)

// Getting all the claims of a given Guild
Set<ChunkCoords> allClaims = Board.getInstance().getAllClaims(String guildId);

// Claiming a chunk for a Guild
Board.getInstance().claim(String guildId, ChunkCoords chunk);

// Unclaiming a chunk for a Guild - No guild needed as it goes back to wilderness.
Board.getInstance().unclaim(ChunkCoords chunk);
Board.getInstance().unclaimAll(String guildId);
```


---

# 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.supremeventures.ca/premium-plugins/smp-guilds-20.00/developer-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.
