diff options
Diffstat (limited to 'src')
8 files changed, 38 insertions, 10 deletions
diff --git a/src/main/java/net/elytrium/limboauth/LimboAuth.java b/src/main/java/net/elytrium/limboauth/LimboAuth.java index 4ea4659..7750f4a 100644 --- a/src/main/java/net/elytrium/limboauth/LimboAuth.java +++ b/src/main/java/net/elytrium/limboauth/LimboAuth.java @@ -386,7 +386,7 @@ public class LimboAuth { RegisteredPlayer registeredPlayer = AuthSessionHandler.fetchInfo(this.playerDao, nickname); boolean onlineMode = player.isOnlineMode(); - boolean onlineModePassed = false; + TaskEvent.Result result = TaskEvent.Result.NORMAL; if (onlineMode || isFloodgate) { if (registeredPlayer == null || registeredPlayer.getHash().isEmpty()) { @@ -424,23 +424,17 @@ public class LimboAuth { } }); - onlineModePassed = true; + result = TaskEvent.Result.BYPASS; } } } if (registeredPlayer == null) { Consumer<TaskEvent> eventConsumer = (event) -> this.sendPlayer(event, null); - this.server.getEventManager().fire(new PreRegisterEvent(player, eventConsumer)).thenAcceptAsync(eventConsumer); + this.server.getEventManager().fire(new PreRegisterEvent(result, player, eventConsumer)).thenAcceptAsync(eventConsumer); } else { Consumer<TaskEvent> eventConsumer = (event) -> this.sendPlayer(event, ((PreAuthorizationEvent) event).getPlayerInfo()); - TaskEvent event = new PreAuthorizationEvent(player, registeredPlayer, eventConsumer); - - if (onlineModePassed) { - event.setResult(TaskEvent.Result.BYPASS); - } - - this.server.getEventManager().fire(event).thenAcceptAsync(eventConsumer); + this.server.getEventManager().fire(new PreAuthorizationEvent(result, player, registeredPlayer, eventConsumer)).thenAcceptAsync(eventConsumer); } } diff --git a/src/main/java/net/elytrium/limboauth/event/PostAuthorizationEvent.java b/src/main/java/net/elytrium/limboauth/event/PostAuthorizationEvent.java index c28ed46..c95218a 100644 --- a/src/main/java/net/elytrium/limboauth/event/PostAuthorizationEvent.java +++ b/src/main/java/net/elytrium/limboauth/event/PostAuthorizationEvent.java @@ -25,4 +25,8 @@ public class PostAuthorizationEvent extends PostEvent { public PostAuthorizationEvent(LimboPlayer player, RegisteredPlayer playerInfo, Consumer<TaskEvent> onComplete) { super(player, playerInfo, onComplete); } + + public PostAuthorizationEvent(Result result, LimboPlayer player, RegisteredPlayer playerInfo, Consumer<TaskEvent> onComplete) { + super(result, player, playerInfo, onComplete); + } } diff --git a/src/main/java/net/elytrium/limboauth/event/PostEvent.java b/src/main/java/net/elytrium/limboauth/event/PostEvent.java index 68932ef..2d5b4fb 100644 --- a/src/main/java/net/elytrium/limboauth/event/PostEvent.java +++ b/src/main/java/net/elytrium/limboauth/event/PostEvent.java @@ -33,6 +33,13 @@ public abstract class PostEvent extends TaskEvent { this.playerInfo = playerInfo; } + protected PostEvent(Result result, LimboPlayer player, RegisteredPlayer playerInfo, Consumer<TaskEvent> onComplete) { + super(result, onComplete); + + this.player = player; + this.playerInfo = playerInfo; + } + public RegisteredPlayer getPlayerInfo() { return this.playerInfo; } diff --git a/src/main/java/net/elytrium/limboauth/event/PostRegisterEvent.java b/src/main/java/net/elytrium/limboauth/event/PostRegisterEvent.java index fd8f24c..882f43b 100644 --- a/src/main/java/net/elytrium/limboauth/event/PostRegisterEvent.java +++ b/src/main/java/net/elytrium/limboauth/event/PostRegisterEvent.java @@ -25,4 +25,8 @@ public class PostRegisterEvent extends PostEvent { public PostRegisterEvent(LimboPlayer player, RegisteredPlayer playerInfo, Consumer<TaskEvent> onComplete) { super(player, playerInfo, onComplete); } + + public PostRegisterEvent(Result result, LimboPlayer player, RegisteredPlayer playerInfo, Consumer<TaskEvent> onComplete) { + super(result, player, playerInfo, onComplete); + } } diff --git a/src/main/java/net/elytrium/limboauth/event/PreAuthorizationEvent.java b/src/main/java/net/elytrium/limboauth/event/PreAuthorizationEvent.java index 207fcf6..45254df 100644 --- a/src/main/java/net/elytrium/limboauth/event/PreAuthorizationEvent.java +++ b/src/main/java/net/elytrium/limboauth/event/PreAuthorizationEvent.java @@ -29,6 +29,11 @@ public class PreAuthorizationEvent extends PreEvent { this.playerInfo = playerInfo; } + public PreAuthorizationEvent(Result result, Player player, RegisteredPlayer playerInfo, Consumer<TaskEvent> onComplete) { + super(result, player, onComplete); + this.playerInfo = playerInfo; + } + public RegisteredPlayer getPlayerInfo() { return this.playerInfo; } diff --git a/src/main/java/net/elytrium/limboauth/event/PreEvent.java b/src/main/java/net/elytrium/limboauth/event/PreEvent.java index 45bb37d..55bf4d3 100644 --- a/src/main/java/net/elytrium/limboauth/event/PreEvent.java +++ b/src/main/java/net/elytrium/limboauth/event/PreEvent.java @@ -28,6 +28,11 @@ public abstract class PreEvent extends TaskEvent { this.player = player; } + protected PreEvent(Result result, Player player, Consumer<TaskEvent> onComplete) { + super(result, onComplete); + this.player = player; + } + public Player getPlayer() { return this.player; } diff --git a/src/main/java/net/elytrium/limboauth/event/PreRegisterEvent.java b/src/main/java/net/elytrium/limboauth/event/PreRegisterEvent.java index 90eff58..971c8c6 100644 --- a/src/main/java/net/elytrium/limboauth/event/PreRegisterEvent.java +++ b/src/main/java/net/elytrium/limboauth/event/PreRegisterEvent.java @@ -24,4 +24,8 @@ public class PreRegisterEvent extends PreEvent { public PreRegisterEvent(Player player, Consumer<TaskEvent> onComplete) { super(player, onComplete); } + + public PreRegisterEvent(Result result, Player player, Consumer<TaskEvent> onComplete) { + super(result, player, onComplete); + } } diff --git a/src/main/java/net/elytrium/limboauth/event/TaskEvent.java b/src/main/java/net/elytrium/limboauth/event/TaskEvent.java index 30e7947..a81c062 100644 --- a/src/main/java/net/elytrium/limboauth/event/TaskEvent.java +++ b/src/main/java/net/elytrium/limboauth/event/TaskEvent.java @@ -35,6 +35,11 @@ public abstract class TaskEvent { this.onComplete = onComplete; } + public TaskEvent(Result result, Consumer<TaskEvent> onComplete) { + this.result = result; + this.onComplete = onComplete; + } + public Result getResult() { return this.result; } |