Interface CooldownRepository<K>
- Type Parameters:
K- type of the keys that identifies the profiles
- All Known Implementing Classes:
CooldownRepository.AbstractCooldownRepository,CooldownRepository.CacheCooldownRepository,CooldownRepository.MapCooldownRepository,CooldownRepository.MappingCooldownRepository
Repository that stores
cooldown profiles identifies by keys of type CooldownRepository.
If the command sender objects are temporary (such as game entities, etc) the keys map be mapped to a persistent
identifier by using a mapping(Function, CooldownRepository) repository.
The CooldownProfile creation may be customized by passing a custom CooldownProfileFactory
to CooldownConfiguration.profileFactory().
- Since:
- 1.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic final classstatic final classstatic final class -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteCooldown(@NonNull K key, @NonNull CooldownGroup group) Deletes the cooldown identified by the givenkeybelonging to the givengroup.voiddeleteProfile(@NonNull K key) Deletes the profile identified by the givenkey.static <K> @NonNull CooldownRepository<K>forCache(@NonNull CloudCache<K, CooldownProfile> cache) Returns a new repository backed by the givencache.static <K> @NonNull CooldownRepository<K>forMap(@NonNull Map<K, CooldownProfile> map) Returns a new repository backed by the givenmap.getProfile(@NonNull K key, @NonNull CooldownProfileFactory profileFactory) Returns the profile for the givenkey.getProfileIfExists(@NonNull K key) Returns the profile for the givenkey, if it exists.static <C,K> @NonNull CooldownRepository<C> mapping(@NonNull Function<C, K> mappingFunction, @NonNull CooldownRepository<K> otherRepository) Returns a new repository backed by the givenotherRepositorythat maps requests for keys of typeCooldownRepositoryto typeCooldownRepositoryusing the givenmappingFunction.
-
Method Details
-
mapping
static <C,K> @NonNull CooldownRepository<C> mapping(@NonNull Function<C, K> mappingFunction, @NonNull CooldownRepository<K> otherRepository) Returns a new repository backed by the givenotherRepositorythat maps requests for keys of typeCooldownRepositoryto typeCooldownRepositoryusing the givenmappingFunction.- Type Parameters:
C- command sender typeK- repository key type- Parameters:
mappingFunction- function that maps between the typesotherRepository- backing repository- Returns:
- the repository
-
forCache
Returns a new repository backed by the givencache.- Type Parameters:
K- key type- Parameters:
cache- backing cache- Returns:
- the repository
-
forMap
Returns a new repository backed by the givenmap.- Type Parameters:
K- key type- Parameters:
map- backing map- Returns:
- the repository
-
getProfile
Returns the profile for the givenkey.If no profile exists in the repository, a new profile will be persisted and returned.
- Parameters:
key- key that identifies the profileprofileFactory- factory that creates profiles- Returns:
- the profile
-
getProfileIfExists
Returns the profile for the givenkey, if it exists.- Parameters:
key- key that identifies the profile- Returns:
- the profile, or
null
-
deleteProfile
Deletes the profile identified by the givenkey.- Parameters:
key- the key
-
deleteCooldown
Deletes the cooldown identified by the givenkeybelonging to the givengroup.If the profile is empty after the deletion, then the profile is deleted too.
- Parameters:
key- key identifying the profilegroup- group to delete
-