delhome/delwarp all rewrite; add events for bulk-deletes, close #265

This commit is contained in:
William committed 2022-11-22 21:58:23 +00:00
1 parent 2402f12536
commit 834fdbfc0e
17 files changed
+379 -51

No files matched your search

@@ -152,6 +152,20 @@ public class SavedPositionManager {
});
}
public CompletableFuture<Integer> deleteAllHomes(@NotNull User user) {
return CompletableFuture.supplyAsync(() -> eventDispatcher.dispatchDeleteAllHomesEvent(user).join().isCancelled())
.thenApply(cancelled -> database.deleteAllHomes(user)
.thenApply(result -> {
cache.homes.remove(user.uuid);
cache.privateHomeLists.remove(user.username);
cache.publicHomeLists.clear();
if (mapHook != null) {
mapHook.clearHomes(user);
}
return result;
}).join());
}
/**
* Tries to update an existing home with new metadata
*
@@ -320,6 +334,18 @@ public class SavedPositionManager {
});
}
public CompletableFuture<Integer> deleteAllWarps() {
return CompletableFuture.supplyAsync(() -> eventDispatcher.dispatchDeleteAllWarpsEvent().join().isCancelled())
.thenApply(cancelled -> database.deleteAllWarps()
.thenApply(result -> {
cache.warps.clear();
if (mapHook != null) {
mapHook.clearWarps();
}
return result;
}).join());
}
/**
* Tries to update an existing warp with new metadata
*