Package net.luckperms.api.track
Interface TrackManager
public interface TrackManager
Represents the object responsible for managing
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.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.
-
loadAllTracks
@NonNull CompletableFuture<Void> loadAllTracks()Loads all tracks into memory.- Returns:
- a future to encapsulate the operation.
-
getTrack
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
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
-