From f88746b2f50e453b8312a5990d7ea4aa810db829 Mon Sep 17 00:00:00 2001 From: UserNugget Date: Sat, 15 Jun 2024 23:02:25 +0300 Subject: [PATCH] Fix invalid online-mode detection --- .../injection/login/LoginListener.java | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/plugin/src/main/java/net/elytrium/limboapi/injection/login/LoginListener.java b/plugin/src/main/java/net/elytrium/limboapi/injection/login/LoginListener.java index 8d25515e..8e47a4ab 100644 --- a/plugin/src/main/java/net/elytrium/limboapi/injection/login/LoginListener.java +++ b/plugin/src/main/java/net/elytrium/limboapi/injection/login/LoginListener.java @@ -34,10 +34,7 @@ package net.elytrium.limboapi.injection.login; -import com.velocitypowered.api.event.PostOrder; import com.velocitypowered.api.event.Subscribe; -import com.velocitypowered.api.event.connection.DisconnectEvent; -import com.velocitypowered.api.event.connection.PreLoginEvent; import com.velocitypowered.api.event.player.GameProfileRequestEvent; import com.velocitypowered.api.event.player.PlayerChooseInitialServerEvent; import com.velocitypowered.api.event.player.ServerConnectedEvent; @@ -68,8 +65,6 @@ import java.lang.invoke.MethodType; import java.lang.reflect.Field; import java.net.InetSocketAddress; -import java.util.ArrayList; -import java.util.List; import java.util.Objects; import java.util.UUID; import net.elytrium.commons.utils.reflection.ReflectionException; @@ -92,7 +87,6 @@ public class LoginListener { private static final MethodHandle CONNECTED_PLAYER_CONSTRUCTOR; private static final MethodHandle SPAWNED_FIELD; - private final List onlineMode = new ArrayList<>(); private final LimboAPI plugin; private final VelocityServer server; @@ -101,14 +95,6 @@ public LoginListener(LimboAPI plugin, VelocityServer server) { this.server = server; } - @Subscribe(order = PostOrder.LAST) - public void hookPreLogin(PreLoginEvent event) { - PreLoginEvent.PreLoginComponentResult result = event.getResult(); - if (!result.isForceOfflineMode() && (this.server.getConfiguration().isOnlineMode() || result.isOnlineModeAllowed())) { - this.onlineMode.add(event.getUsername()); - } - } - @Subscribe public void hookInitialServer(PlayerChooseInitialServerEvent event) { if (this.plugin.hasNextServer(event.getPlayer())) { @@ -118,11 +104,6 @@ public void hookInitialServer(PlayerChooseInitialServerEvent event) { this.plugin.setLimboJoined(event.getPlayer()); } - @Subscribe - public void onDisconnect(DisconnectEvent event) { - this.onlineMode.remove(event.getPlayer().getUsername()); - } - @SuppressWarnings("ConstantConditions") public void hookLoginSession(GameProfileRequestEvent event) throws Throwable { LoginInboundConnection inboundConnection = (LoginInboundConnection) event.getConnection(); @@ -178,7 +159,7 @@ public void hookLoginSession(GameProfileRequestEvent event) throws Throwable { event.getGameProfile(), connection, inboundConnection.getVirtualHost().orElse(null), - this.onlineMode.contains(event.getUsername()), + event.isOnlineMode(), playerKey ); if (connection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) {