API Overview
GroupManager exposes a public Java API that other plugins can use to query groups, manage membership, and listen for group events.
Getting Started
Add GroupManager's jar as a compileOnly dependency:
build.gradle.kts
dependencies {
compileOnly(files("libs/groupmanager.jar"))
}
All public types live under com.groupmanager.api:
| Type | Description |
|---|---|
GroupService | Main API interface — all queries and operations |
GroupManagerProvider | Static provider to obtain the API instance |
GroupEventListener | Event callback interface for group lifecycle events |
Obtaining the API
import com.groupmanager.api.GroupManagerProvider;
import com.groupmanager.api.GroupService;
// Get the API instance (returns null if GroupManager is not loaded)
GroupService api = GroupManagerProvider.get();
if (api != null) {
// Use the API
}
tip
Cache the GroupService reference — the instance doesn't change during server lifetime.
Quick Examples
Check if a player is in a group
api.getPlayerGroup(playerUuid).ifPresent(group -> {
System.out.println("In group: " + group.groupId());
System.out.println("Leader: " + group.leaderUuid());
System.out.println("Members: " + group.size());
});
Check if two players are teammates
if (api.areInSameGroup(player1Uuid, player2Uuid)) {
// Don't apply PvP damage
}
Invite a player programmatically
GroupService.GroupResult result = api.invitePlayer(inviterUuid, targetUuid);
if (result.success()) {
System.out.println("Invitation sent!");
} else {
System.out.println("Failed: " + result.message());
}
Listen for group events
api.registerEventListener(new GroupEventListener() {
@Override
public void onGroupCreated(UUID groupId, UUID leaderUuid) {
System.out.println("New group created by " + leaderUuid);
}
@Override
public void onMemberJoined(UUID groupId, UUID playerUuid) {
System.out.println("Player " + playerUuid + " joined group " + groupId);
}
});
API Sections
- GroupService — Complete reference for all API methods
- Events — Event listener interface and all event types
- Integration Guide — Step-by-step guide for integrating with GroupManager