Add delay to bungee force-login messages

This commit is contained in:
Gabriele C 2022-08-18 03:39:40 +02:00
parent b65ffd7c74
commit 6f1c63e693
5 changed files with 17 additions and 4 deletions

View File

@ -153,7 +153,13 @@ public class AsynchronousJoin implements AsynchronousProcess {
});
// Skip if registration is optional
bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN);
if (bungeeSender.isEnabled()) {
// 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), 10L);
}
return;
}

View File

@ -300,7 +300,13 @@ public class AsynchronousLogin implements AsynchronousProcess {
playerCache.updatePlayer(auth);
dataSource.setLogged(name);
sessionService.grantSession(name);
bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN);
if (bungeeSender.isEnabled()) {
// 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), 10L);
}
// As the scheduling executes the Task most likely after the current
// task, we schedule it in the end

View File

@ -308,7 +308,7 @@ public class BukkitService implements SettingsDependent {
}
/**
* Adds a ban to the this list. If a previous ban exists, this will
* Adds a ban to the list. If a previous ban exists, this will
* update the previous entry.
*
* @param ip the ip of the ban

View File

@ -46,7 +46,7 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent
this.isEnabled = bukkitService.isBungeeCordConfiguredForSpigot().orElse(false);
}
if (this.isEnabled) {
Messenger messenger = plugin.getServer().getMessenger();
final Messenger messenger = plugin.getServer().getMessenger();
if (!messenger.isIncomingChannelRegistered(plugin, "BungeeCord")) {
messenger.registerIncomingPluginChannel(plugin, "BungeeCord", this);
}

View File

@ -83,6 +83,7 @@ public class BungeeSender implements SettingsDependent {
if (!isEnabled || destinationServerOnLogin.isEmpty()) {
return;
}
// Add a small delay, just in case...
bukkitService.scheduleSyncDelayedTask(() ->
sendBungeecordMessage(player, "Connect", destinationServerOnLogin), 5L);
}