Skip to content

Commit

Permalink
Properly invoke LimboAuth::unsetForcedPreviously
Browse files Browse the repository at this point in the history
  • Loading branch information
UserNugget committed Jun 15, 2024
1 parent 3c703af commit a913e94
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/main/java/net/elytrium/limboauth/listener/AuthListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.j256.ormlite.stmt.UpdateBuilder;
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.PostLoginEvent;
import com.velocitypowered.api.event.connection.PreLoginEvent;
import com.velocitypowered.api.event.player.GameProfileRequestEvent;
Expand Down Expand Up @@ -92,7 +91,19 @@ public void onPreLoginEvent(PreLoginEvent event) {
event.setResult(PreLoginEvent.PreLoginComponentResult.forceOfflineMode());
}
} else {
this.plugin.saveForceOfflineMode(username);
try {
MinecraftConnection connection = this.getConnection(event.getConnection());
if (!connection.isClosed()) {
this.plugin.saveForceOfflineMode(username);

// As Velocity doesnt have any events for our usecase, just inject into netty
connection.getChannel().closeFuture().addListener(future -> {
this.plugin.unsetForcedPreviously(username);
});
}
} catch (Throwable throwable) {
throw new IllegalStateException("failed to track client disconnection", throwable);
}
}
}

Expand Down Expand Up @@ -124,11 +135,6 @@ private boolean isPremiumByIdentifiedKey(InboundConnection inbound) throws Throw
}
*/

@Subscribe
public void onProxyDisconnect(DisconnectEvent event) {
this.plugin.unsetForcedPreviously(event.getPlayer().getUsername());
}

@Subscribe
public void onPostLogin(PostLoginEvent event) {
UUID uuid = event.getPlayer().getUniqueId();
Expand Down

0 comments on commit a913e94

Please sign in to comment.