mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-29 21:43:30 +01:00
Merge branch 'master' of https://github.com/MylesIsCool/ViaVersion into dev
This commit is contained in:
commit
89f47c6a6a
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user