Skip to content

Commit

Permalink
Fix invalid online-mode detection
Browse files Browse the repository at this point in the history
  • Loading branch information
UserNugget committed Jun 15, 2024
1 parent 20a51e1 commit f88746b
Showing 1 changed file with 1 addition and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -92,7 +87,6 @@ public class LoginListener {
private static final MethodHandle CONNECTED_PLAYER_CONSTRUCTOR;
private static final MethodHandle SPAWNED_FIELD;

private final List<String> onlineMode = new ArrayList<>();
private final LimboAPI plugin;
private final VelocityServer server;

Expand All @@ -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())) {
Expand All @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f88746b

Please sign in to comment.