Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 00:00:28 +01:00
Fix ProtocolSupport not working on new versions #629 (+1 ProtocolSupport having nice code)
Dieser Commit ist enthalten in:
Ursprung
9d991cdd26
Commit
899eac0e7e
@ -33,8 +33,16 @@ public class ClassGenerator {
|
|||||||
addSpigotCompatibility(pool, BukkitDecodeHandler.class, decodeSuper);
|
addSpigotCompatibility(pool, BukkitDecodeHandler.class, decodeSuper);
|
||||||
addSpigotCompatibility(pool, BukkitEncodeHandler.class, encodeSuper);
|
addSpigotCompatibility(pool, BukkitEncodeHandler.class, encodeSuper);
|
||||||
} else {
|
} else {
|
||||||
Class decodeSuper = Class.forName(getPSPackage().equals("unknown") ? "protocolsupport.protocol.pipeline.common.PacketDecoder" : getPSPackage() + ".wrapped.WrappedDecoder");
|
// ProtocolSupport compatibility
|
||||||
Class encodeSuper = Class.forName(getPSPackage().equals("unknown") ? "protocolsupport.protocol.pipeline.common.PacketEncoder" : getPSPackage() + ".wrapped.WrappedEncoder");
|
Class encodeSuper;
|
||||||
|
Class decodeSuper;
|
||||||
|
if (isMultiplatformPS()) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
String psPackage = getOldPSPackage();
|
||||||
|
decodeSuper = Class.forName(psPackage.equals("unknown") ? "protocolsupport.protocol.pipeline.common.PacketDecoder" : psPackage + ".wrapped.WrappedDecoder");
|
||||||
|
encodeSuper = Class.forName(psPackage.equals("unknown") ? "protocolsupport.protocol.pipeline.common.PacketEncoder" : psPackage + ".wrapped.WrappedEncoder");
|
||||||
|
}
|
||||||
// Generate the classes
|
// Generate the classes
|
||||||
addPSCompatibility(pool, BukkitDecodeHandler.class, decodeSuper);
|
addPSCompatibility(pool, BukkitDecodeHandler.class, decodeSuper);
|
||||||
addPSCompatibility(pool, BukkitEncodeHandler.class, encodeSuper);
|
addPSCompatibility(pool, BukkitEncodeHandler.class, encodeSuper);
|
||||||
@ -110,7 +118,7 @@ public class ClassGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Class addPSCompatibility(ClassPool pool, Class input, Class superclass) {
|
private static Class addPSCompatibility(ClassPool pool, Class input, Class superclass) {
|
||||||
boolean newPS = getPSPackage().equals("unknown");
|
boolean newPS = getOldPSPackage().equals("unknown");
|
||||||
String newName = "us.myles.ViaVersion.classgenerator.generated." + input.getSimpleName();
|
String newName = "us.myles.ViaVersion.classgenerator.generated." + input.getSimpleName();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -121,8 +129,8 @@ public class ClassGenerator {
|
|||||||
|
|
||||||
if (!newPS) {
|
if (!newPS) {
|
||||||
// Override setRealEncoder / setRealDecoder
|
// Override setRealEncoder / setRealDecoder
|
||||||
pool.importPackage(getPSPackage());
|
pool.importPackage(getOldPSPackage());
|
||||||
pool.importPackage(getPSPackage() + ".wrapped");
|
pool.importPackage(getOldPSPackage() + ".wrapped");
|
||||||
if (superclass.getName().endsWith("Decoder")) {
|
if (superclass.getName().endsWith("Decoder")) {
|
||||||
// Decoder
|
// Decoder
|
||||||
generated.addMethod(CtMethod.make("public void setRealDecoder(IPacketDecoder dec) {\n" +
|
generated.addMethod(CtMethod.make("public void setRealDecoder(IPacketDecoder dec) {\n" +
|
||||||
@ -158,7 +166,7 @@ public class ClassGenerator {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPSPackage() {
|
public static String getOldPSPackage() {
|
||||||
if (psPackage == null) {
|
if (psPackage == null) {
|
||||||
try {
|
try {
|
||||||
Class.forName("protocolsupport.protocol.core.IPacketDecoder");
|
Class.forName("protocolsupport.protocol.core.IPacketDecoder");
|
||||||
@ -174,4 +182,14 @@ public class ClassGenerator {
|
|||||||
}
|
}
|
||||||
return psPackage;
|
return psPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isMultiplatformPS() {
|
||||||
|
try {
|
||||||
|
Class.forName("protocolsupport.zplatform.impl.spigot.network.pipeline.SpigotPacketEncoder");
|
||||||
|
return true;
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren