try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1)) { // use the edit session here ... } // it is automatically closed/flushed when the code exits the block