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 |
GroupType | Enum with TEMPORARY and PERMANENT values |
Obtaining the API
import com.groupmanager.api.GroupManagerProvider;
import com.groupmanager.api.GroupService;
import com.groupmanager.api.GroupType;
// 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);
}
});
Customize player names in the HUD
// Show level and class next to player names in the group HUD
api.setHudPrefix(playerUuid, "[Lv." + level + "] ");
api.setHudSuffix(playerUuid, " | " + className);
// HUD shows: "[Lv.12] Steve | Warrior"
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
What Can You Do?
| Feature | Methods |
|---|---|
| Query groups | getPlayerGroup, getGroup, getAllGroups, isPlayerOnline |
| Check relationships | areInSameGroup, isGroupLeader, canPlayerJoinExternalActivity |
| Manage groups | createGroup, dissolveGroup, invitePlayer, kickMember, leaveGroup, transferLeadership |
| Temporary teams | createTemporaryGroup, dissolveTemporaryGroup, rejoinCoalitionGroup |
| Communication | broadcastToGroup, broadcastToGroupExcept |
| HUD control | pauseHud, resumeHud, isAutoMultiHudPresent |
| HUD customization | setHudPrefix, setHudSuffix, getHudPrefix, getHudSuffix, clearHudPrefixSuffix |
| Events | registerEventListener, unregisterEventListener |