Solved WorldEdit API - Undo schematics

Discussion in 'Plugin Development' started by Unica, Feb 18, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Unica

    Helloo.

    I am working with WorldEdit, and since I've never really used it before I have a (hopefully)
    basic question.

    Pasting schematics works like a charm, but I need to undo / remove the schematic
    later, is there a way to loop through all placed blocks / undo a schematic?

    Current code:
    Code:
    private Location loc;
        private final String PATH = Main.getInstance().getDataFolder().getAbsolutePath() + File.separator + "Schematics";
        private CuboidClipboard cc = null;
        private Vector v = null;
       
        public void loadArea() throws IOException, DataException, MaxChangedBlocksException{
            if(GameManager.getCurrentGame() == null) return;
            String name = GameManager.getCurrentGame().getName();
            File f = new File(PATH, name.toLowerCase().replaceAll(" ", "_")+".schematic");
            if(f.exists()){
                this.loc = new Locations().getLocation(LocationType.SCHEMATICS);
                final EditSession es = new EditSession(new BukkitWorld(loc.getWorld()), 900000);
                this.cc = CuboidClipboard.loadSchematic(f);
                v = new Vector(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
                cc.place(es, v, false);
            }
        }
       
        public void clearArea(){
            if(cc != null){
                //Idk :P
            }
        }
     
  2. Offline

    NathanWolf

    Have you tried calling undo? :)

    You'll need to retain the reference to your EditSession, but I think it should be easy as that.
     
    Unica likes this.
  3. Offline

    Unica

    @NathanWolf

    Wow. That was it :p

    I was playing with CuboidClipboard, but you were right, thanks m8.

    Solved.
     
    NathanWolf likes this.
Thread Status:
Not open for further replies.

Share This Page