Merge branch 'master' into reflection-cleanup

This commit is contained in:
Dan Mulloy 2022-07-24 10:09:34 -04:00 committed by GitHub
commit d96b8f2a6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -303,7 +303,7 @@ public class PacketContainer extends AbstractStructure implements Serializable {
handle = type.getPacketClass()
.getConstructor(MinecraftReflection.getPacketDataSerializerClass())
.newInstance(serializer);
} catch (ReflectiveOperationException ex) {
} catch (NoSuchMethodException | IllegalAccessException | InstantiationException ex) {
// they might have a static method to create them instead
Method method = FuzzyReflection.fromClass(type.getPacketClass(), true)
.getMethod(FuzzyMethodContract
@ -314,9 +314,11 @@ public class PacketContainer extends AbstractStructure implements Serializable {
.build());
try {
handle = method.invoke(null, serializer);
} catch (ReflectiveOperationException ignored) {
throw new RuntimeException("Failed to construct packet for " + type, ex);
} catch (ReflectiveOperationException exception) {
throw new RuntimeException("Failed to construct packet for " + type, exception);
}
} catch (InvocationTargetException ex) {
throw new RuntimeException("Unable to clone packet " + type + " using constructor", ex.getCause());
}
} else {
handle = StructureCache.newPacket(type);