FastAsyncWorldEdit

FastAsyncWorldEdit

152k Downloads

Mask/Pattern Factory parseFromInput within RichParser broken after 2.11.0 - API

Zeranny opened this issue ยท 5 comments

commented

Server Implementation

Paper

Server Version

1.20.5/6

Describe the bug

Following the updates in #2786, usage of Mask/Pattern factory parseFromInput() within a RichParser paser does not work and causes the surrounding parser to error.

I see this in my own new plugin, and it has also been reported in Arceon @Brennian
I have added a small example code snippet to show what I mean. The error is thrown on the inner Mask parse.

Note that my debugpaste is on Version 2.11.1-SNAPSHOT as I was testing adding debug statements to find the point of failure, I have replicated in on 2.11.0 and reports from those using Arceon are on 2.11.0
Also tested on MC versions 1.20.4, 1.20.5/6, and 1.21.0 and the issue persists

Issue not present on 2.9.2 or 2.10.0

To Reproduce

Using the FAWE API, call Mask/Pattern factory's parseFromInput() inside a RichParser

Expected behaviour

Prior to this update there was no issue using masks/patterns within a RichParser. Looking to restore that functionality.

Screenshots / Videos

image
image

Error log (if applicable)

No response

Fawe Debugpaste

https://athion.net/ISPaster/paste/view/91bb2d0911d741f2b58c459d89e2acf1

Fawe Version

2.11.1-SNAPSHOT

Checklist

Anything else?

public class NearMaskParser extends RichParser<Mask> {

    public NearMaskParser(WorldEdit WorldEdit, String ... aliases) {
        super(WorldEdit, aliases);
    }

    @Override
    protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
        System.out.println("NM"); // Prints
        Mask mask = worldEdit.getMaskFactory().parseFromInput(arguments[0], context);
        System.out.println("Doesn't print");
        ...

        return new NearMask(mask, ...);
    }
}
commented

I can confirm that

commented

How is it being registered to the Mask factory?

commented

How is it being registered to the Mask factory?

worldEdit.getWorldEdit().getMaskFactory().register(new NearMaskParser(worldEdit.getWorldEdit(), "#near"));

@Brennian does Arceon do anything different?

commented

From a little further testing I found it's this line that is failing: https://github.com/IntellectualSites/FastAsyncWorldEdit/blob/561ef4afdd3dd717d1f040b6440af39354d5826f/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java#L113C14-L113C73

At least when using the API it seems to not return as a Mask.

I have a fix which may not be the preferred way to resolve the problem, but it does appear to work. Raising as a PR

commented

Okay so this is a binary incompatibility as the generic method is erased to return Object and the code is compiled to reference a method that returns Mask/Patterninstead.