9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2025-12-28 11:19:24 +00:00

Fix users not saving

This commit is contained in:
SamB440
2023-04-19 22:04:26 +01:00
parent 946156ec7c
commit c62d9b30c3
2 changed files with 6 additions and 6 deletions

View File

@@ -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));
}

View File

@@ -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));
}