Skip to content

Commit

Permalink
Fix PostLogin task never removed (closes #97)
Browse files Browse the repository at this point in the history
  • Loading branch information
hevav committed Jul 5, 2023
1 parent bb3544c commit beb4871
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -103,12 +102,12 @@ public void onProxyDisconnect(DisconnectEvent event) {

@Subscribe
public void onPostLogin(PostLoginEvent event) {
Map<UUID, Runnable> 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();
}
Expand Down

0 comments on commit beb4871

Please sign in to comment.