diff --git a/pom.xml b/pom.xml index f128018..217a32e 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.glyart.authmevelocity parent pom - 2.2.0 + 2.2.1-SNAPSHOT 11 diff --git a/proxy/pom.xml b/proxy/pom.xml index d0e5674..519607a 100644 --- a/proxy/pom.xml +++ b/proxy/pom.xml @@ -5,7 +5,7 @@ parent com.glyart.authmevelocity - 2.2.0 + 2.2.1-SNAPSHOT 4.0.0 diff --git a/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/AuthMeConfig.java b/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/AuthMeConfig.java index adde8ca..c39e811 100644 --- a/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/AuthMeConfig.java +++ b/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/AuthMeConfig.java @@ -21,7 +21,7 @@ public final class AuthMeConfig { this.commands = ConfigUtils.getObjectOrElse(toml, "Commands", Commands.class, () -> new Commands(Set.of("login", "register", "l", "reg", "email", "captcha"), "You cannot execute commands if you are not logged in yet")); this.ensure = ConfigUtils.getObjectOrElse(toml, "EnsureAuthServer", EnsureAuthServer.class, - () -> new EnsureAuthServer(false, "You could not connect to a login server, please try again later")); + () -> new EnsureAuthServer(false)); } public static class ServerOnLogin { @@ -62,21 +62,15 @@ public final class AuthMeConfig { public static class EnsureAuthServer { private final boolean ensureFirstServerIsAuthServer; - private final String disconnectMessage; - public EnsureAuthServer(boolean ensureFirstServerIsAuthServer, String disconnectMessage){ + public EnsureAuthServer(boolean ensureFirstServerIsAuthServer){ this.ensureFirstServerIsAuthServer = ensureFirstServerIsAuthServer; - this.disconnectMessage = disconnectMessage; } public boolean ensureAuthServer(){ return this.ensureFirstServerIsAuthServer; } - public @NotNull String getDisconnectMessage(){ - return this.disconnectMessage; - } - } public @NotNull Commands getCommandsConfig(){ diff --git a/proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/ProxyListener.java b/proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/ProxyListener.java index b02d6e9..bc3ddfb 100644 --- a/proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/ProxyListener.java +++ b/proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/ProxyListener.java @@ -96,7 +96,7 @@ public final class ProxyListener { @Subscribe public void onServerPostConnect(ServerPostConnectEvent event) { final Player player = event.getPlayer(); - if(api.isInAuthServer(player)){ + if (api.isLogged(player) && api.isInAuthServer(player)){ ByteArrayDataOutput buf = ByteStreams.newDataOutput(); buf.writeUTF("LOGIN"); player.getCurrentServer().ifPresent(sv -> @@ -122,30 +122,26 @@ public final class ProxyListener { @Subscribe(order = PostOrder.LATE) public void onInitialServer(PlayerChooseInitialServerEvent event, Continuation continuation){ - if( - !config.getEnsureOptions().ensureAuthServer() + if(!config.getEnsureOptions().ensureAuthServer() || event.getInitialServer().map(api::isAuthServer).orElse(false) ) { continuation.resume(); return; } @Nullable RegisteredServer server = getAvailableServer(); - if (server == null) { - continuation.resume(); - logger.error("Cannot send the player {} to an auth server", event.getPlayer().getUsername()); - String disconnectMessage = config.getEnsureOptions().getDisconnectMessage(); - event.getPlayer().disconnect(ConfigUtils.MINIMESSAGE.deserialize(disconnectMessage)); - return; - } + // Velocity takes over in case the initial server is not present event.setInitialServer(server); continuation.resume(); - + if (server == null) { + logger.error("Cannot send the player {} to an auth server", event.getPlayer().getUsername()); + } } + // TODO: Implement #40 private @Nullable RegisteredServer getAvailableServer() { for(String sv : config.getAuthServers()){ Optional opt = proxy.getServer(sv); - if(opt.isPresent()) return opt.get(); + if (opt.isPresent()) return opt.get(); } return null; } diff --git a/proxy/src/main/resources/config.toml b/proxy/src/main/resources/config.toml index 54c5c73..7f42bb1 100644 --- a/proxy/src/main/resources/config.toml +++ b/proxy/src/main/resources/config.toml @@ -24,6 +24,3 @@ authServers = ["auth1", "auth2"] [EnsureAuthServer] # Ensure that the first server to which players connect is an auth server ensureFirstServerIsAuthServer = false - - # Message to be sent to the player in case no auth server is available - disconnectMessage = "You could not connect to a login server, please try again later" \ No newline at end of file diff --git a/spigot/pom.xml b/spigot/pom.xml index 6779597..fa947ff 100644 --- a/spigot/pom.xml +++ b/spigot/pom.xml @@ -5,7 +5,7 @@ parent com.glyart.authmevelocity - 2.2.0 + 2.2.1-SNAPSHOT 4.0.0