List
typealias OnExpireCallback<T> = (T) -> Unit
interface ExpirationList<E> : MutableIterable<E> {
/**
* Returns the time missing to expire or `null` if the list don't contain the element
*/
fun missingTime(element: E): Int?
/**
* Add the element to the list with an expiration time.
*
* [expireTime] in seconds
* callback [onExpire] is called when the element expires.
*/
fun add(element: E, expireTime: Int, onExpire: OnExpireCallback<E>? = null)
/**
* Add the element in the start of list with an expiration time.
*
* [expireTime] in seconds
* callback [onExpire] is called when the element expires.
*/
fun addFirst(element: E, expireTime: Int, onExpire: OnExpireCallback<E>? = null)
}Creating one
Expiration List uses Bukkit tasks to expire the values inside, in this case, a Plugin is needed (you will find extension to WITHPLUGIN INTERFACE as well).
expirationListOf(): Empty expiration listexpirationListOf(expireTime: Int, vararg elements: E): Expiration list with a list of element that will expire in the time provided (in seconds)expirationListOf(expireTime: Int, plugin: Plugin, vararg elements: Pair<E, OnExpireCallback<E>>): Expiration list with a list of element in Pair togther with the OnExpireCallback.
Last updated