public interface TrackManager
Track instances.
All blocking methods return CompletableFutures, which will be
populated with the result once the data has been loaded/saved asynchronously.
Care should be taken when using such methods to ensure that the main server
thread is not blocked.
Methods such as CompletableFuture.get() and equivalent should
not be called on the main server thread. If you need to use
the result of these operations on the main server thread, register a
callback using CompletableFuture.thenAcceptAsync(Consumer, Executor).
| Modifier and Type | Method and Description |
|---|---|
@NonNull CompletableFuture<Track> |
createAndLoadTrack(@NonNull String name)
Creates a new track in the plugin's storage provider and then loads it
into memory.
|
@NonNull CompletableFuture<Void> |
deleteTrack(@NonNull Track track)
Permanently deletes a track from the plugin's storage provider.
|
@NonNull Set<Track> |
getLoadedTracks()
Gets a set of all loaded tracks.
|
@Nullable Track |
getTrack(@NonNull String name)
Gets a loaded track.
|
default @NonNull Optional<Track> |
getTrackOpt(@NonNull String name)
Gets a loaded track.
|
boolean |
isLoaded(@NonNull String name)
Check if a track is loaded in memory
|
@NonNull CompletableFuture<Void> |
loadAllTracks()
Loads all tracks into memory.
|
@NonNull CompletableFuture<Optional<Track>> |
loadTrack(@NonNull String name)
Loads a track from the plugin's storage provider into memory.
|
@NonNull CompletableFuture<Void> |
saveTrack(@NonNull Track track)
Saves a track's data back to the plugin's storage provider.
|
@NonNull CompletableFuture<Track> createAndLoadTrack(@NonNull String name)
If a track by the same name already exists, it will be loaded.
This method is effectively the same as
Storage.createAndLoadTrack(String), however, the Future returns
the resultant track instance instead of a boolean flag.
Unlike the method in Storage, when a track cannot be loaded,
the future will be completed exceptionally.
name - the name of the trackNullPointerException - if the name is null@NonNull CompletableFuture<Optional<Track>> loadTrack(@NonNull String name)
Returns an empty optional if the track does
not exist.
This method is effectively the same as
Storage.loadTrack(String), however, the Future returns
the resultant track instance instead of a boolean flag.
Unlike the method in Storage, when a track cannot be loaded,
the future will be completed exceptionally.
name - the name of the trackNullPointerException - if the name is null@NonNull CompletableFuture<Void> saveTrack(@NonNull Track track)
You should call this after you make any changes to a track.
This method is effectively the same as Storage.saveTrack(Track),
however, the Future returns void instead of a boolean flag.
Unlike the method in Storage, when a track cannot be saved,
the future will be completed exceptionally.
track - the track to saveNullPointerException - if track is nullIllegalStateException - if the track instance was not obtained from LuckPerms.@NonNull CompletableFuture<Void> deleteTrack(@NonNull Track track)
This method is effectively the same as Storage.deleteTrack(Track),
however, the Future returns void instead of a boolean flag.
Unlike the method in Storage, when a track cannot be deleted,
the future will be completed exceptionally.
track - the track to deleteNullPointerException - if track is nullIllegalStateException - if the track instance was not obtained from LuckPerms.@NonNull CompletableFuture<Void> loadAllTracks()
This method is effectively the same as Storage.loadAllTracks(),
however, the Future returns void instead of a boolean flag.
Unlike the method in Storage, when a track cannot be loaded,
the future will be completed exceptionally.
@Nullable Track getTrack(@NonNull String name)
name - the name of the track to getTrack object, if one matching the name exists, or null if notNullPointerException - if the name is nulldefault @NonNull Optional<Track> getTrackOpt(@NonNull String name)
This method does not return null, unlike getTrack(java.lang.String)
name - the name of the track to getTrack objectNullPointerException - if the name is nullboolean isLoaded(@NonNull String name)
name - the name to check forNullPointerException - if the name is null