9
0
mirror of https://github.com/Auxilor/EcoSkills.git synced 2026-01-03 06:12:21 +00:00

Made LeaderboardHandler run asynchronously

This commit is contained in:
Auxilor
2021-12-15 12:30:25 +00:00
parent 89d8189457
commit 290451bd57
2 changed files with 4 additions and 3 deletions

View File

@@ -74,7 +74,7 @@ public class EcoSkillsPlugin extends EcoPlugin {
ActionBarUtils.startRunnable();
}
this.getScheduler().runTimer(new LeaderboardHandler.Runnable(), 50, 2400);
this.getScheduler().runAsyncTimer(new LeaderboardHandler.Runnable(), 50, 2400);
}
/**

View File

@@ -6,14 +6,15 @@ import com.willfp.ecoskills.skills.Skill
import com.willfp.ecoskills.skills.Skills
import org.bukkit.Bukkit
import org.bukkit.OfflinePlayer
import java.util.Collections
import kotlin.math.ceil
import kotlin.math.max
import kotlin.math.min
class LeaderboardHandler {
companion object {
private val sortedLeaderboard = mutableListOf<OfflinePlayer>()
private val skillLeaderboards = mutableMapOf<Skill, MutableList<OfflinePlayer>>()
private val sortedLeaderboard = Collections.synchronizedList(mutableListOf<OfflinePlayer>())
private val skillLeaderboards = Collections.synchronizedMap(mutableMapOf<Skill, MutableList<OfflinePlayer>>())
fun getPage(page: Int, skill: Skill? = null): MutableMap<Int, OfflinePlayer> {
val selectedLeaderboard = if (skill == null) sortedLeaderboard else skillLeaderboards[skill]!!