misc: Improved AutoLogin debug messages
This commit is contained in:
parent
7c5c75d4b9
commit
d617995bbe
@ -1,5 +1,5 @@
|
|||||||
group = io.github.4drian3d
|
group = io.github.4drian3d
|
||||||
version = 4.0.1
|
version = 4.0.2-SNAPSHOT
|
||||||
description = AuthMeReloaded Support for Velocity
|
description = AuthMeReloaded Support for Velocity
|
||||||
url = https://modrinth.com/plugin/authmevelocity
|
url = https://modrinth.com/plugin/authmevelocity
|
||||||
id = authmevelocity
|
id = authmevelocity
|
||||||
|
@ -29,8 +29,10 @@ import com.velocitypowered.api.event.player.ServerPreConnectEvent;
|
|||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
|
import io.github._4drian3d.authmevelocity.common.configuration.ProxyConfiguration;
|
||||||
import io.github._4drian3d.authmevelocity.velocity.AuthMeVelocityPlugin;
|
import io.github._4drian3d.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||||
import io.github._4drian3d.authmevelocity.velocity.utils.AuthMeUtils;
|
import io.github._4drian3d.authmevelocity.velocity.utils.AuthMeUtils;
|
||||||
|
import io.github._4drian3d.authmevelocity.velocity.utils.Pair;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -60,8 +62,8 @@ public final class ConnectListener {
|
|||||||
plugin.logDebug("PlayerChooseInitialServerEvent | Player is in auth server");
|
plugin.logDebug("PlayerChooseInitialServerEvent | Player is in auth server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final var config = plugin.config().get();
|
final ProxyConfiguration config = plugin.config().get();
|
||||||
final var server = AuthMeUtils.serverToSend(
|
final Pair<RegisteredServer> server = AuthMeUtils.serverToSend(
|
||||||
config.ensureAuthServer().sendMode(), proxy, config.authServers(), config.advanced().randomAttempts());
|
config.ensureAuthServer().sendMode(), proxy, config.authServers(), config.advanced().randomAttempts());
|
||||||
|
|
||||||
// Velocity takes over in case the initial server is not present
|
// Velocity takes over in case the initial server is not present
|
||||||
@ -96,18 +98,26 @@ public final class ConnectListener {
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onServerPostConnect(final ServerPostConnectEvent event) {
|
public void onServerPostConnect(final ServerPostConnectEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (plugin.isLogged(player) && plugin.isInAuthServer(player)) {
|
|
||||||
|
final boolean isLogged = plugin.isLogged(player);
|
||||||
|
plugin.logDebug("ServerPostConnectEvent | Player "+player.getUsername()+" is logged: " + isLogged);
|
||||||
|
final boolean isInAuthServer = plugin.isInAuthServer(player);
|
||||||
|
plugin.logDebug("ServerPostConnectEvent | Player "+player.getUsername()+" is in AuthServer: " + isInAuthServer);
|
||||||
|
|
||||||
|
if (!(isLogged && isInAuthServer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
plugin.logDebug("ServerPostConnectEvent | Already logged player and connected to an Auth server");
|
plugin.logDebug("ServerPostConnectEvent | Already logged player and connected to an Auth server");
|
||||||
final ByteArrayDataOutput buf = ByteStreams.newDataOutput();
|
final ByteArrayDataOutput buf = ByteStreams.newDataOutput();
|
||||||
buf.writeUTF("LOGIN");
|
buf.writeUTF("LOGIN");
|
||||||
player.getCurrentServer().ifPresent(sv -> {
|
player.getCurrentServer().ifPresent(server -> {
|
||||||
var byteArray = buf.toByteArray();
|
final byte[] byteArray = buf.toByteArray();
|
||||||
if (!sv.sendPluginMessage(AuthMeVelocityPlugin.MODERN_CHANNEL, byteArray)) {
|
if (!server.sendPluginMessage(AuthMeVelocityPlugin.MODERN_CHANNEL, byteArray)) {
|
||||||
plugin.logDebug("ServerPostConnectEvent | Failed to send on Modern Channel");
|
plugin.logDebug("ServerPostConnectEvent | Failed to send on Modern Channel");
|
||||||
var legacyResult = sv.sendPluginMessage(AuthMeVelocityPlugin.LEGACY_CHANNEL, byteArray);
|
final boolean legacyResult = server.sendPluginMessage(AuthMeVelocityPlugin.LEGACY_CHANNEL, byteArray);
|
||||||
if (!legacyResult) plugin.logDebug("ServerPostConnectEvent | Failed to send on Legacy Channel");
|
if (!legacyResult) plugin.logDebug("ServerPostConnectEvent | Failed to send on Legacy Channel");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -29,8 +29,10 @@ import com.velocitypowered.api.proxy.ServerConnection;
|
|||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import io.github._4drian3d.authmevelocity.api.velocity.event.*;
|
import io.github._4drian3d.authmevelocity.api.velocity.event.*;
|
||||||
import io.github._4drian3d.authmevelocity.common.MessageType;
|
import io.github._4drian3d.authmevelocity.common.MessageType;
|
||||||
|
import io.github._4drian3d.authmevelocity.common.configuration.ProxyConfiguration;
|
||||||
import io.github._4drian3d.authmevelocity.velocity.AuthMeVelocityPlugin;
|
import io.github._4drian3d.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||||
import io.github._4drian3d.authmevelocity.velocity.utils.AuthMeUtils;
|
import io.github._4drian3d.authmevelocity.velocity.utils.AuthMeUtils;
|
||||||
|
import io.github._4drian3d.authmevelocity.velocity.utils.Pair;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
@ -113,9 +115,9 @@ public class PluginMessageListener {
|
|||||||
private void createServerConnectionRequest(Player player, ServerConnection connection){
|
private void createServerConnectionRequest(Player player, ServerConnection connection){
|
||||||
final RegisteredServer loginServer = player.getCurrentServer().orElse(connection).getServer();
|
final RegisteredServer loginServer = player.getCurrentServer().orElse(connection).getServer();
|
||||||
|
|
||||||
final var config = plugin.config().get();
|
final ProxyConfiguration config = plugin.config().get();
|
||||||
|
|
||||||
final var toSend = AuthMeUtils.serverToSend(
|
final Pair<RegisteredServer> toSend = AuthMeUtils.serverToSend(
|
||||||
config.sendOnLogin().sendMode(), proxy, config.sendOnLogin().teleportServers(), config.advanced().randomAttempts());
|
config.sendOnLogin().sendMode(), proxy, config.sendOnLogin().teleportServers(), config.advanced().randomAttempts());
|
||||||
|
|
||||||
if (toSend.isEmpty()) {
|
if (toSend.isEmpty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user