Main API

Main API

The DominionAPI singleton's query, permission-check, cache, and provider entry points.

Get the singleton

DominionAPI api = DominionAPI.getInstance();

The singleton may be null before Dominion is enabled and initialized. With a hard dependency, get it in onEnable(); with a soft dependency, check the plugin state first. Do not use it during onLoad().

Query players

MethodReturn valueDescription
getPlayer(String name)PlayerDTO or nullQuery a known player by name
getPlayer(UUID uuid)PlayerDTO or nullQuery a known player by UUID
getPlayerName(UUID uuid)StringGet a name from a UUID

PlayerDTO contains player data known to Dominion; it is not the same as an online Bukkit Player. When you need to operate in the game world, still obtain the online player object through the Bukkit/Paper/Folia API.

Query claims

MethodReturn valueDescription
getDominion(Integer id)DominionDTO or nullQuery by ID; with multi-server support, the result may be a claim cached from another server
getDominion(String name)DominionDTO or nullQuery by name
getDominion(Location location)DominionDTO or nullQuery the claim containing a location; the location must have a world
getAllDominions()List<DominionDTO>Get all claims
getAllDominionsOfPlayer(UUID uuid)List<DominionDTO>Get claims owned by a player
getPlayerOwnDominionDTOs(UUID uuid)List<DominionDTO>Get claims where a player is the owner
getPlayerAdminDominionDTOs(UUID uuid)List<DominionDTO>Get claims where a player has admin permissions
getChildrenDominionOf(DominionDTO parent)List<DominionDTO>Get the direct child claims of a parent

getDominion(Location) is the most common spatial query. If you only need to query, do not call getPlayerCurrentDominion(Player) just to read the claim at a location.

A player’s current claim

DominionDTO current = api.getPlayerCurrentDominion(player);

This method maintains current-claim state based on the player’s position. When the player moves from one claim to another, Dominion fires the corresponding movement events. It returns null when there is no claim.

If the addon maintains its own player-position state, it can call this when a player leaves the server, teleports, or its data becomes invalid:

api.resetPlayerCurrentDominionId(player);

Query members and groups

MemberDTO member = api.getMember(dominion, player.getUniqueId());
GroupDTO group = member == null ? null : api.getGroup(member);

You can also pass an online player directly with getMember(DominionDTO, Player), or query by group ID with getGroup(Integer id). The claim parameter of getMember may be null, but addons should confirm that the target claim exists whenever possible so that “no claim” and “not a member” are not conflated.

Permission and environment checks

boolean canOpen = api.checkPrivilegeFlagSilence(
        block.getLocation(),
        Flags.CONTAINER,
        player
);

boolean creeperCanExplode = api.checkEnvironmentFlag(
        block.getLocation(),
        Flags.CREEPER_EXPLODE
);

PriFlag represents player permissions such as PLACE, BREAK_BLOCK, CONTAINER, and TELEPORT. EnvFlag represents claim environment rules such as CREEPER_EXPLODE, FIRE_SPREAD, and MONSTER_SPAWN.

MethodCan notify the player or trigger feedback?Use case
checkPrivilegeFlag(Location, PriFlag, Player)PossiblyPermission check for a direct player action
checkPrivilegeFlagSilence(Location, PriFlag, Player)NoInternal logic, menu pre-checks, and background tasks
checkEnvironmentFlag(Location, EnvFlag)No player feedback involvedCheck an environment rule at a location

The main API also retains overloads that accept DominionDTO, but the source explicitly recommends position-based overloads from 4.5.0 onward. The claim-object overload does not check the discouraged world-wide permission rules.

Providers and maintenance entry points

DominionProvider dominionProvider = DominionAPI.getDominionProvider();
GroupProvider groupProvider = DominionAPI.getGroupProvider();
MemberProvider memberProvider = DominionAPI.getMemberProvider();

You can also get PlayerProvider, TeleportProvider, TemplateProvider, and CopyProvider through DominionAPI.getPlayerProvider(), getTeleportProvider(), getTemplateProvider(), and getCopyProvider(). See Providers for their responsibilities and asynchronous constraints.

reloadCache(), reloadConfig(), and getMcaWhiteListInitiative() are operations or advanced interfaces for server maintenance. An addon should not normally reload all of Dominion’s cache or configuration as part of its own business flow; misuse can affect other plugins and online players.

applyFlagChanges() waits for custom flags and flag groups to be applied. See Flags for details.

Statistics

MethodDescription
dominionCount()Total number of claims
groupCount()Total number of groups
memberCount()Total number of members

With multi-server support enabled, some queries and statistics combine caches from other servers. Do not interpret the result as the number of local objects in a single backend process.