diff options
author | Petr Ilin <hevav@hevav.dev> | 2022-07-10 14:15:38 +0300 |
---|---|---|
committer | Petr Ilin <hevav@hevav.dev> | 2022-07-10 14:15:38 +0300 |
commit | 428a1c8e1aa22d2e6df7ccd6e6836925c7be104d (patch) | |
tree | 47bf6da05c77771f27173e5462f677a76d303835 /src/main/java/net/elytrium/limboauth/handler | |
parent | d233006fb68c785e6432327236b9e1f0c3f38b03 (diff) | |
download | LimboAuth-428a1c8e1aa22d2e6df7ccd6e6836925c7be104d.tar.gz LimboAuth-428a1c8e1aa22d2e6df7ccd6e6836925c7be104d.tar.bz2 LimboAuth-428a1c8e1aa22d2e6df7ccd6e6836925c7be104d.zip |
In-async-thread scheduler
Diffstat (limited to 'src/main/java/net/elytrium/limboauth/handler')
-rw-r--r-- | src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java b/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java index 6a65e7f..fbb442a 100644 --- a/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java +++ b/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java @@ -20,7 +20,6 @@ package net.elytrium.limboauth.handler; import at.favre.lib.crypto.bcrypt.BCrypt; import com.j256.ormlite.dao.Dao; import com.velocitypowered.api.proxy.Player; -import com.velocitypowered.api.scheduler.ScheduledTask; import dev.samstevens.totp.code.CodeVerifier; import dev.samstevens.totp.code.DefaultCodeGenerator; import dev.samstevens.totp.code.DefaultCodeVerifier; @@ -31,6 +30,7 @@ import java.text.MessageFormat; import java.util.List; import java.util.Locale; import java.util.UUID; +import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import net.elytrium.java.commons.mc.serialization.Serializer; @@ -101,7 +101,7 @@ public class AuthSessionHandler implements LimboSessionHandler { @Nullable private RegisteredPlayer playerInfo; - private ScheduledTask authMainTask; + private ScheduledFuture<?> authMainTask; private LimboPlayer player; private String ip; @@ -158,7 +158,7 @@ public class AuthSessionHandler implements LimboSessionHandler { Serializer serializer = LimboAuth.getSerializer(); int authTime = Settings.IMP.MAIN.AUTH_TIME; float multiplier = 1000.0F / authTime; - this.authMainTask = this.plugin.getServer().getScheduler().buildTask(this.plugin, () -> { + this.authMainTask = this.plugin.getScheduler().scheduleWithFixedDelay(() -> { if (System.currentTimeMillis() - this.joinTime > authTime) { this.proxyPlayer.disconnect(timesUp); } else { @@ -169,7 +169,7 @@ public class AuthSessionHandler implements LimboSessionHandler { this.bossBar.progress(Math.min(1.0F, secondsLeft * multiplier)); } } - }).repeat(1, TimeUnit.SECONDS).schedule(); + }, 0, 1, TimeUnit.SECONDS); if (bossBarEnabled) { this.proxyPlayer.showBossBar(this.bossBar); @@ -249,7 +249,7 @@ public class AuthSessionHandler implements LimboSessionHandler { @Override public void onDisconnect() { if (this.authMainTask != null) { - this.authMainTask.cancel(); + this.authMainTask.cancel(true); } this.proxyPlayer.hideBossBar(this.bossBar); |