Skip to content

Commit 7dc5f5f

Browse files
committed
arrange the logic of click-requirement in WrappedPredicateButton
1 parent 927c6b6 commit 7dc5f5f

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

src/main/java/me/hsgamer/bettergui/button/WrappedPredicateButton.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.Optional;
2525
import java.util.Set;
2626
import java.util.UUID;
27-
import java.util.concurrent.CompletableFuture;
2827
import java.util.concurrent.ConcurrentSkipListSet;
2928

3029
public class WrappedPredicateButton extends BaseWrappedButton<WrappedPredicateButton.PredicateClickButton> {
@@ -129,18 +128,20 @@ public boolean apply(@NotNull UUID uuid, @NotNull ActionItem actionItem) {
129128
return;
130129
}
131130

132-
clickCheckList.add(clickUUID);
133-
CompletableFuture.supplyAsync(() -> clickRequirement.getResult(clickUUID)).thenAccept((result) -> {
134-
clickCheckList.remove(clickUUID);
135-
BatchRunnable batchRunnable = new BatchRunnable();
136-
batchRunnable.getTaskPool(ProcessApplierConstants.REQUIREMENT_ACTION_STAGE).addLast(process -> {
137-
result.applier.accept(clickUUID, process);
138-
process.next();
139-
});
131+
BatchRunnable batchRunnable = new BatchRunnable();
132+
batchRunnable.getTaskPool(ProcessApplierConstants.REQUIREMENT_ACTION_STAGE).addLast(process -> {
133+
Requirement.Result result = clickRequirement.getResult(clickUUID);
134+
result.applier.accept(uuid, process);
140135
if (result.isSuccess) {
141-
batchRunnable.getTaskPool(ProcessApplierConstants.ACTION_STAGE).addLast(() -> objectConsumer.accept(event));
136+
process.getTaskPool(ProcessApplierConstants.ACTION_STAGE).addLast(() -> objectConsumer.accept(event));
142137
}
143-
SchedulerUtil.async().run(batchRunnable);
138+
process.next();
139+
});
140+
141+
SchedulerUtil.async().run(() -> {
142+
clickCheckList.add(clickUUID);
143+
batchRunnable.run();
144+
clickCheckList.remove(clickUUID);
144145
});
145146
});
146147
}

0 commit comments

Comments
 (0)