diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/feature/ignore/IgnoreRepositoryOrmLite.java b/eternalcore-core/src/main/java/com/eternalcode/core/feature/ignore/IgnoreRepositoryOrmLite.java index ebbb8fbcb..cf3f07685 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/feature/ignore/IgnoreRepositoryOrmLite.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/feature/ignore/IgnoreRepositoryOrmLite.java @@ -57,19 +57,22 @@ public CompletableFuture isIgnored(UUID by, UUID target) { @Override public CompletableFuture ignore(UUID by, UUID target) { - return CompletableFuture.runAsync(() -> { - try { - Set uuids = this.ignores.get(by); - - if (!uuids.contains(target)) { - this.save(IgnoreTable.class, new IgnoreTable(by, target)) - .thenRun(() -> this.ignores.refresh(by)); + return CompletableFuture.supplyAsync(() -> { + try { + return this.ignores.get(by); } - } - catch (ExecutionException exception) { - throw new RuntimeException(exception); - } - }); + catch (ExecutionException exception) { + throw new RuntimeException(exception); + } + }) + .thenCompose(uuids -> { + if (uuids.contains(target)) { + return CompletableFuture.completedFuture(null); + } + + return this.save(IgnoreTable.class, new IgnoreTable(by, target)) + .thenRun(() -> this.ignores.refresh(by)); + }); } @Override