Fix warp and home list caches not being invalidated when homes updated

This commit is contained in:
William committed 2023-03-25 17:44:33 +00:00
1 parent e88e424b6e
commit 161d860392
3 files changed
+23

No files matched your search

@@ -18,4 +18,8 @@ public abstract class ListCommand extends Command {
this.cachedLists = new HashMap<>();
}
public void invalidateCaches() {
cachedLists.clear();
}
}
@@ -1,6 +1,7 @@
package net.william278.huskhomes.manager;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.command.ListCommand;
import net.william278.huskhomes.hook.EconomyHook;
import net.william278.huskhomes.network.Message;
import net.william278.huskhomes.network.Payload;
@@ -59,6 +60,10 @@ public class HomesManager {
plugin.getMapHook().ifPresent(hook -> hook.updateHome(home));
}
plugin.getCommands().stream()
.filter(command -> command instanceof ListCommand)
.map(command -> (ListCommand) command)
.forEach(ListCommand::invalidateCaches);
if (propagate) {
propagateCacheUpdate(home.getUuid());
}
@@ -74,6 +79,10 @@ public class HomesManager {
return false;
});
plugin.getCommands().stream()
.filter(command -> command instanceof ListCommand)
.map(command -> (ListCommand) command)
.forEach(ListCommand::invalidateCaches);
if (propagate) {
this.propagateCacheUpdate(homeId);
}
@@ -1,6 +1,7 @@
package net.william278.huskhomes.manager;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.command.ListCommand;
import net.william278.huskhomes.hook.MapHook;
import net.william278.huskhomes.network.Message;
import net.william278.huskhomes.network.Payload;
@@ -29,6 +30,11 @@ public class WarpsManager {
warps.remove(warp);
warps.add(warp);
plugin.getMapHook().ifPresent(hook -> hook.updateWarp(warp));
plugin.getCommands().stream()
.filter(command -> command instanceof ListCommand)
.map(command -> (ListCommand) command)
.forEach(ListCommand::invalidateCaches);
if (propagate) {
this.propagateCacheUpdate(warp.getUuid());
}
@@ -43,6 +49,10 @@ public class WarpsManager {
return false;
});
plugin.getCommands().stream()
.filter(command -> command instanceof ListCommand)
.map(command -> (ListCommand) command)
.forEach(ListCommand::invalidateCaches);
if (propagate) {
this.propagateCacheUpdate(warpId);
}