From beb48712c53410b3eb3e11715fd26e9e54840b95 Mon Sep 17 00:00:00 2001 From: Petr Ilin Date: Wed, 5 Jul 2023 21:49:13 +0300 Subject: [PATCH] Fix PostLogin task never removed (closes #97) --- .../java/net/elytrium/limboauth/listener/AuthListener.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/elytrium/limboauth/listener/AuthListener.java b/src/main/java/net/elytrium/limboauth/listener/AuthListener.java index 7e1cb82d..7df2aa8f 100644 --- a/src/main/java/net/elytrium/limboauth/listener/AuthListener.java +++ b/src/main/java/net/elytrium/limboauth/listener/AuthListener.java @@ -35,7 +35,6 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.sql.SQLException; -import java.util.Map; import java.util.UUID; import java.util.concurrent.TimeUnit; import net.elytrium.commons.utils.reflection.ReflectionException; @@ -103,12 +102,12 @@ public void onProxyDisconnect(DisconnectEvent event) { @Subscribe public void onPostLogin(PostLoginEvent event) { - Map postLoginTasks = this.plugin.getPostLoginTasks(); UUID uuid = event.getPlayer().getUniqueId(); - if (postLoginTasks.containsKey(uuid)) { + Runnable postLoginTask = this.plugin.getPostLoginTasks().remove(uuid); + if (postLoginTask != null) { // We need to delay for player's client to finish switching the server, it takes a little time. this.plugin.getServer().getScheduler() - .buildTask(this.plugin, () -> postLoginTasks.get(uuid).run()) + .buildTask(this.plugin, postLoginTask) .delay(Settings.IMP.MAIN.PREMIUM_AND_FLOODGATE_MESSAGES_DELAY, TimeUnit.MILLISECONDS) .schedule(); }