CloudNetService / CloudNet

A modern application that can dynamically and easily deliver Minecraft oriented software
https://cloudnetservice.eu
Apache License 2.0
367 stars 115 forks source link

WorldEdit transformers for 1.8.8 + give more control to transformers (wrapper) #1429

Open DasBabyPixel opened 1 week ago

DasBabyPixel commented 1 week ago

Motivation

A few servers running bukkit 1.8.8 still use worldedit. Only since the change to modern java on those old versions, worldedit stopped to work. This PR fixes worldedit and FAWE on 1.8.8. The necessary class transformers also uncovered a problem in the class transformer api. Converting a ClassNode back to a byte[] was not possible (in some cases), because of COMPUTE_FRAMES|COMPUTE_MAXS.

Some might also want to make use of the wrapper transformer API in wrapper modules, so the custom byte[] creation might come in handy. As an example, I have another project that needs transforming of classes, but uses a byte[] instead of asm. The new API allows something like this:

@Override
public byte[] toByteArray(ClassNode classNode) {
    var bytes = Transformer.super.toByteArray(classNode);
    return CustomTransformer.transform(bytes);
}

Modification

Added transformers for WorldEdit / FAWE Added a custom opt-in serializer option for transformers. Added better logging for transformer failures.

Result

FAWE / WorldEdit supported. Proper handling of transformer errors / soft failure - not doing this causes the JVM to freeze on errors iirc. Give more control to transformers, without changing their default behaviour.

Other context

This is something I concocted some ago and kept in my fork, thought this might be of interest. I did also test worldedit/fawe on 1.20 to make sure this doesn't cause any problems. Didn't notice anything, but as always with transformers, future changes on worldedit (they'd have to do something odd, but still) could cause the transformer to break worldedit functionality.

If the worldedit transformers aren't merged, I'd still love to see the API to give more control to transformers merged, because I use the API changes privately. WorldEdit transformers could be re-added by a wrapper module, but only with the more powerful api.

0utplay commented 21 hours ago

I like the idea, but this might have to wait until we've replaced the networking and asm