aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Ilin <hevav@hevav.dev>2022-03-25 18:53:55 +0300
committerPetr Ilin <hevav@hevav.dev>2022-03-25 18:53:55 +0300
commit5b7b05f69414e9b1fa0f2784ce93255dd02b2cec (patch)
tree2910e9a634330c0091e239bcb068b9bdba5b3edb
parent82424d4408abe364cdbc3d640829b550c88d93d5 (diff)
downloadLimboAuth-5b7b05f69414e9b1fa0f2784ce93255dd02b2cec.tar.gz
LimboAuth-5b7b05f69414e9b1fa0f2784ce93255dd02b2cec.tar.bz2
LimboAuth-5b7b05f69414e9b1fa0f2784ce93255dd02b2cec.zip
Events implementation fix
-rw-r--r--src/main/java/net/elytrium/limboauth/LimboAuth.java33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/main/java/net/elytrium/limboauth/LimboAuth.java b/src/main/java/net/elytrium/limboauth/LimboAuth.java
index 8bde70d..9340bad 100644
--- a/src/main/java/net/elytrium/limboauth/LimboAuth.java
+++ b/src/main/java/net/elytrium/limboauth/LimboAuth.java
@@ -80,6 +80,7 @@ import net.elytrium.limboauth.command.PremiumCommand;
import net.elytrium.limboauth.command.TotpCommand;
import net.elytrium.limboauth.command.UnregisterCommand;
import net.elytrium.limboauth.event.PreAuthorizationEvent;
+import net.elytrium.limboauth.event.PreEvent;
import net.elytrium.limboauth.event.PreRegisterEvent;
import net.elytrium.limboauth.floodgate.FloodgateApiHolder;
import net.elytrium.limboauth.handler.AuthSessionHandler;
@@ -423,19 +424,35 @@ public class LimboAuth {
if (registeredPlayer == null) {
this.server.getEventManager().fire(new PreRegisterEvent(player)).thenAcceptAsync((event)
- -> this.sendPlayer(event.getPlayer(), null));
+ -> this.sendPlayer(event, null));
} else {
this.server.getEventManager().fire(new PreAuthorizationEvent(player, registeredPlayer)).thenAcceptAsync((event)
- -> this.sendPlayer(event.getPlayer(), event.getPlayerInfo()));
+ -> this.sendPlayer(event, event.getPlayerInfo()));
}
}
- private void sendPlayer(Player player, RegisteredPlayer registeredPlayer) {
- // Send player to auth virtual server.
- try {
- this.authServer.spawnPlayer(player, new AuthSessionHandler(this.playerDao, player, this, registeredPlayer));
- } catch (Throwable t) {
- this.getLogger().error("Error", t);
+ private void sendPlayer(PreEvent event, RegisteredPlayer registeredPlayer) {
+ Player player = event.getPlayer();
+
+ switch (event.getResult()) {
+ case BYPASS: {
+ this.factory.passLoginLimbo(player);
+ break;
+ }
+ case CANCEL: {
+ player.disconnect(event.getReason());
+ break;
+ }
+ case NORMAL:
+ default: {
+ try {
+ this.authServer.spawnPlayer(player, new AuthSessionHandler(this.playerDao, player, this, registeredPlayer));
+ } catch (Throwable t) {
+ this.getLogger().error("Error", t);
+ }
+
+ break;
+ }
}
}