Permalink
Browse files

Flush buffers in tools or disable them.

  • Loading branch information...
kenzierocks committed Oct 21, 2018
1 parent dd2fcba commit 274dd4494643adf12f3c9d58ea61212456e1cada
@@ -285,7 +285,7 @@ public void remember(Player player, EditSession editSession) {
LocalSession session = WorldEdit.getInstance().getSessionManager().get(wePlayer);
session.remember(editSession);
editSession.flushQueue();
editSession.flushBuffers();
WorldEdit.getInstance().flushBlockBag(wePlayer, editSession);
}
@@ -302,9 +302,9 @@ public void enableQueue() {
*/
public void disableQueue() {
if (isQueueEnabled()) {
flushQueue();
flushBuffers();
}
reorderExtent.setEnabled(true);
reorderExtent.setEnabled(false);
}
/**
@@ -405,7 +405,7 @@ public void setBatchingChunks(boolean batchingChunks) {
return;
}
if (!batchingChunks) {
flushQueue();
flushBuffers();
}
chunkBatchingExtent.setEnabled(batchingChunks);
}
@@ -569,7 +569,7 @@ public void undo(EditSession editSession) {
UndoContext context = new UndoContext();
context.setExtent(editSession.bypassHistory);
Operations.completeBlindly(ChangeSetExecutor.createUndo(changeSet, context));
editSession.flushQueue();
editSession.flushBuffers();
}
/**
@@ -581,7 +581,7 @@ public void redo(EditSession editSession) {
UndoContext context = new UndoContext();
context.setExtent(editSession.bypassHistory);
Operations.completeBlindly(ChangeSetExecutor.createRedo(changeSet, context));
editSession.flushQueue();
editSession.flushBuffers();
}
/**
@@ -614,9 +614,19 @@ public Vector getMaximumPoint() {
}
/**
* Finish off the queue.
* Disable all buffering extents.
*
* Calling this means there is no need to call {@link #flushBuffers()}.
*/
public void disableBuffering() {
disableQueue();
setBatchingChunks(false);
}
/**
* Finish any pending / buffered block changes.
*/
public void flushQueue() {
public void flushBuffers() {
Operations.completeBlindly(commit());
}
@@ -628,7 +628,7 @@ public void runScript(Player player, File f, String[] args) throws WorldEditExce
logger.log(Level.WARNING, "Failed to execute script", e);
} finally {
for (EditSession editSession : scriptContext.getEditSessions()) {
editSession.flushQueue();
editSession.flushBuffers();
session.remember(editSession);
}
}
@@ -460,7 +460,7 @@ public void butcher(Actor actor, CommandContext args) throws WorldEditException
if (editSession != null) {
session.remember(editSession);
editSession.flushQueue();
editSession.flushBuffers();
}
}
@@ -520,7 +520,7 @@ public void remove(Actor actor, CommandContext args) throws WorldEditException,
if (editSession != null) {
session.remember(editSession);
editSession.flushQueue();
editSession.flushBuffers();
}
}
@@ -83,7 +83,7 @@ public boolean actPrimary(Platform server, LocalConfiguration config, Player pla
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {
editSession.flushQueue();
editSession.flushBuffers();
session.remember(editSession);
}
@@ -53,16 +53,17 @@ public boolean actPrimary(Platform server, LocalConfiguration config, Player pla
BlockBag bag = session.getBlockBag(player);
EditSession editSession = session.createEditSession(player);
editSession.disableBuffering();
try {
Vector position = clicked.toVector();
editSession.setBlock(position, pattern.apply(position));
} catch (MaxChangedBlocksException ignored) {
} finally {
session.remember(editSession);
if (bag != null) {
bag.flushChanges();
}
session.remember(editSession);
}
return true;
@@ -193,10 +193,11 @@ public boolean actPrimary(Platform server, LocalConfiguration config, Player pla
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {
session.remember(editSession);
editSession.flushBuffers();
if (bag != null) {
bag.flushChanges();
}
session.remember(editSession);
}
return true;
@@ -75,7 +75,7 @@ public boolean actPrimary(Platform server, LocalConfiguration config, Player pla
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {
editSession.flushQueue();
editSession.flushBuffers();
session.remember(editSession);
}
@@ -57,7 +57,7 @@ public boolean actPrimary(Platform server, LocalConfiguration config, Player pla
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {
editSession.flushQueue();
editSession.flushBuffers();
}
world.playEffect(clicked.toVector(), 2001, blockType.getLegacyId());
@@ -316,7 +316,7 @@ public void handleCommand(CommandEvent event) {
if (editSession != null) {
session.remember(editSession);
editSession.flushQueue();
editSession.flushBuffers();
if (config.profile) {
long time = System.currentTimeMillis() - start;

0 comments on commit 274dd44

Please sign in to comment.