From c62d9b30c3ab9472d8a8ffc7d2f20544916371ff Mon Sep 17 00:00:00 2001 From: SamB440 Date: Wed, 19 Apr 2023 22:04:26 +0100 Subject: [PATCH] Fix users not saving --- .../rpgregions/managers/data/SQLCommonStorage.java | 6 +++--- .../rpgregions/managers/data/yml/YamlStorage.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rpgregions/src/main/java/net/islandearth/rpgregions/managers/data/SQLCommonStorage.java b/rpgregions/src/main/java/net/islandearth/rpgregions/managers/data/SQLCommonStorage.java index 01154dc..7bcdfcb 100644 --- a/rpgregions/src/main/java/net/islandearth/rpgregions/managers/data/SQLCommonStorage.java +++ b/rpgregions/src/main/java/net/islandearth/rpgregions/managers/data/SQLCommonStorage.java @@ -36,14 +36,14 @@ public abstract class SQLCommonStorage implements IStorageManager { public SQLCommonStorage(RPGRegions plugin) { this.plugin = plugin; this.cachedAccounts = Caffeine.newBuilder() - .maximumSize(1_000) + .maximumSize(1_000) // Realistically no server can support higher than this, even Folia .scheduler(Scheduler.systemScheduler()) .expireAfterAccess(plugin.getConfig().getInt("settings.storage.cache-expiry-time", 180), TimeUnit.SECONDS) .removalListener((k, v, c) -> { plugin.debug("Removed user from cache, cause: " + c.name()); // If the user was manually removed, don't save, let other code handle how it wants - if (c == RemovalCause.EXPLICIT) return; - removeCachedAccount(((RPGRegionsAccount) v).getUuid()); + if (v == null || c == RemovalCause.EXPLICIT) return; + saveAccount(((RPGRegionsAccount) v)); }) .buildAsync((key, executor) -> getAccount(key)); } diff --git a/rpgregions/src/main/java/net/islandearth/rpgregions/managers/data/yml/YamlStorage.java b/rpgregions/src/main/java/net/islandearth/rpgregions/managers/data/yml/YamlStorage.java index 12d86ee..ca8e61f 100644 --- a/rpgregions/src/main/java/net/islandearth/rpgregions/managers/data/yml/YamlStorage.java +++ b/rpgregions/src/main/java/net/islandearth/rpgregions/managers/data/yml/YamlStorage.java @@ -35,14 +35,14 @@ public class YamlStorage implements IStorageManager { File dataFile = new File(plugin.getDataFolder() + "/accounts/"); dataFile.mkdirs(); this.cachedAccounts = Caffeine.newBuilder() - .maximumSize(1_000) + .maximumSize(1_000) // Realistically no server can support higher than this, even Folia .scheduler(Scheduler.systemScheduler()) .expireAfterAccess(plugin.getConfig().getInt("settings.storage.cache-expiry-time", 180), TimeUnit.SECONDS) .removalListener((k, v, c) -> { plugin.debug("Removed user from cache, cause: " + c.name()); // If the user was manually removed, don't save, let other code handle how it wants - if (c == RemovalCause.EXPLICIT) return; - removeCachedAccount(((RPGRegionsAccount) v).getUuid()); + if (v == null || c == RemovalCause.EXPLICIT) return; + saveAccount(((RPGRegionsAccount) v)); }) .buildAsync((key, executor) -> getAccount(key)); }