Member and Claim Operations
Docs/dominion-api/Member and Claim Operations

Member and Claim Operations

Run controlled data operations through providers and continue the business flow after asynchronous completion.

Add a member automatically

public void addPlayerToDominion(
        CommandSender operator,
        DominionDTO dominion,
        UUID targetUuid
) {
    PlayerDTO target = api.getPlayer(targetUuid);
    if (target == null) {
        operator.sendMessage("Dominion has no data for this player.");
        return;
    }

    api.getMemberProvider()
            .addMember(operator, dominion, target)
            .thenAccept(member -> {
                if (member == null) {
                    operator.sendMessage("Failed to add the member.");
                    return;
                }
                operator.sendMessage("Member added.");
            });
}

Passing operator makes Dominion check management permissions for that identity. An automated backend task may pass the console, but this should be explicitly authorized in configuration instead of elevating every player operation to the console.

Set an individual member permission

MemberDTO member = api.getMember(dominion, targetUuid);
if (member == null) return;

api.getMemberProvider()
        .setMemberFlag(operator, dominion, member, Flags.CONTAINER, true)
        .thenAccept(updated -> {
            if (updated == null) {
                getLogger().warning("Could not grant container access.");
            }
        });

If a permission represents a role, create a group and configure it with GroupProvider.setGroupFlag, then add the member to the group. This is easier to maintain than copying the same group permissions to every member.

Create a top-level claim

CuboidDTO area = new CuboidDTO(
        minX, minY, minZ,
        maxX, maxY, maxZ
);

api.getDominionProvider()
        .createDominion(
                Bukkit.getConsoleSender(),
                "auto-claim",
                ownerUuid,
                world,
                area,
                null,
                false
        )
        .thenAccept(created -> {
            if (created == null) {
                getLogger().warning("The claim was rejected by Dominion.");
                return;
            }
            getLogger().info("Created " + created.getName());
        });

Do not treat creation success as equivalent to a successful database insert. The provider also checks the name, player limits, size, overlap, parent-child boundaries, and economy rules.