# Developer Overview
Lead is a team management plugin for Paper servers. It lets players create, join, and manage teams with features like colored nametags, team chat, friendly fire control, collision settings, and spawn points. The Lead-API module provides a public interface that allows other plugins to interact with teams programmatically.
---
## Maven / Gradle
The Lead-API artifact is hosted on JitPack. Add it as a `compileOnly` / `provided` dependency so that Lead is not shaded into your plugin jar.
**Gradle (Kotlin DSL):**
```kotlin
repositories {
maven("https://jitpack.io")
}
dependencies {
compileOnly("com.github.Lodestones:Lead-API:1.1.11")
}
```
**Maven:**
```xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.Lodestones</groupId>
<artifactId>Lead-API</artifactId>
<version>1.1.11</version>
<scope>provided</scope>
</dependency>
</dependencies>
```
Add `Lead` as a `depend` or `softdepend` in your `plugin.yml`:
```yaml
depend:
- Lead
```
Or, if Lead is optional for your plugin:
```yaml
softdepend:
- Lead
```
---
## Accessing the API
The API is accessed through the static `LeadAPI` class. The API instance is available after Lead has been enabled.
```java
import gg.lode.leadapi.LeadAPI;
import gg.lode.leadapi.ILeadAPI;
ILeadAPI api = LeadAPI.getApi();
if (api == null) {
// Lead is not loaded
return;
}
```
---
## Common Operations
### Get a player's team
```java
import gg.lode.leadapi.api.ITeam;
ITeam team = api.getTeam(player.getUniqueId());
if (team != null) {
String teamName = team.getName();
String teamColor = team.getColor(); // hex, e.g. "#FF0000"
}
```
### Check if a player is on a team
```java
boolean onTeam = api.hasTeam(player.getUniqueId());
```
### Get a team by ID
```java
ITeam team = api.getTeam("alpha");
```
### List all teams
```java
import java.util.List;
List<ITeam> teams = api.getTeams();
for (ITeam team : teams) {
// team.getId(), team.getName(), team.getColor(), team.getMembers()
}
```
### Create a team
```java
import gg.lode.leadapi.api.exception.MaxTeamLimitException;
import gg.lode.leadapi.api.exception.TeamAlreadyExistsException;
try {
ITeam team = api.createTeamWithUniqueColor(player, "alpha", "Alpha Team");
} catch (MaxTeamLimitException e) {
// Server has reached its configured team limit
} catch (TeamAlreadyExistsException e) {
// A team with that ID already exists
}
```
### Delete a team
```java
import gg.lode.leadapi.api.exception.TeamNotFoundException;
try {
api.deleteTeam("alpha");
} catch (TeamNotFoundException e) {
// No team found with that ID
}
```
### Manage members
```java
import gg.lode.leadapi.api.ITeamMember;
// Add a player to a team
team.addMember(player);
// Remove a player from a team
team.removeMember(player.getUniqueId());
// Get a specific member
ITeamMember member = team.getMember(player.getUniqueId());
// Check if a player is on the team
boolean isMember = team.containsMember(player.getUniqueId());
```
### Team settings
```java
import org.bukkit.scoreboard.Team;
// Friendly fire
team.setFriendlyFireAllowed(false);
boolean ff = team.isFriendlyFireAllowed();
// Collision
team.setCollidable(Team.OptionStatus.NEVER);
// Nametag visibility
team.setNameTagVisibility(Team.OptionStatus.ALWAYS);
// Color
team.setColor("#00FF00");
// Spawn location
team.setSpawnLocation(player.getLocation());
```
---
## Listening to Events
Lead fires Bukkit events for team lifecycle actions. Register listeners the same way you would for any other Bukkit event.
```java
import gg.lode.leadapi.api.event.TeamJoinEvent;
import gg.lode.leadapi.api.event.TeamLeaveEvent;
import gg.lode.leadapi.api.event.TeamCreateEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class TeamListener implements Listener {
@EventHandler
public void onTeamCreate(TeamCreateEvent event) {
ITeam team = event.getTeam();
// event.getPlayer() may be null if the team was created programmatically
}
@EventHandler
public void onTeamJoin(TeamJoinEvent event) {
Player player = event.getPlayer();
ITeam team = event.getTeam();
// Cancel the join if needed
event.setCancelled(true);
}
@EventHandler
public void onTeamLeave(TeamLeaveEvent event) {
ITeam team = event.getTeam();
// event.getPlayer() returns an OfflinePlayer
}
}
```
Many team events are cancellable, including `TeamJoinEvent`, `TeamLeaveEvent`, `TeamKickEvent`, and `TeamInviteEvent`.
---
## Related Pages
- [[Lead/Developers/API Reference]] — Full API interface documentation with code examples.