Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 17:20:24 +01:00
Merge pull request #1021 from 7kasper/master
ViaVersion <3 ProtocolSupport
Dieser Commit ist enthalten in:
Commit
94b3b51602
@ -48,7 +48,7 @@ public class ClassGenerator {
|
|||||||
Class encodeSuper;
|
Class encodeSuper;
|
||||||
Class decodeSuper;
|
Class decodeSuper;
|
||||||
if (isMultiplatformPS()) {
|
if (isMultiplatformPS()) {
|
||||||
psConnectListener = makePSConnectListener(pool);
|
psConnectListener = makePSConnectListener(pool, shouldUseNewHandshakeVersionMethod());
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
String psPackage = getOldPSPackage();
|
String psPackage = getOldPSPackage();
|
||||||
@ -178,7 +178,7 @@ public class ClassGenerator {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Class makePSConnectListener(ClassPool pool) {
|
private static Class makePSConnectListener(ClassPool pool, boolean newVersionMethod) {
|
||||||
try {
|
try {
|
||||||
// Reference classes
|
// Reference classes
|
||||||
CtClass toExtend = pool.get("protocolsupport.api.Connection$PacketListener");
|
CtClass toExtend = pool.get("protocolsupport.api.Connection$PacketListener");
|
||||||
@ -208,10 +208,15 @@ public class ClassGenerator {
|
|||||||
// Check if we are getting handshake packet.
|
// Check if we are getting handshake packet.
|
||||||
+ " if (event.getPacket() instanceof PacketHandshakingInSetProtocol) {\n"
|
+ " if (event.getPacket() instanceof PacketHandshakingInSetProtocol) {\n"
|
||||||
// Get protocol version.
|
// Get protocol version.
|
||||||
+ " int protoVersion = ((PacketHandshakingInSetProtocol) event.getPacket()).getProtocolVersion();\n"
|
+ " PacketHandshakingInSetProtocol packet = (PacketHandshakingInSetProtocol) event.getPacket();\n"
|
||||||
// ViaVersion has at this point already spoofed the connectionversion. (Since it is higher up the pipeline)
|
+ (newVersionMethod ? (
|
||||||
|
" int protoVersion = packet.getProtocolVersion();\n"
|
||||||
|
) : (
|
||||||
|
" int protoVersion = packet.b();\n"
|
||||||
|
))
|
||||||
|
// ViaVersion has at this point already spoofed the connectionversion. (Since it is higher up the pipeline)
|
||||||
// If via has put the protoVersion to the server we can spoof ProtocolSupport's version.
|
// If via has put the protoVersion to the server we can spoof ProtocolSupport's version.
|
||||||
+ " if (protoVersion == us.myles.ViaVersion.api.protocol.ProtocolRegistry.SERVER_PROTOCOL) {\n"
|
+ " if (connection.getVersion() == ProtocolVersion.MINECRAFT_FUTURE && protoVersion == us.myles.ViaVersion.api.protocol.ProtocolRegistry.SERVER_PROTOCOL) {\n"
|
||||||
+ " connection.setVersion(ProtocolVersion.getLatest(ProtocolType.PC));\n"
|
+ " connection.setVersion(ProtocolVersion.getLatest(ProtocolType.PC));\n"
|
||||||
+ " }\n"
|
+ " }\n"
|
||||||
+ " }\n"
|
+ " }\n"
|
||||||
@ -279,4 +284,13 @@ public class ClassGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean shouldUseNewHandshakeVersionMethod() {
|
||||||
|
try {
|
||||||
|
NMSUtil.nms("PacketHandshakingInSetProtocol").getMethod("getProtocolVersion");
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren