Skip to main content

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:

TypeDescription
GroupServiceMain API interface — all queries and operations
GroupManagerProviderStatic provider to obtain the API instance
GroupEventListenerEvent callback interface for group lifecycle events
GroupTypeEnum 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?

FeatureMethods
Query groupsgetPlayerGroup, getGroup, getAllGroups, isPlayerOnline
Check relationshipsareInSameGroup, isGroupLeader, canPlayerJoinExternalActivity
Manage groupscreateGroup, dissolveGroup, invitePlayer, kickMember, leaveGroup, transferLeadership
Temporary teamscreateTemporaryGroup, dissolveTemporaryGroup, rejoinCoalitionGroup
CommunicationbroadcastToGroup, broadcastToGroupExcept
HUD controlpauseHud, resumeHud, isAutoMultiHudPresent
HUD customizationsetHudPrefix, setHudSuffix, getHudPrefix, getHudSuffix, clearHudPrefixSuffix
EventsregisterEventListener, unregisterEventListener