From 1da308838c82e584bf8c6548cf1e2f78c123e40e Mon Sep 17 00:00:00 2001 From: xism4 Date: Sun, 25 Aug 2024 16:18:56 +0200 Subject: [PATCH] Move getOfflinePlayer to own async thread --- .../voteparty/bungee/NuVotifierBungeeHandler.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/me/clip/voteparty/bungee/NuVotifierBungeeHandler.kt b/src/main/kotlin/me/clip/voteparty/bungee/NuVotifierBungeeHandler.kt index 2661db63..9939cd04 100644 --- a/src/main/kotlin/me/clip/voteparty/bungee/NuVotifierBungeeHandler.kt +++ b/src/main/kotlin/me/clip/voteparty/bungee/NuVotifierBungeeHandler.kt @@ -1,7 +1,6 @@ package me.clip.voteparty.bungee import com.google.gson.Gson -import com.vexsoftware.votifier.model.Vote import me.clip.voteparty.base.Addon import me.clip.voteparty.base.State import me.clip.voteparty.conf.sections.HookSettings @@ -56,8 +55,14 @@ internal class NuVotifierBungeeHandler(override val plugin: VotePartyPlugin) : A return } - val player = party.usersHandler[vote.username]?.player() ?: server.getOfflinePlayer(vote.username) - val event = VoteReceivedEvent(player, vote.serviceName) - server.pluginManager.callEvent(event) + // Runs on separated thread for mojang uuid player check + Bukkit.getScheduler().runTaskAsynchronously(plugin, Runnable { + val player = party.usersHandler[vote.username]?.player() ?: server.getOfflinePlayer(vote.username) + val event = VoteReceivedEvent(player, vote.serviceName) + + Bukkit.getScheduler().runTask(plugin, Runnable { + server.pluginManager.callEvent(event) + }) + }) } } \ No newline at end of file