handle cancellation properly in DefaultProgressSubscriber

This commit is contained in:
dordsor21 2021-01-04 18:23:45 +00:00
parent 4c0bc79e49
commit 9598416932
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -27,7 +27,6 @@ package com.plotsquared.core.queue.subscriber;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.AtomicDouble; import com.google.common.util.concurrent.AtomicDouble;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject; import com.google.inject.assistedinject.AssistedInject;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
@ -105,6 +104,7 @@ public class DefaultProgressSubscriber implements ProgressSubscriber {
} }
if (cancelled.get()) { if (cancelled.get()) {
task.cancel(); task.cancel();
return;
} }
actor.sendMessage(caption, Template.of("progress", String.format("%.2f", this.progress.doubleValue() * 100))); actor.sendMessage(caption, Template.of("progress", String.format("%.2f", this.progress.doubleValue() * 100)));
}, interval), wait); }, interval), wait);