Examples of EditSession


Examples of com.mozilla.bespin.EditSession

            }

            boolean openSession = true;

            // check for an existing edit session from the current user
            EditSession session = tracker.getSession(requestedFile, getUser());
            if (session != null) {
                if (session.getEditMode() == editMode) openSession = false;
                if ((session.getEditMode() == EditMode.Read) && (editMode == EditMode.ReadWrite)) {
                    tracker.closeSession(requestedFile, getUser());
                }
            }

            if (openSession) {
View Full Code Here

Examples of com.mozilla.bespin.EditSession

    public void put() throws IOException {
        java.io.File file = getFilesystem().getFileHandle(getUser(), getPath());

        SessionTracker tracker = getSessionTracker();
        synchronized (tracker) {
            EditSession session = tracker.getSession(file, getUser());

            // check if the lastEdit parameter was sent
            String lastEdit = getCtx().getReq().getParameter("lastEdit");
            if (StringUtils.isNumeric(lastEdit) && StringUtils.isNotBlank(lastEdit)) {
                // verify that the user has a session open
                if ((session == null) || (session.getEditMode() != EditMode.ReadWrite)) {
                    getCtx().getResp().sendError(400, "File not open for read/write access");
                    return;
                }

                session.setLastEditBeforeSave(Integer.parseInt(lastEdit));
            } else {
                // TODO: We may not be in a collaborate mode, but still want to save back
//                if ((session != null) && (session.getEditMode() == EditMode.ReadWrite)) {
//                    getCtx().getResp().sendError(400, "File open for read/write access; could not save without lastEdit parameter");
//                    return;
View Full Code Here

Examples of com.mozilla.bespin.EditSession

    private void addEdits(String path, JSONObject... edits) throws IOException {
        // first get the file handle
        java.io.File file = getFilesystem().getFileHandle(getUser(), path);

        // get the edit session
        EditSession editSession = getSessionTracker().getSession(file, getUser());
        if (editSession == null) {
            getCtx().getResp().sendError(400, "No edit session open for file");
            return;
        }

        editSession.addEdits(edits);
    }
View Full Code Here

Examples of com.mozilla.bespin.EditSession

    private List<JSONObject> getEdits(String path) throws IOException {
        // first get the file handle
        java.io.File file = getFilesystem().getFileHandle(getUser(), path);

        // get the edit session
        EditSession editSession = getSessionTracker().getSession(file, getUser());

        if (editSession != null) {
            return editSession.getEdits();
        } else {
            return new ArrayList<JSONObject>();
        }
    }
View Full Code Here

Examples of com.sk89q.worldedit.EditSession

        if (blockType == BlockID.BEDROCK
                && !player.canDestroyBedrock()) {
            return true;
        }

        EditSession editSession = session.createEditSession(player);
        editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);

        try {
            editSession.setBlock(clicked.toVector(), new BaseBlock(BlockID.AIR));
        } catch (MaxChangedBlocksException e) {
            player.printError("Max blocks change limit reached.");
        } finally {
            editSession.flushQueue();
        }

        world.playEffect(clicked.toVector(), 2001, blockType);

        return true;
View Full Code Here

Examples of com.sk89q.worldedit.EditSession

    @Override
    public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {

        World world = (World) clicked.getExtent();
        EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, 0, player);
        BaseBlock block = (editSession).rawGetBlock(clicked.toVector());
        BlockType type = BlockType.fromID(block.getType());

        player.print("\u00A79@" + clicked.toVector() + ": " + "\u00A7e"
                + "#" + block.getType() + "\u00A77" + " ("
View Full Code Here

Examples of com.sk89q.worldedit.EditSession

            } else {
                actor.printError("An unknown error has occurred! Please see console.");
                log.log(Level.SEVERE, "An unknown error occurred", e);
            }
        } finally {
            EditSession editSession = locals.get(EditSession.class);

            if (editSession != null) {
                session.remember(editSession);
                editSession.flushQueue();

                if (config.profile) {
                    long time = System.currentTimeMillis() - start;
                    int changed = editSession.getBlockChangeCount();
                    if (time > 0) {
                        double throughput = changed / (time / 1000.0);
                        actor.printDebug((time / 1000.0) + "s elapsed (history: "
                                + changed + " changed; "
                                + Math.round(throughput) + " blocks/sec).");
View Full Code Here

Examples of com.sk89q.worldedit.EditSession

    @BindingMatch(type = EditSession.class,
                  behavior = BindingBehavior.PROVIDES)
    public EditSession getEditSession(ArgumentStack context) throws ParameterException {
        Player sender = getPlayer(context);
        LocalSession session = worldEdit.getSessionManager().get(sender);
        EditSession editSession = session.createEditSession(sender);
        editSession.enableQueue();
        context.getContext().getLocals().put(EditSession.class, editSession);
        session.tellVersion(sender);
        return editSession;
    }
View Full Code Here

Examples of com.sk89q.worldedit.EditSession

    public EditSession createEditSession(Player player) {
        LocalPlayer wePlayer = wrapPlayer(player);
        LocalSession session = WorldEdit.getInstance().getSession(wePlayer);
        BlockBag blockBag = session.getBlockBag(wePlayer);

        EditSession editSession = WorldEdit.getInstance().getEditSessionFactory()
                .getEditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag, wePlayer);
        editSession.enableQueue();

        return editSession;
    }
View Full Code Here

Examples of com.sk89q.worldedit.EditSession

    @Deprecated
    public void perform(Player player, WorldEditOperation op) throws Throwable {
        LocalPlayer wePlayer = wrapPlayer(player);
        LocalSession session = WorldEdit.getInstance().getSession(wePlayer);

        EditSession editSession = createEditSession(player);
        try {
            op.run(session, wePlayer, editSession);
        } finally {
            remember(player, editSession);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.