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).
-
Method Summary
Modifier and TypeMethodDescriptioncreateAndLoadTrack(@NonNull String name) Creates a new track in the plugin's storage provider and then loads it into memory.deleteTrack(@NonNull Track track) Permanently deletes a track from the plugin's storage provider.Gets a set of all loaded tracks.Gets a loaded track.booleanCheck if a track is loaded in memoryLoads all tracks into memory.Loads a track from the plugin's storage provider into memory.default @NonNull CompletableFuture<Void> Loads (or creates) a track from the plugin's storage provider, applies the givenaction, then saves the track's data back to storage.Saves a track's data back to the plugin's storage provider.
-
Method Details
-
createAndLoadTrack
Creates a new track in the plugin's storage provider and then loads it into memory.If a track by the same name already exists, it will be loaded.
- Parameters:
name- the name of the track- Returns:
- the resultant track
- Throws:
NullPointerException- if the name is null
-
loadTrack
Loads a track from the plugin's storage provider into memory.Returns an
empty optionalif the track does not exist.- Parameters:
name- the name of the track- Returns:
- the resultant track
- Throws:
NullPointerException- if the name is null
-
saveTrack
Saves a track's data back to the plugin's storage provider.You should call this after you make any changes to a track.
- Parameters:
track- the track to save- Returns:
- a future to encapsulate the operation.
- Throws:
NullPointerException- if track is nullIllegalStateException- if the track instance was not obtained from LuckPerms.
-
deleteTrack
Permanently deletes a track from the plugin's storage provider.- Parameters:
track- the track to delete- Returns:
- a future to encapsulate the operation.
- Throws:
NullPointerException- if track is nullIllegalStateException- if the track instance was not obtained from LuckPerms.
-
modifyTrack
default @NonNull CompletableFuture<Void> modifyTrack(@NonNull String name, @NonNull Consumer<? super Track> action) Loads (or creates) a track from the plugin's storage provider, applies the givenaction, then saves the track's data back to storage.This method effectively calls
createAndLoadTrack(String), followed by theaction, thensaveTrack(Track), and returns an encapsulation of the whole process as aCompletableFuture.- Parameters:
name- the name of the trackaction- the action to apply to the track- Returns:
- a future to encapsulate the operation
- Since:
- 5.5
-
loadAllTracks
@NonNull CompletableFuture<Void> loadAllTracks()Loads all tracks into memory.- Returns:
- a future to encapsulate the operation.
-
getTrack
-
getLoadedTracks
-
isLoaded
Check if a track is loaded in memory- Parameters:
name- the name to check for- Returns:
- true if the track is loaded
- Throws:
NullPointerException- if the name is null
-