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"
|
||||
version = "1.3.2-beta-rc8"
|
||||
version = "1.3.2-beta-rc10"
|
||||
|
||||
repositories {
|
||||
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.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 ProxyServer server;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,12 @@ public enum VelocityForgeBackendConnectionPhase implements BackendConnectionPhas
|
|||
VelocityForgeBackendConnectionPhase nextPhase() {
|
||||
return WAITING_FOR_ACK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean consideredComplete() {
|
||||
//Safe if the server hasn't initiated the handshake yet.
|
||||
return true;
|
||||
}
|
||||
},
|
||||
WAITING_FOR_ACK() {
|
||||
@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.OutboundForgeHandshakeQueue;
|
||||
import org.adde0109.ambassador.velocity.client.OutboundSuccessHolder;
|
||||
import org.adde0109.ambassador.velocity.client.PluginLoginPacketQueue;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
|
@ -49,11 +50,14 @@ public enum VelocityForgeClientConnectionPhase implements ClientConnectionPhase
|
|||
}
|
||||
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().addAfter(Connections.MINECRAFT_ENCODER, ForgeConstants.FORGE_HANDSHAKE_HOLDER,new OutboundForgeHandshakeQueue());
|
||||
((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.getChannel().pipeline().addAfter(Connections.MINECRAFT_ENCODER,ForgeConstants.PLUGIN_PACKET_QUEUE, new PluginLoginPacketQueue());
|
||||
|
||||
player.setPhase(WAITING_RESET);
|
||||
WAITING_RESET.onTransitionToNewPhase(player);
|
||||
|
|
@ -94,6 +98,7 @@ public enum VelocityForgeClientConnectionPhase implements ClientConnectionPhase
|
|||
((OutboundSuccessHolder) connection.getChannel().pipeline().get(ForgeConstants.SERVER_SUCCESS_LISTENER))
|
||||
.sendPacket();
|
||||
connection.setState(StateRegistry.PLAY);
|
||||
connection.getChannel().pipeline().remove(ForgeConstants.PLUGIN_PACKET_QUEUE);
|
||||
((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.proxy.VelocityServer;
|
||||
import com.velocitypowered.proxy.config.PlayerInfoForwarding;
|
||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||
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.LoginPluginMessage;
|
||||
import com.velocitypowered.proxy.protocol.packet.ServerLoginSuccess;
|
||||
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.adde0109.ambassador.Ambassador;
|
||||
import org.adde0109.ambassador.forge.ForgeConstants;
|
||||
|
|
@ -59,12 +61,12 @@ public class ForgeLoginSessionHandler implements MinecraftSessionHandler {
|
|||
} else if (player.getConnection().getState() == StateRegistry.LOGIN) {
|
||||
//Initial vanilla
|
||||
//Vanilla -> Forge
|
||||
//Forge -> Forge
|
||||
MinecraftConnection connection = player.getConnection();
|
||||
((OutboundSuccessHolder) connection.getChannel().pipeline().get(ForgeConstants.SERVER_SUCCESS_LISTENER))
|
||||
.sendPacket();
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -78,8 +80,8 @@ public class ForgeLoginSessionHandler implements MinecraftSessionHandler {
|
|||
|
||||
@Override
|
||||
public boolean handle(Disconnect packet) {
|
||||
if (!serverConnection.getPlayer().getPhase().consideredComplete()) {
|
||||
serverConnection.getPlayer().handleConnectionException(serverConnection.getServer(), packet,false);
|
||||
if (!serverConnection.getPhase().consideredComplete()) {
|
||||
serverConnection.getPlayer().handleConnectionException(serverConnection.getServer(), packet, false);
|
||||
return true;
|
||||
}
|
||||
return original.handle(packet);
|
||||
|
|
@ -87,19 +89,23 @@ public class ForgeLoginSessionHandler implements MinecraftSessionHandler {
|
|||
|
||||
@Override
|
||||
public void disconnected() {
|
||||
if (!serverConnection.getPhase().consideredComplete()
|
||||
&& serverConnection.getPlayer().getPhase() != VelocityForgeClientConnectionPhase.NOT_STARTED) {
|
||||
int protocolVersion = serverConnection.getConnection().getProtocolVersion().getProtocol();
|
||||
if (protocolVersion <= ProtocolVersion.MINECRAFT_1_16_4.getProtocol()) {
|
||||
//Same as default just not safe.
|
||||
if (!serverConnection.getPhase().consideredComplete()) {
|
||||
if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.LEGACY) {
|
||||
serverConnection.getPlayer().handleConnectionException(serverConnection.getServer(),
|
||||
Disconnect.create(Component.text("Ambassador: Backend server disconnected during handshake." +
|
||||
((protocolVersion <= ProtocolVersion.MINECRAFT_1_16_4.getProtocol()) ?
|
||||
"Could be mismatched mods." : "")),
|
||||
serverConnection.getPlayer().getProtocolVersion()),false);
|
||||
return;
|
||||
}
|
||||
new QuietRuntimeException("The connection to the remote server was unexpectedly closed.\n"
|
||||
+ "This is usually because the remote server does not have BungeeCord IP forwarding "
|
||||
+ "correctly enabled.\nSee https://velocitypowered.com/wiki/users/forwarding/ "
|
||||
+ "for instructions on how to configure player info forwarding correctly."),
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user