From 63bfa2119e0764439c411f8687a7e9d9629456cb Mon Sep 17 00:00:00 2001 From: William Date: Tue, 10 Oct 2023 19:47:21 +0100 Subject: [PATCH] Invalidate home/warp list caches when deleting all homes/warps --- .../net/william278/huskhomes/manager/HomesManager.java | 8 ++++++++ .../net/william278/huskhomes/manager/WarpsManager.java | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/common/src/main/java/net/william278/huskhomes/manager/HomesManager.java b/common/src/main/java/net/william278/huskhomes/manager/HomesManager.java index 58fa066c8..93dee7fb1 100644 --- a/common/src/main/java/net/william278/huskhomes/manager/HomesManager.java +++ b/common/src/main/java/net/william278/huskhomes/manager/HomesManager.java @@ -255,6 +255,10 @@ public int deleteAllHomes(@NotNull User owner) { }); publicHomes.removeIf(h -> h.getOwner().getUuid().equals(owner.getUuid())); plugin.getMapHook().ifPresent(hook -> hook.clearHomes(owner)); + plugin.getCommands().stream() + .filter(command -> command instanceof ListCommand) + .map(command -> (ListCommand) command) + .forEach(ListCommand::invalidateCaches); plugin.getManager().propagateCacheUpdate(); return deleted; } @@ -268,6 +272,10 @@ public int deleteAllHomes(@NotNull String worldName, @NotNull String serverName) if (plugin.getSettings().doCrossServer() && serverName.equals(plugin.getServerName())) { plugin.getMapHook().ifPresent(hook -> hook.clearHomes(worldName)); } + plugin.getCommands().stream() + .filter(command -> command instanceof ListCommand) + .map(command -> (ListCommand) command) + .forEach(ListCommand::invalidateCaches); plugin.getManager().propagateCacheUpdate(); return deleted; } diff --git a/common/src/main/java/net/william278/huskhomes/manager/WarpsManager.java b/common/src/main/java/net/william278/huskhomes/manager/WarpsManager.java index e63182896..36505de51 100644 --- a/common/src/main/java/net/william278/huskhomes/manager/WarpsManager.java +++ b/common/src/main/java/net/william278/huskhomes/manager/WarpsManager.java @@ -158,6 +158,10 @@ public int deleteAllWarps() { final int deleted = plugin.getDatabase().deleteAllWarps(); warps.clear(); plugin.getMapHook().ifPresent(MapHook::clearWarps); + plugin.getCommands().stream() + .filter(command -> command instanceof ListCommand) + .map(command -> (ListCommand) command) + .forEach(ListCommand::invalidateCaches); plugin.getManager().propagateCacheUpdate(); return deleted; } @@ -168,6 +172,10 @@ public int deleteAllWarps(@NotNull String worldName, @NotNull String serverName) if (plugin.getSettings().doCrossServer() && plugin.getServerName().equals(serverName)) { plugin.getMapHook().ifPresent(hook -> hook.clearWarps(worldName)); } + plugin.getCommands().stream() + .filter(command -> command instanceof ListCommand) + .map(command -> (ListCommand) command) + .forEach(ListCommand::invalidateCaches); plugin.getManager().propagateCacheUpdate(); return deleted; }