SyncAPI
com.astralrealms.sync.SyncAPI
The primary entry point for interacting with AstralSync from other plugins. All methods are static.
Methods
findHolderById
Returns the DataHolder for a currently online player. Returns an empty Optional if the player is not online or their data has not finished loading yet.
Parameters:
Name | Type | Description |
|---|---|---|
|
| The player's unique ID |
Returns: Optional<DataHolder> — empty if not found
Example:
findData(UUID, Class<T>)
Retrieves a specific data object from a player's holder, matched by class type. Equivalent to calling holder.findByClass(dataClass).
Parameters:
Name | Type | Description |
|---|---|---|
|
| The player's unique ID |
|
| The class of the data to retrieve |
Returns: Optional<T> — empty if the player is not loaded or the data type is not stored
Example:
findData(UUID, Key)
Retrieves a specific data object from a player's holder by adapter key. Equivalent to calling holder.findByKey(key).
Parameters:
Name | Type | Description |
|---|---|---|
|
| The player's unique ID |
|
| The adapter's key |
Returns: Optional<T> — empty if the player is not loaded or the key is not stored
Example:
registerAdapter
Registers a SnapshotAdapter so that its data is included in all future snapshot save and load operations. Call this in your plugin's onEnable() method.
AstralSync detects whether the adapter implements VersionedSnapshotAdapter and stores it under the appropriate version slot automatically.
Parameters:
Name | Type | Description |
|---|---|---|
|
| The adapter to register |
Example:
holders
Returns an unmodifiable view of all currently loaded data holders, keyed by player UUID. Only includes players who are currently online (or whose data is still in memory during a save operation).
Returns: Map<UUID, DataHolder> — unmodifiable, never null
Example: