Package net.luckperms.api.track
Interface TrackManager
-
public interface TrackManagerRepresents the object responsible for managingTrackinstances.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 usingCompletableFuture.thenAcceptAsync(Consumer, Executor).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method 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 @Unmodifiable Set<Track>getLoadedTracks()Gets a set of all loaded tracks.@Nullable TrackgetTrack(@NonNull String name)Gets a loaded track.booleanisLoaded(@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.
-
-
-
Method Detail
-
createAndLoadTrack
@NonNull CompletableFuture<Track> createAndLoadTrack(@NonNull String name)
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
@NonNull CompletableFuture<Optional<Track>> loadTrack(@NonNull String name)
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
@NonNull CompletableFuture<Void> saveTrack(@NonNull Track track)
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
@NonNull CompletableFuture<Void> deleteTrack(@NonNull Track track)
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.
-
loadAllTracks
@NonNull CompletableFuture<Void> loadAllTracks()
Loads all tracks into memory.- Returns:
- a future to encapsulate the operation.
-
getTrack
@Nullable Track getTrack(@NonNull String name)
Gets a loaded track.- Parameters:
name- the name of the track to get- Returns:
- a
Trackobject, if one matching the name exists, or null if not - Throws:
NullPointerException- if the name is null
-
getLoadedTracks
@NonNull @Unmodifiable Set<Track> getLoadedTracks()
Gets a set of all loaded tracks.
-
isLoaded
boolean isLoaded(@NonNull String name)
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
-
-