mirror of
https://github.com/Auxilor/EcoJobs.git
synced 2026-01-06 15:51:59 +00:00
Allow the leaderboard to be disabled
This commit is contained in:
@@ -59,14 +59,15 @@ class EcoJobsPlugin : LibreforgePlugin() {
|
||||
Triggers.register(TriggerJoinJob)
|
||||
Triggers.register(TriggerLeaveJob)
|
||||
Filters.register(FilterJob)
|
||||
|
||||
|
||||
registerSpecificHolderProvider<Player> { player ->
|
||||
player.activeJobs.map { it.getLevel(player.getJobLevel(it)) }.map {
|
||||
SimpleProvidedHolder(it)
|
||||
}
|
||||
}
|
||||
|
||||
EcoJobsJobTopPlaceholder(this).register()
|
||||
if (this.configYml.getBool("leaderboard.enabled"))
|
||||
EcoJobsJobTopPlaceholder(this).register()
|
||||
|
||||
PlayerPlaceholder(
|
||||
this,
|
||||
|
||||
@@ -12,7 +12,8 @@ class CommandJobs(plugin: EcoPlugin) : PluginCommand(plugin, "jobs", "ecojobs.co
|
||||
init {
|
||||
this.addSubcommand(CommandJoin(plugin))
|
||||
.addSubcommand(CommandLeave(plugin))
|
||||
.addSubcommand(CommandTop(plugin))
|
||||
if (plugin.configYml.getBool("leaderboard.enabled"))
|
||||
this.addSubcommand(CommandTop(plugin))
|
||||
}
|
||||
|
||||
override fun onExecute(player: Player, args: List<String>) {
|
||||
|
||||
@@ -12,8 +12,14 @@ import java.util.concurrent.TimeUnit
|
||||
|
||||
object JobsLeaderboard {
|
||||
private var leaderboardCache = Caffeine.newBuilder()
|
||||
.expireAfterWrite(1, TimeUnit.MINUTES)
|
||||
.expireAfterWrite(
|
||||
Duration.ofSeconds(
|
||||
EcoJobsPlugin.instance.configYml.getInt("leaderboard.cache-lifetime").toLong()
|
||||
)
|
||||
)
|
||||
.build<Boolean, Map<Job, List<UUID>>> {
|
||||
if (!EcoJobsPlugin.instance.configYml.getBool("leaderboard.enabled"))
|
||||
return@build emptyMap()
|
||||
val offlinePlayers = Bukkit.getOfflinePlayers()
|
||||
val top = mutableMapOf<Job, List<UUID>>()
|
||||
for (job in Jobs.values())
|
||||
|
||||
@@ -8,6 +8,14 @@
|
||||
# cross-server sync.
|
||||
use-local-storage: false
|
||||
|
||||
leaderboard:
|
||||
# You can disable the top leaderboard if you don't want it
|
||||
# Please note that it will require a full server restart to take into effect
|
||||
enabled: true
|
||||
|
||||
# Time in seconds for the lifetime of the leaderboard cache
|
||||
cache-lifetime: 60
|
||||
|
||||
jobs:
|
||||
limit: 3 # The most jobs a player can have at once.
|
||||
# You can set custom limits with the ecojobs.limit.<number> permission
|
||||
|
||||
Reference in New Issue
Block a user