diff options
author | Petr Ilin <hevav@hevav.dev> | 2022-03-25 18:12:16 +0300 |
---|---|---|
committer | Petr Ilin <hevav@hevav.dev> | 2022-03-25 18:32:05 +0300 |
commit | a992cfc04be8f330f669923360199b7b57a49e35 (patch) | |
tree | 19ce4f06ea28f1be49efb05bee8698b26e709471 /src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java | |
parent | ef636472638b0aec8b7f56fbd3a22943aaa2a47a (diff) | |
download | LimboAuth-a992cfc04be8f330f669923360199b7b57a49e35.tar.gz LimboAuth-a992cfc04be8f330f669923360199b7b57a49e35.tar.bz2 LimboAuth-a992cfc04be8f330f669923360199b7b57a49e35.zip |
Events implementation
Diffstat (limited to 'src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java')
-rw-r--r-- | src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java b/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java index c4c4587..03f9d5f 100644 --- a/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java +++ b/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java @@ -38,6 +38,10 @@ import net.elytrium.limboapi.api.LimboSessionHandler; import net.elytrium.limboapi.api.player.LimboPlayer; import net.elytrium.limboauth.LimboAuth; import net.elytrium.limboauth.Settings; +import net.elytrium.limboauth.event.PostAuthorizationEvent; +import net.elytrium.limboauth.event.PostEvent; +import net.elytrium.limboauth.event.PostRegisterEvent; +import net.elytrium.limboauth.event.TaskEvent; import net.elytrium.limboauth.migration.MigrationHash; import net.elytrium.limboauth.model.RegisteredPlayer; import net.kyori.adventure.bossbar.BossBar; @@ -128,7 +132,7 @@ public class AuthSessionHandler implements LimboSessionHandler { ) ); } - this.finishAuth(); + this.finishRegister(); } } else { this.sendMessage(false); @@ -313,14 +317,27 @@ public class AuthSessionHandler implements LimboSessionHandler { ) ); } - this.finishAuth(); + + this.plugin.getServer().getEventManager() + .fire(new PostAuthorizationEvent(this.player, this.playerInfo)) + .thenAcceptAsync(this::finishAuth); + } + + private void finishRegister() { + this.plugin.getServer().getEventManager() + .fire(new PostRegisterEvent(this.player, this.playerInfo)) + .thenAcceptAsync(this::finishAuth); } - private void finishAuth() { + private void finishAuth(PostEvent event) { if (Settings.IMP.MAIN.CRACKED_TITLE_SETTINGS.CLEAR_AFTER_LOGIN) { this.proxyPlayer.clearTitle(); } + if (event.getResult() == TaskEvent.Result.CANCEL) { + this.proxyPlayer.disconnect(event.getReason()); + } + this.plugin.cacheAuthUser(this.proxyPlayer); this.player.disconnect(); } |