Data Operations
About 192 wordsLess than 1 minute
2025-08-21
Introduction
Due to strict data consistency requirements in dominions, arbitrarily modifying certain data may cause serious issues. To ensure data consistency, modifications to DominionDTO
, GroupDTO
, and MemberDTO
objects must, in principle, be performed through the Provider methods provided by the API.
These Provider methods check for compliance before modifying data and trigger corresponding events after modification to ensure data consistency and integrity.
For example, to change the name of a dominion:
import java.util.concurrent.CompletableFuture;
class ChangeDominionNameExample {
public void changeDominionName(DominionDTO dominion, String newName) {
CompletableFuture<DominionDTO> changed = DominionProviderHandler.getInstance().renameDominion(
Bukkit.getConsoleSender(),
dominion,
newName
);
if (changed.get() == null) {
// change failed
} else {
// change success
}
}
}
Operation Identity
All methods provided by the Provider require a CommandSender
parameter, which represents the identity performing the operation.
This parameter determines the permissions and source of the operation. For example, if you want to simulate a player performing the operation, you can pass in a Player
object. If you want to bypass basic checks (such as permission checks, but basic compliance checks will still be performed), you can pass in Bukkit.getConsoleSender()
to simulate the highest privilege operation from the console.