CRPM detection
This commit is contained in:
parent
1b59fbae1a
commit
cd8df2c5a0
|
|
@ -5,7 +5,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "org.adde0109"
|
||||
version = "1.4.0-beta-rc2"
|
||||
version = "1.4.0-beta-rc4"
|
||||
|
||||
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.4.0-beta-rc1", authors = {"adde0109"})
|
||||
@Plugin(id = "ambassador", name = "Ambassador", version = "1.4.0-beta-rc4", authors = {"adde0109"})
|
||||
public class Ambassador {
|
||||
|
||||
public ProxyServer server;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@ public enum VelocityForgeClientConnectionPhase implements ClientConnectionPhase
|
|||
VelocityForgeClientConnectionPhase nextPhase() {
|
||||
return IN_PROGRESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetConnectionPhase(ConnectedPlayer player) {
|
||||
RESETTABLE.resetConnectionPhase(player);
|
||||
}
|
||||
},
|
||||
IN_PROGRESS {
|
||||
},
|
||||
|
|
@ -58,9 +63,8 @@ public enum VelocityForgeClientConnectionPhase implements ClientConnectionPhase
|
|||
|
||||
if (connection.getState() == StateRegistry.PLAY) {
|
||||
connection.write(new PluginMessage("fml:handshake", Unpooled.wrappedBuffer(ForgeHandshakeUtils.generatePluginResetPacket())));
|
||||
connection.setState(StateRegistry.LOGIN);
|
||||
} else {
|
||||
connection.write(new LoginPluginMessage(98,"fml:handshake", Unpooled.wrappedBuffer(ForgeHandshakeUtils.generateResetPacket())));
|
||||
connection.write(new LoginPluginMessage(98,"fml:loginwrapper", Unpooled.wrappedBuffer(ForgeHandshakeUtils.generateResetPacket())));
|
||||
}
|
||||
|
||||
//Prepare to receive reset ACK
|
||||
|
|
@ -94,12 +98,13 @@ public enum VelocityForgeClientConnectionPhase implements ClientConnectionPhase
|
|||
if (msg.getId() == 98) {
|
||||
player.getConnection().getChannel().pipeline().remove(ForgeConstants.RESET_LISTENER);
|
||||
player.setPhase(NOT_STARTED);
|
||||
player.getConnection().setState(StateRegistry.LOGIN);
|
||||
|
||||
player.getConnection().getChannel().pipeline().remove(ForgeConstants.LOGIN_PACKET_QUEUE);
|
||||
|
||||
if (!(server.getConnection().getType() instanceof ForgeFMLConnectionType)) {
|
||||
// -> vanilla
|
||||
complete(player);
|
||||
complete(player, msg.getSuccess());
|
||||
player.getConnectionInFlight().getConnection().getChannel().config().setAutoRead(true);
|
||||
}
|
||||
|
||||
|
|
@ -173,12 +178,16 @@ public enum VelocityForgeClientConnectionPhase implements ClientConnectionPhase
|
|||
}
|
||||
|
||||
public void complete(ConnectedPlayer player) {
|
||||
complete(player, isResettable(player));
|
||||
}
|
||||
|
||||
public void complete(ConnectedPlayer player, boolean resettable) {
|
||||
MinecraftConnection connection = player.getConnection();
|
||||
((OutboundSuccessHolder) connection.getChannel().pipeline().get(ForgeConstants.SERVER_SUCCESS_LISTENER))
|
||||
.sendPacket();
|
||||
connection.setState(StateRegistry.PLAY);
|
||||
|
||||
if (isResettable(player)) {
|
||||
if (resettable) {
|
||||
player.setPhase(RESETTABLE);
|
||||
RESETTABLE.onTransitionToNewPhase(player);
|
||||
RESETTABLE.clientModList = clientModList;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ public class GenericForgeLoginWrapperPacket extends DeferredByteBufHolder implem
|
|||
return id;
|
||||
}
|
||||
|
||||
public boolean success() {
|
||||
@Override
|
||||
public boolean getSuccess() {
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,4 +5,6 @@ import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse;
|
|||
public interface IForgeLoginWrapperPacket {
|
||||
public LoginPluginResponse encode();
|
||||
public int getId();
|
||||
|
||||
public boolean getSuccess();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package org.adde0109.ambassador.forge.packet;
|
|||
|
||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.api.util.ModInfo;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.packet.LoginPluginResponse;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
|
@ -21,12 +20,15 @@ public class ModListReplyPacket implements IForgeLoginWrapperPacket {
|
|||
|
||||
private final int id;
|
||||
|
||||
private final boolean success;
|
||||
|
||||
private ModListReplyPacket(List<String> mods, Map<ChannelIdentifier,
|
||||
String> channels, Map<String, String> registries, int id) {
|
||||
String> channels, Map<String, String> registries, int id, boolean success) {
|
||||
this.mods = mods;
|
||||
this.channels = channels;
|
||||
this.registries = registries;
|
||||
this.id = id;
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public static ModListReplyPacket read(LoginPluginResponse msg) {
|
||||
|
|
@ -48,7 +50,7 @@ public class ModListReplyPacket implements IForgeLoginWrapperPacket {
|
|||
for (int x = 0; x < len; x++)
|
||||
registries.put(ProtocolUtils.readString(input, 32767), ProtocolUtils.readString(input, 0x100));
|
||||
|
||||
return new ModListReplyPacket(mods, channels, registries, msg.getId());
|
||||
return new ModListReplyPacket(mods, channels, registries, msg.getId(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -85,6 +87,11 @@ public class ModListReplyPacket implements IForgeLoginWrapperPacket {
|
|||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public List<String> getMods() {
|
||||
return mods;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ 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 io.netty.buffer.Unpooled;
|
||||
import org.adde0109.ambassador.forge.*;
|
||||
|
||||
public class ForgeLoginSessionHandler implements MinecraftSessionHandler {
|
||||
|
|
@ -48,17 +49,10 @@ public class ForgeLoginSessionHandler implements MinecraftSessionHandler {
|
|||
}
|
||||
ConnectedPlayer player = serverConnection.getPlayer();
|
||||
if (!(serverConnection.getConnection().getType() instanceof ForgeFMLConnectionType)) {
|
||||
if (player.getConnectedServer() == null) {
|
||||
//Initial Vanilla
|
||||
//Send empty mod list in order to get client mod list
|
||||
//((VelocityForgeClientConnectionPhase) player.getPhase()).sendVanillaModlist(player);
|
||||
//player.getConnectionInFlight().getConnection().getChannel().config().setAutoRead(false);
|
||||
((VelocityForgeClientConnectionPhase) player.getPhase()).complete(player);
|
||||
} else if (player.getConnectedServer().getConnection().getType() instanceof ForgeFMLConnectionType) {
|
||||
//Forge -> vanilla
|
||||
player.getPhase().resetConnectionPhase(player);
|
||||
player.getConnectionInFlight().getConnection().getChannel().config().setAutoRead(false);
|
||||
}
|
||||
} else {
|
||||
((VelocityForgeClientConnectionPhase) player.getPhase()).complete(player);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user