/** * Performs a redo * * @param newBlockBag a new block bag * @param player the player * @return whether anything was redone */ public EditSession redo(@Nullable BlockBag newBlockBag, Player player) { checkNotNull(player); if (historyPointer < history.size()) { EditSession editSession = history.get(historyPointer); try (EditSession newEditSession = WorldEdit.getInstance().getEditSessionFactory() .getEditSession(editSession.getWorld(), -1, newBlockBag, player)) { newEditSession.enableStandardMode(); newEditSession.setReorderMode(reorderMode); newEditSession.setFastMode(fastMode); editSession.redo(newEditSession); } ++historyPointer; return editSession; } return null; }
/** * Performs an undo. * * @param newBlockBag a new block bag * @param player the player * @return whether anything was undone */ public EditSession undo(@Nullable BlockBag newBlockBag, Player player) { checkNotNull(player); --historyPointer; if (historyPointer >= 0) { EditSession editSession = history.get(historyPointer); try (EditSession newEditSession = WorldEdit.getInstance().getEditSessionFactory() .getEditSession(editSession.getWorld(), -1, newBlockBag, player)) { newEditSession.enableStandardMode(); newEditSession.setReorderMode(reorderMode); newEditSession.setFastMode(fastMode); editSession.undo(newEditSession); } return editSession; } else { historyPointer = 0; return null; } }
/** * Construct a new edit session. * * @param player the player * @return an edit session */ public EditSession createEditSession(Player player) { checkNotNull(player); BlockBag blockBag = getBlockBag(player); // Create an edit session EditSession editSession = WorldEdit.getInstance().getEditSessionFactory() .getEditSession(player.isPlayer() ? player.getWorld() : null, getBlockChangeLimit(), blockBag, player); editSession.setFastMode(fastMode); editSession.setReorderMode(reorderMode); Request.request().setEditSession(editSession); editSession.setMask(mask); return editSession; }