From 6bf9d371b9a2d60064fdd1c02d4256d97672613d Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Sat, 18 Feb 2023 02:20:16 +0300 Subject: [PATCH] Fixed leaderboard placeholders updating --- .../src/main/kotlin/com/willfp/ecojobs/jobs/Job.kt | 5 ++++- eco-core/core-plugin/src/main/resources/config.yml | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/jobs/Job.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/jobs/Job.kt index 530c946..19fca95 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/jobs/Job.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/jobs/Job.kt @@ -38,6 +38,7 @@ import org.bukkit.Bukkit import org.bukkit.OfflinePlayer import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack +import java.time.Duration import java.util.DoubleSummaryStatistics import java.util.Objects import java.util.concurrent.TimeUnit @@ -47,7 +48,9 @@ import kotlin.math.max class Job( val id: String, val config: Config, private val plugin: EcoJobsPlugin ) { - private val topCache = Caffeine.newBuilder().build() + private val topCache = Caffeine.newBuilder() + .expireAfterWrite(Duration.ofSeconds(plugin.configYml.getInt("leaderboard-cache-lifetime").toLong())) + .build() val name = config.getFormattedString("name") val description = config.getFormattedString("description") diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index 6d507f3..ae6b936 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -312,6 +312,7 @@ point-names: # If you have point names that look ugly (eg g_souls) then you can use-faster-move-trigger: true # Disable if you want move trigger to detect sub-1-block movements raytrace-distance: 80 # The distance that alt_click should check for a location +leaderboard-cache-lifetime: 180 # How often will top placeholders update their cache (in seconds) potions: icon: