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 |
|---|---|
CompletableFuture<Track> |
createAndLoadTrack(String name)
Creates a new track in the plugin's storage provider and then loads it
into memory.
|
CompletableFuture<Void> |
deleteTrack(Track track)
Permanently deletes a track from the plugin's storage provider.
|
Set<Track> |
getLoadedTracks()
Gets a set of all loaded tracks.
|
Track |
getTrack(String name)
Gets a loaded track.
|
default Optional<Track> |
getTrackOpt(String name)
Gets a loaded track.
|
boolean |
isLoaded(String name)
Check if a track is loaded in memory
|
CompletableFuture<Void> |
loadAllTracks()
Loads all tracks into memory.
|
CompletableFuture<Optional<Track>> |
loadTrack(String name)
Loads a track from the plugin's storage provider into memory.
|
CompletableFuture<Void> |
saveTrack(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 null@Nonnull default 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 nullCopyright © 2018. All rights reserved.