From 54cef57ea5ff26c9afab4e8695beff47586eba1f Mon Sep 17 00:00:00 2001 From: HaHaWTH Date: Tue, 2 Apr 2024 17:34:03 +0800 Subject: [PATCH] Configurable send delay --- .../fr/xephi/authme/process/join/AsynchronousJoin.java | 8 ++++++-- .../fr/xephi/authme/process/login/AsynchronousLogin.java | 8 +++++--- .../xephi/authme/settings/properties/HooksSettings.java | 6 ++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java index b296a059..ed723f7b 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java @@ -19,6 +19,7 @@ import fr.xephi.authme.service.bungeecord.BungeeSender; import fr.xephi.authme.service.bungeecord.MessageType; import fr.xephi.authme.service.velocity.VMessageType; import fr.xephi.authme.service.velocity.VelocitySender; +import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.commandconfig.CommandManager; import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.RegistrationSettings; @@ -47,6 +48,9 @@ public class AsynchronousJoin implements AsynchronousProcess { @Inject private Server server; + @Inject + private Settings settings; + @Inject private DataSource database; @@ -157,11 +161,11 @@ public class AsynchronousJoin implements AsynchronousProcess { // As described at https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/ // "Keep in mind that you can't send plugin messages directly after a player joins." bukkitService.scheduleSyncDelayedTask(() -> - bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN), 5L); + bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN), settings.getProperty(HooksSettings.PROXY_SEND_DELAY)); } if (velocitySender.isEnabled()) { bukkitService.scheduleSyncDelayedTask(() -> - velocitySender.sendAuthMeVelocityMessage(player, VMessageType.LOGIN), 10L); + velocitySender.sendAuthMeVelocityMessage(player, VMessageType.LOGIN), settings.getProperty(HooksSettings.PROXY_SEND_DELAY)); } return; } diff --git a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java index 9800f554..12ed97a0 100644 --- a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java @@ -28,6 +28,7 @@ import fr.xephi.authme.service.bungeecord.BungeeSender; import fr.xephi.authme.service.bungeecord.MessageType; import fr.xephi.authme.service.velocity.VMessageType; import fr.xephi.authme.service.velocity.VelocitySender; +import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.DatabaseSettings; import fr.xephi.authme.settings.properties.EmailSettings; import fr.xephi.authme.settings.properties.HooksSettings; @@ -83,7 +84,8 @@ public class AsynchronousLogin implements AsynchronousProcess { @Inject private SessionService sessionService; - + @Inject + private Settings settings; @Inject private BungeeSender bungeeSender; @Inject @@ -310,11 +312,11 @@ public class AsynchronousLogin implements AsynchronousProcess { // As described at https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/ // "Keep in mind that you can't send plugin messages directly after a player joins." bukkitService.scheduleSyncDelayedTask(() -> - bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN), 5L); + bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN), settings.getProperty(HooksSettings.PROXY_SEND_DELAY)); } if (velocitySender.isEnabled()) { bukkitService.scheduleSyncDelayedTask(() -> - velocitySender.sendAuthMeVelocityMessage(player, VMessageType.LOGIN), 10L); + velocitySender.sendAuthMeVelocityMessage(player, VMessageType.LOGIN), settings.getProperty(HooksSettings.PROXY_SEND_DELAY)); } // As the scheduling executes the Task most likely after the current diff --git a/src/main/java/fr/xephi/authme/settings/properties/HooksSettings.java b/src/main/java/fr/xephi/authme/settings/properties/HooksSettings.java index 9a8ddadd..08c91c6a 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/HooksSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/HooksSettings.java @@ -22,6 +22,12 @@ public final class HooksSettings implements SettingsHolder { public static final Property VELOCITY = newProperty("Hooks.velocity", false); + @Comment({"How many ticks should we wait before sending login info to proxy?", + "Change this to higher if your player has high ping.", + "See: https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/"}) + public static final Property PROXY_SEND_DELAY = + newProperty("Hooks.proxySendDelay", 10L); + @Comment({"Hook into floodgate.", "This must be true if you want to use other bedrock features." })