Fixed modern forwarding support and kick handling

This commit is contained in:
Adrian Bergqvist 2022-10-13 22:05:54 +02:00
parent fd8fb5ae37
commit 14d5d9fc07
No known key found for this signature in database
GPG Key ID: FAE7D8EDE225E686
4 changed files with 6 additions and 3 deletions

View File

@ -4,7 +4,7 @@ plugins {
}
group 'org.adde0109'
version '1.0.4-alpha'
version '1.0.5-alpha'
repositories {
maven {

View File

@ -22,7 +22,7 @@ import org.slf4j.Logger;
import java.nio.file.Path;
@Plugin(id = "ambassador", name = "Ambassador", version = "1.0.4-alpha", authors = {"adde0109"})
@Plugin(id = "ambassador", name = "Ambassador", version = "1.0.5-alpha", authors = {"adde0109"})
public class Ambassador {
public ProxyServer server;

View File

@ -79,6 +79,7 @@ public class ForgeFML2ClientConnectionPhase implements VelocityForgeClientConnec
if (player.getConnectedServer() != null) {
backupServer = player.getConnectedServer().getServer();
player.getConnectedServer().disconnect();
player.setConnectedServer(null);
}
MinecraftConnection connection = player.getConnection();
connection.setSessionHandler(new VelocityForgeHandshakeSessionHandler(connection.getSessionHandler(),player));
@ -112,6 +113,7 @@ public class ForgeFML2ClientConnectionPhase implements VelocityForgeClientConnec
if (backupServer != null && !(event.getResult() instanceof KickedFromServerEvent.RedirectPlayer)) {
net.kyori.adventure.text.Component reason = event.getServerKickReason().orElse(null);
event.setResult(KickedFromServerEvent.RedirectPlayer.create(backupServer,reason));
backupServer = null;
}
}

View File

@ -25,7 +25,8 @@ public class ForgeFML2ConnectionType implements ConnectionType {
@Override
public GameProfile addGameProfileTokensIfRequired(GameProfile original, PlayerInfoForwarding forwardingType) {
original.addProperties(Collections.singleton(new GameProfile.Property("extraData", "\1FML2\1", "")));
if (forwardingType == PlayerInfoForwarding.LEGACY)
original.addProperties(Collections.singleton(new GameProfile.Property("extraData", "\1FML2\1", "")));
return original;
}
}