Plugin doesn't send anything during reset. Disconnect handling.
This commit is contained in:
parent
08bdfe9b22
commit
7cb4890995
|
|
@ -5,7 +5,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "org.adde0109"
|
group = "org.adde0109"
|
||||||
version = "1.3.2-beta-rc8"
|
version = "1.3.2-beta-rc10"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19;
|
||||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19_3;
|
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19_3;
|
||||||
import static com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentIdentifier.mapSet;
|
import static com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentIdentifier.mapSet;
|
||||||
|
|
||||||
@Plugin(id = "ambassador", name = "Ambassador", version = "1.3.2-beta-rc4", authors = {"adde0109"})
|
@Plugin(id = "ambassador", name = "Ambassador", version = "1.3.2-beta-rc", authors = {"adde0109"})
|
||||||
public class Ambassador {
|
public class Ambassador {
|
||||||
|
|
||||||
public ProxyServer server;
|
public ProxyServer server;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,12 @@ public enum VelocityForgeBackendConnectionPhase implements BackendConnectionPhas
|
||||||
VelocityForgeBackendConnectionPhase nextPhase() {
|
VelocityForgeBackendConnectionPhase nextPhase() {
|
||||||
return WAITING_FOR_ACK;
|
return WAITING_FOR_ACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean consideredComplete() {
|
||||||
|
//Safe if the server hasn't initiated the handshake yet.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
WAITING_FOR_ACK() {
|
WAITING_FOR_ACK() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import org.adde0109.ambassador.forge.pipeline.ForgeLoginWrapperDecoder;
|
||||||
import org.adde0109.ambassador.velocity.client.FML2CRPMResetCompleteDecoder;
|
import org.adde0109.ambassador.velocity.client.FML2CRPMResetCompleteDecoder;
|
||||||
import org.adde0109.ambassador.velocity.client.OutboundForgeHandshakeQueue;
|
import org.adde0109.ambassador.velocity.client.OutboundForgeHandshakeQueue;
|
||||||
import org.adde0109.ambassador.velocity.client.OutboundSuccessHolder;
|
import org.adde0109.ambassador.velocity.client.OutboundSuccessHolder;
|
||||||
|
import org.adde0109.ambassador.velocity.client.PluginLoginPacketQueue;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
@ -49,11 +50,14 @@ public enum VelocityForgeClientConnectionPhase implements ClientConnectionPhase
|
||||||
}
|
}
|
||||||
player.getConnectionInFlight().getConnection().getChannel().config().setAutoRead(false);
|
player.getConnectionInFlight().getConnection().getChannel().config().setAutoRead(false);
|
||||||
|
|
||||||
|
//Prepare to receive reset ACK and Forge Handshake.
|
||||||
connection.getChannel().pipeline().addBefore(Connections.MINECRAFT_DECODER, ForgeConstants.RESET_LISTENER,new FML2CRPMResetCompleteDecoder());
|
connection.getChannel().pipeline().addBefore(Connections.MINECRAFT_DECODER, ForgeConstants.RESET_LISTENER,new FML2CRPMResetCompleteDecoder());
|
||||||
connection.getChannel().pipeline().addAfter(Connections.MINECRAFT_ENCODER, ForgeConstants.FORGE_HANDSHAKE_HOLDER,new OutboundForgeHandshakeQueue());
|
connection.getChannel().pipeline().addAfter(Connections.MINECRAFT_ENCODER, ForgeConstants.FORGE_HANDSHAKE_HOLDER,new OutboundForgeHandshakeQueue());
|
||||||
((ForgeLoginWrapperDecoder) connection.getChannel().pipeline().get(ForgeConstants.FORGE_HANDSHAKE_DECODER)).registerLoginWrapperID(98);
|
((ForgeLoginWrapperDecoder) connection.getChannel().pipeline().get(ForgeConstants.FORGE_HANDSHAKE_DECODER)).registerLoginWrapperID(98);
|
||||||
|
|
||||||
|
//No more PLAY packets past this point should be sent to the client in case the reset works.
|
||||||
connection.write(new PluginMessage("fml:handshake", Unpooled.wrappedBuffer(ForgeHandshakeUtils.generatePluginResetPacket())));
|
connection.write(new PluginMessage("fml:handshake", Unpooled.wrappedBuffer(ForgeHandshakeUtils.generatePluginResetPacket())));
|
||||||
|
connection.getChannel().pipeline().addAfter(Connections.MINECRAFT_ENCODER,ForgeConstants.PLUGIN_PACKET_QUEUE, new PluginLoginPacketQueue());
|
||||||
|
|
||||||
player.setPhase(WAITING_RESET);
|
player.setPhase(WAITING_RESET);
|
||||||
WAITING_RESET.onTransitionToNewPhase(player);
|
WAITING_RESET.onTransitionToNewPhase(player);
|
||||||
|
|
@ -94,6 +98,7 @@ public enum VelocityForgeClientConnectionPhase implements ClientConnectionPhase
|
||||||
((OutboundSuccessHolder) connection.getChannel().pipeline().get(ForgeConstants.SERVER_SUCCESS_LISTENER))
|
((OutboundSuccessHolder) connection.getChannel().pipeline().get(ForgeConstants.SERVER_SUCCESS_LISTENER))
|
||||||
.sendPacket();
|
.sendPacket();
|
||||||
connection.setState(StateRegistry.PLAY);
|
connection.setState(StateRegistry.PLAY);
|
||||||
|
connection.getChannel().pipeline().remove(ForgeConstants.PLUGIN_PACKET_QUEUE);
|
||||||
((VelocityServer) Ambassador.getInstance().server).registerConnection(player);
|
((VelocityServer) Ambassador.getInstance().server).registerConnection(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package org.adde0109.ambassador.velocity.backend;
|
||||||
|
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.proxy.VelocityServer;
|
import com.velocitypowered.proxy.VelocityServer;
|
||||||
|
import com.velocitypowered.proxy.config.PlayerInfoForwarding;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||||
import com.velocitypowered.proxy.connection.backend.*;
|
import com.velocitypowered.proxy.connection.backend.*;
|
||||||
|
|
@ -11,6 +12,7 @@ import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessage;
|
import com.velocitypowered.proxy.protocol.packet.LoginPluginMessage;
|
||||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccess;
|
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccess;
|
||||||
|
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.adde0109.ambassador.Ambassador;
|
import org.adde0109.ambassador.Ambassador;
|
||||||
import org.adde0109.ambassador.forge.ForgeConstants;
|
import org.adde0109.ambassador.forge.ForgeConstants;
|
||||||
|
|
@ -59,12 +61,12 @@ public class ForgeLoginSessionHandler implements MinecraftSessionHandler {
|
||||||
} else if (player.getConnection().getState() == StateRegistry.LOGIN) {
|
} else if (player.getConnection().getState() == StateRegistry.LOGIN) {
|
||||||
//Initial vanilla
|
//Initial vanilla
|
||||||
//Vanilla -> Forge
|
//Vanilla -> Forge
|
||||||
|
//Forge -> Forge
|
||||||
MinecraftConnection connection = player.getConnection();
|
MinecraftConnection connection = player.getConnection();
|
||||||
((OutboundSuccessHolder) connection.getChannel().pipeline().get(ForgeConstants.SERVER_SUCCESS_LISTENER))
|
((OutboundSuccessHolder) connection.getChannel().pipeline().get(ForgeConstants.SERVER_SUCCESS_LISTENER))
|
||||||
.sendPacket();
|
.sendPacket();
|
||||||
connection.setState(StateRegistry.PLAY);
|
connection.setState(StateRegistry.PLAY);
|
||||||
if (connection.getChannel().pipeline().toMap().containsKey(ForgeConstants.PLUGIN_PACKET_QUEUE))
|
connection.getChannel().pipeline().remove(ForgeConstants.PLUGIN_PACKET_QUEUE);
|
||||||
connection.getChannel().pipeline().remove(ForgeConstants.PLUGIN_PACKET_QUEUE);
|
|
||||||
((VelocityServer) Ambassador.getInstance().server).registerConnection(player);
|
((VelocityServer) Ambassador.getInstance().server).registerConnection(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,8 +80,8 @@ public class ForgeLoginSessionHandler implements MinecraftSessionHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(Disconnect packet) {
|
public boolean handle(Disconnect packet) {
|
||||||
if (!serverConnection.getPlayer().getPhase().consideredComplete()) {
|
if (!serverConnection.getPhase().consideredComplete()) {
|
||||||
serverConnection.getPlayer().handleConnectionException(serverConnection.getServer(), packet,false);
|
serverConnection.getPlayer().handleConnectionException(serverConnection.getServer(), packet, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return original.handle(packet);
|
return original.handle(packet);
|
||||||
|
|
@ -87,19 +89,23 @@ public class ForgeLoginSessionHandler implements MinecraftSessionHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected() {
|
public void disconnected() {
|
||||||
if (!serverConnection.getPhase().consideredComplete()
|
//Same as default just not safe.
|
||||||
&& serverConnection.getPlayer().getPhase() != VelocityForgeClientConnectionPhase.NOT_STARTED) {
|
if (!serverConnection.getPhase().consideredComplete()) {
|
||||||
int protocolVersion = serverConnection.getConnection().getProtocolVersion().getProtocol();
|
if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.LEGACY) {
|
||||||
if (protocolVersion <= ProtocolVersion.MINECRAFT_1_16_4.getProtocol()) {
|
|
||||||
serverConnection.getPlayer().handleConnectionException(serverConnection.getServer(),
|
serverConnection.getPlayer().handleConnectionException(serverConnection.getServer(),
|
||||||
Disconnect.create(Component.text("Ambassador: Backend server disconnected during handshake." +
|
new QuietRuntimeException("The connection to the remote server was unexpectedly closed.\n"
|
||||||
((protocolVersion <= ProtocolVersion.MINECRAFT_1_16_4.getProtocol()) ?
|
+ "This is usually because the remote server does not have BungeeCord IP forwarding "
|
||||||
"Could be mismatched mods." : "")),
|
+ "correctly enabled.\nSee https://velocitypowered.com/wiki/users/forwarding/ "
|
||||||
serverConnection.getPlayer().getProtocolVersion()),false);
|
+ "for instructions on how to configure player info forwarding correctly."),
|
||||||
return;
|
false);
|
||||||
}
|
} else {
|
||||||
|
serverConnection.getPlayer().handleConnectionException(serverConnection.getServer(),
|
||||||
|
new QuietRuntimeException("The connection to the remote server was unexpectedly closed."),
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
original.disconnected();
|
original.disconnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleGeneric(MinecraftPacket packet) {
|
public void handleGeneric(MinecraftPacket packet) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user