13
0
geforkt von Mirrors/Velocity

Actually populate ForgeConstants

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-10-15 17:02:19 -04:00
Ursprung 51c402e3d3
Commit 8eb7ecba83
5 geänderte Dateien mit 17 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -6,7 +6,7 @@ import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler; import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler;
import com.velocitypowered.proxy.connection.forge.ForgeUtil; import com.velocitypowered.proxy.connection.forge.ForgeConstants;
import com.velocitypowered.proxy.connection.util.ConnectionMessages; import com.velocitypowered.proxy.connection.util.ConnectionMessages;
import com.velocitypowered.proxy.protocol.MinecraftPacket; import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolConstants; import com.velocitypowered.proxy.protocol.ProtocolConstants;
@ -84,7 +84,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
return true; return true;
} }
if (!serverConn.hasCompletedJoin() && packet.getChannel().equals(ForgeUtil.FORGE_LEGACY_HANDSHAKE_CHANNEL)) { if (!serverConn.hasCompletedJoin() && packet.getChannel().equals(ForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL)) {
if (!serverConn.isLegacyForge()) { if (!serverConn.isLegacyForge()) {
serverConn.setLegacyForge(true); serverConn.setLegacyForge(true);
@ -173,7 +173,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
boolean isMCOrFMLMessage; boolean isMCOrFMLMessage;
if (serverConn.getConnection().getProtocolVersion() <= ProtocolConstants.MINECRAFT_1_12_2) { if (serverConn.getConnection().getProtocolVersion() <= ProtocolConstants.MINECRAFT_1_12_2) {
String channel = message.getChannel(); String channel = message.getChannel();
isMCOrFMLMessage = channel.startsWith("MC|") || channel.startsWith(ForgeUtil.FORGE_LEGACY_HANDSHAKE_CHANNEL); isMCOrFMLMessage = channel.startsWith("MC|") || channel.startsWith(ForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL);
} else { } else {
isMCOrFMLMessage = message.getChannel().startsWith("minecraft:"); isMCOrFMLMessage = message.getChannel().startsWith("minecraft:");
} }

Datei anzeigen

@ -7,6 +7,7 @@ import com.velocitypowered.api.util.ModInfo;
import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection; import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
import com.velocitypowered.proxy.connection.forge.ForgeConstants;
import com.velocitypowered.proxy.connection.forge.ForgeUtil; import com.velocitypowered.proxy.connection.forge.ForgeUtil;
import com.velocitypowered.proxy.protocol.MinecraftPacket; import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolConstants; import com.velocitypowered.proxy.protocol.ProtocolConstants;
@ -144,7 +145,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
} else if (PluginMessageUtil.isMCBrand(packet)) { } else if (PluginMessageUtil.isMCBrand(packet)) {
player.getConnectedServer().getConnection().write(PluginMessageUtil.rewriteMCBrand(packet)); player.getConnectedServer().getConnection().write(PluginMessageUtil.rewriteMCBrand(packet));
} else if (player.getConnectedServer().isLegacyForge() && !player.getConnectedServer().hasCompletedJoin()) { } else if (player.getConnectedServer().isLegacyForge() && !player.getConnectedServer().hasCompletedJoin()) {
if (packet.getChannel().equals(ForgeUtil.FORGE_LEGACY_HANDSHAKE_CHANNEL)) { if (packet.getChannel().equals(ForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL)) {
if (!player.getModInfo().isPresent()) { if (!player.getModInfo().isPresent()) {
ForgeUtil.readModList(packet).ifPresent(mods -> player.setModInfo(new ModInfo("FML", mods))); ForgeUtil.readModList(packet).ifPresent(mods -> player.setModInfo(new ModInfo("FML", mods)));
} }

Datei anzeigen

@ -26,7 +26,7 @@ import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.MinecraftConnection;
import com.velocitypowered.proxy.connection.MinecraftConnectionAssociation; import com.velocitypowered.proxy.connection.MinecraftConnectionAssociation;
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection; import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
import com.velocitypowered.proxy.connection.forge.ForgeUtil; import com.velocitypowered.proxy.connection.forge.ForgeConstants;
import com.velocitypowered.proxy.connection.util.ConnectionMessages; import com.velocitypowered.proxy.connection.util.ConnectionMessages;
import com.velocitypowered.proxy.connection.util.ConnectionRequestResults; import com.velocitypowered.proxy.connection.util.ConnectionRequestResults;
import com.velocitypowered.proxy.protocol.ProtocolConstants; import com.velocitypowered.proxy.protocol.ProtocolConstants;
@ -400,8 +400,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
public void sendLegacyForgeHandshakeResetPacket() { public void sendLegacyForgeHandshakeResetPacket() {
if (connection.canSendLegacyFMLResetPacket()) { if (connection.canSendLegacyFMLResetPacket()) {
PluginMessage resetPacket = new PluginMessage(); PluginMessage resetPacket = new PluginMessage();
resetPacket.setChannel(ForgeUtil.FORGE_LEGACY_HANDSHAKE_CHANNEL); resetPacket.setChannel(ForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL);
resetPacket.setData(ForgeUtil.FORGE_LEGACY_HANDSHAKE_RESET_DATA); resetPacket.setData(ForgeConstants.FORGE_LEGACY_HANDSHAKE_RESET_DATA);
connection.write(resetPacket); connection.write(resetPacket);
connection.setCanSendLegacyFMLResetPacket(false); connection.setCanSendLegacyFMLResetPacket(false);
} }

Datei anzeigen

@ -1,4 +1,12 @@
package com.velocitypowered.proxy.connection.forge; package com.velocitypowered.proxy.connection.forge;
public class ForgeConstants { public class ForgeConstants {
public static final String FORGE_LEGACY_HANDSHAKE_CHANNEL = "FML|HS";
public static final String FORGE_LEGACY_CHANNEL = "FML";
public static final String FORGE_MULTIPART_LEGACY_CHANNEL = "FML|MP";
public static final byte[] FORGE_LEGACY_HANDSHAKE_RESET_DATA = new byte[] { -2, 0 };
private ForgeConstants() {
throw new AssertionError();
}
} }

Datei anzeigen

@ -12,10 +12,6 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
public class ForgeUtil { public class ForgeUtil {
public static final String FORGE_LEGACY_HANDSHAKE_CHANNEL = "FML|HS";
public static final String FORGE_LEGACY_CHANNEL = "FML";
public static final String FORGE_MULTIPART_LEGACY_CHANNEL = "FML|MP";
public static final byte[] FORGE_LEGACY_HANDSHAKE_RESET_DATA = new byte[] { -2, 0 };
private ForgeUtil() { private ForgeUtil() {
throw new AssertionError(); throw new AssertionError();
@ -23,7 +19,7 @@ public class ForgeUtil {
public static Optional<List<ModInfo.Mod>> readModList(PluginMessage message) { public static Optional<List<ModInfo.Mod>> readModList(PluginMessage message) {
Preconditions.checkNotNull(message, "message"); Preconditions.checkNotNull(message, "message");
Preconditions.checkArgument(message.getChannel().equals(FORGE_LEGACY_HANDSHAKE_CHANNEL), Preconditions.checkArgument(message.getChannel().equals(ForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL),
"message is not a FML HS plugin message"); "message is not a FML HS plugin message");
ByteBuf byteBuf = Unpooled.wrappedBuffer(message.getData()); ByteBuf byteBuf = Unpooled.wrappedBuffer(message.getData());