From 8f2cf09714c3797e78e57928aaa023c67645024d Mon Sep 17 00:00:00 2001 From: Emibergo02 <36164338+Emibergo02@users.noreply.github.com> Date: Mon, 14 Oct 2024 22:34:20 +0200 Subject: [PATCH] 4.3.19 Remove unbinded uuids More verbose on cloud sync --- pom.xml | 2 +- .../unnm3d/rediseconomy/command/PurgeUserCommand.java | 4 +--- .../unnm3d/rediseconomy/currency/CurrenciesManager.java | 9 +++++++++ .../java/dev/unnm3d/rediseconomy/currency/Currency.java | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 9e60d24..4d450b3 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ dev.unnm3d RedisEconomy - 4.3.18 + 4.3.19 jar RedisEconomy diff --git a/src/main/java/dev/unnm3d/rediseconomy/command/PurgeUserCommand.java b/src/main/java/dev/unnm3d/rediseconomy/command/PurgeUserCommand.java index 71304f7..7f984c6 100644 --- a/src/main/java/dev/unnm3d/rediseconomy/command/PurgeUserCommand.java +++ b/src/main/java/dev/unnm3d/rediseconomy/command/PurgeUserCommand.java @@ -44,13 +44,11 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command nameUUIDs = currenciesManager.removeNamePattern(target, !onlyNameUUID); successMsg = plugin.langs().purgeUserSuccess.replace("%player%", target); } - if (nameUUIDs.size() == 0) { + if (nameUUIDs.isEmpty()) { plugin.langs().send(sender, plugin.langs().playerNotFound); return true; } plugin.langs().send(sender, successMsg); - - return true; } diff --git a/src/main/java/dev/unnm3d/rediseconomy/currency/CurrenciesManager.java b/src/main/java/dev/unnm3d/rediseconomy/currency/CurrenciesManager.java index 1354d8a..80dbda8 100644 --- a/src/main/java/dev/unnm3d/rediseconomy/currency/CurrenciesManager.java +++ b/src/main/java/dev/unnm3d/rediseconomy/currency/CurrenciesManager.java @@ -193,6 +193,15 @@ public HashMap removeNamePattern(String namePattern, boolean reset */ public HashMap resetBalanceNamePattern(String namePattern, Currency currencyReset) { HashMap removed = new HashMap<>(); + currencyReset.getOrderedAccounts(Integer.MAX_VALUE).thenAccept(accounts -> { + for (ScoredValue account : accounts) { + UUID uuid = UUID.fromString(account.getValue()); + if (!nameUniqueIds.containsValue(uuid)) { + currencyReset.setPlayerBalance(uuid, null, 0.0); + } + } + }); + for (Map.Entry entry : nameUniqueIds.entrySet()) { if (entry.getKey().matches(namePattern)) { removed.put(entry.getKey(), entry.getValue()); diff --git a/src/main/java/dev/unnm3d/rediseconomy/currency/Currency.java b/src/main/java/dev/unnm3d/rediseconomy/currency/Currency.java index f64b2ea..579e8d3 100644 --- a/src/main/java/dev/unnm3d/rediseconomy/currency/Currency.java +++ b/src/main/java/dev/unnm3d/rediseconomy/currency/Currency.java @@ -597,7 +597,7 @@ private void handleException(@NotNull UUID uuid, @Nullable String playerName, do if (plugin.settings().debugUpdateCache) { plugin.getLogger().warning("Player accounts are desynchronized. try: " + tries); if (e != null) - plugin.getLogger().warning(e.getMessage()); + e.printStackTrace(); } updateAccountCloudCache(uuid, playerName, balance, tries + 1); return;