Configurable send delay

This commit is contained in:
HaHaWTH 2024-04-02 17:34:03 +08:00
parent 73c1116047
commit 54cef57ea5
3 changed files with 17 additions and 5 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -22,6 +22,12 @@ public final class HooksSettings implements SettingsHolder {
public static final Property<Boolean> 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<Long> PROXY_SEND_DELAY =
newProperty("Hooks.proxySendDelay", 10L);
@Comment({"Hook into floodgate.",
"This must be true if you want to use other bedrock features."
})