Permalink
Browse files

Fixed a few bugs but reverted a few of the queueing changes. Still mo…

…re work to go.
  • Loading branch information...
me4502 committed Aug 29, 2018
1 parent 8cfab73 commit 56aa68a44ac805486df0b6210198b860e9fe8cbb
@@ -64,22 +64,13 @@ private ChangeSetExecutor(ChangeSet changeSet, Type type, UndoContext context) {
@Override
public Operation resume(RunContext run) throws WorldEditException {
long start = System.currentTimeMillis();
int count = 0;
while (iterator.hasNext()) {
Change change = iterator.next();
if (type == Type.UNDO) {
change.undo(context);
} else {
change.redo(context);
}
count ++;
if (count % 100 == 0 && System.currentTimeMillis() - start > 50) {
break;
}
}
return iterator.hasNext() ? this : null;
@@ -31,6 +31,7 @@
private Actor actor;
private EditSession editSession;
private boolean hasFlushed = false;
public FlushOperation(Actor actor, EditSession editSession) {
this.actor = actor;
@@ -39,9 +40,14 @@ public FlushOperation(Actor actor, EditSession editSession) {
@Override
public Operation resume(RunContext run) throws WorldEditException {
LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor);
session.remember(editSession);
editSession.flushQueue(actor);
if (!hasFlushed) {
hasFlushed = true;
LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor);
session.remember(editSession);
return new DelegateOperation(this, editSession.commit());
}
WorldEdit.getInstance().flushBlockBag(actor, editSession);
@@ -119,7 +119,7 @@ public static void completeQueued(Operation op) {
actor.print("Added operation to queue.");
Operation operation = op;
if (editSession != null) {
if (editSession != null && !(op instanceof FlushOperation)) {
operation = new OperationQueue(op, new FlushOperation(actor, editSession));
}
@@ -165,15 +165,9 @@ public int getAffected() {
public Operation resume(RunContext run) throws WorldEditException {
Vector position;
long startTime = System.currentTimeMillis();
while ((position = queue.poll()) != null) {
if (function.apply(position)) {
affected++;
if (affected % 100 == 0 && System.currentTimeMillis() - startTime > 50) { // 20TPS 1 tick time.
return this;
}
}
for (Vector dir : directions) {
@@ -54,15 +54,10 @@ public int getAffected() {
@Override
public Operation resume(RunContext run) throws WorldEditException {
long start = System.currentTimeMillis();
while (run.shouldContinue() && iterator.hasNext()) {
if (function.apply(iterator.next())) {
++affected;
}
if (affected % 100 == 0 && System.currentTimeMillis() - start > 50) { // Time of a tick.
break;
}
}
return iterator.hasNext() ? this : null;

0 comments on commit 56aa68a

Please sign in to comment.