FastAsyncWorldEdit

FastAsyncWorldEdit

152k Downloads

Undoing a schematic with API does not ignore air blocks.

derfurkan opened this issue ยท 4 comments

commented

Server Implementation

Paper

Server Version

1.18.2

Describe the bug

When pasting a schematic with the API

 ClipboardFormat format = ClipboardFormats.findByFile(file);
    try {
      ClipboardReader reader = format.getReader(new FileInputStream(file));
      clipboard = reader.read();
    } catch (final IOException e) {
      throw new RuntimeException(e);
    }
    
    currentEditSession = clipboard.paste(FaweAPI.getWorld(Disasters.getModule().getGame().get().getWorldManager().getGameWorld().getName()),to,true,false,null);

The schematic gets pasted while ignoring the airBlocks since pasteAir is set to false as a paremeter.
But when we try to remove it using the API

    if (this.currentEditSession != null) {
        this.currentEditSession.undo(currentEditSession);
      }

The schematic will removed but also sets every block that is in the cuboid of the schematic to its previous state.
Which means every block that is placed near the schematic will be replaced with AIR.

To Reproduce

Create a schematic
Use the FAWE API to paste the schematic somewhere on the world while ignoring airBlocks
Place random blocks inside the area of the schematic which was pasted in
Undo the schematic paste using the API
Not only the schematic will get removed the blocks that were placed are also getting removed

Expected behaviour

Only the blocks of the schematic should be reset to its previous state since the schematic was pasted with the pasteAir boolean set to false. This is completely ignored by the undo mechanic and it just resets all blocks inside the schematics region to their previous state.

Screenshots / Videos

No response

Error log (if applicable)

No response

Fawe Debugpaste

https://athion.net/ISPaster/paste/view/2d2c13bdbff2424991143465793050dd

Fawe Version

FastAsyncWorldEdit version 2.6.3

Checklist

Anything else?

No response

commented

You cannot reuse editsessions, as is outlined in both the WE and FAWE API documentation. Create a new editsession to provide in the undo method editsessionToUndo.undo(newEditsession)

commented

Issue was fixed using the jar containing your pull request (#2305)
Thank you and have a great day!

commented

You cannot reuse editsessions, as is outlined in both the WE and FAWE API documentation. Create a new editsession to provide in the undo method editsessionToUndo.undo(newEditsession)

The issue still persists i'm using this method to undo the schematic:

if (this.currentEditSession != null) {
       try(EditSession newEditSession = WorldEdit.getInstance().newEditSession(FaweAPI.getWorld(Disasters.getModule().getGame().get().getWorldManager().getGameWorld().getName()))) {
           this.currentEditSession.undo(newEditSession);
       } catch (MaxChangedBlocksException e) {
           e.printStackTrace();
       }
     }
commented

This may be a duplicate of #2291 and thus fixed by #2305. Please try using the jar at https://ci.athion.net/job/FastAsyncWorldEdit-Pull-Requests/job/PR-2305/2/