From d2adf18ff29275a1f6ea45c6101664f986cf779f Mon Sep 17 00:00:00 2001 From: creatorfromhell Date: Wed, 23 Aug 2023 20:51:55 -0400 Subject: [PATCH] Test modifications, and patches. Signed-off-by: creatorfromhell --- .../loader/DefaultCurrencyLoader.java | 9 +++++-- .../handlers/player/PlayerJoinHandler.java | 24 ++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Core/src/net/tnemc/core/currency/loader/DefaultCurrencyLoader.java b/Core/src/net/tnemc/core/currency/loader/DefaultCurrencyLoader.java index e06d0dda..3094a002 100644 --- a/Core/src/net/tnemc/core/currency/loader/DefaultCurrencyLoader.java +++ b/Core/src/net/tnemc/core/currency/loader/DefaultCurrencyLoader.java @@ -38,6 +38,7 @@ import java.io.File; import java.io.IOException; import java.math.BigDecimal; +import java.nio.charset.StandardCharsets; import java.util.Optional; import java.util.Set; import java.util.UUID; @@ -158,9 +159,11 @@ public boolean loadCurrency(final File directory, File curDirectory) { uuidAsId = cur.getBoolean("Info.UUIDAsId"); } + + final UUID check = UUID.nameUUIDFromBytes(identifier.getBytes(StandardCharsets.UTF_8)); if(cur.contains("Info.UUID")) { - final UUID check = UUID.fromString(identifier); + System.out.println("UUIDASID: " + uuidAsId); final UUID id = (uuidAsId && !cur.getString("Info.UUID").equalsIgnoreCase(check.toString()))? check : UUID.fromString(cur.getString("Info.UUID")); @@ -170,7 +173,9 @@ public boolean loadCurrency(final File directory, File curDirectory) { currency.setUid(UUID.fromString(cur.getString("Info.UUID"))); } } else { - currency.setUid(UUID.fromString(identifier)); + if(uuidAsId) { + currency.setUid(check); + } } currency.setIdentifier(identifier); diff --git a/Core/src/net/tnemc/core/handlers/player/PlayerJoinHandler.java b/Core/src/net/tnemc/core/handlers/player/PlayerJoinHandler.java index 10c08a09..fb2cccc7 100644 --- a/Core/src/net/tnemc/core/handlers/player/PlayerJoinHandler.java +++ b/Core/src/net/tnemc/core/handlers/player/PlayerJoinHandler.java @@ -78,8 +78,23 @@ public HandlerResponse handle(PlayerProvider provider) { if(acc.isPresent()) { if(firstJoin) { + final String region = TNECore.eco().region().getMode().region(provider); for(Currency currency : TNECore.eco().currency().currencies()) { - acc.get().setHoldings(new HoldingsEntry(TNECore.eco().region().getMode().region(provider), + + if(currency.type().supportsItems() && MainConfig.yaml().getBoolean("Core.Server.ImportItems", true)) { + + TNECore.eco().account().getImporting().add(id); + + for(HoldingsEntry entry : acc.get().getHoldings(region, currency.getUid())) { + + acc.get().setHoldings(entry, entry.getHandler()); + } + + TNECore.eco().account().getImporting().remove(id); + continue; + } + + acc.get().setHoldings(new HoldingsEntry(region, currency.getUid(), currency.getStartingHoldings(), EconomyManager.NORMAL @@ -93,11 +108,14 @@ public HandlerResponse handle(PlayerProvider provider) { if(currency.type().supportsItems()) { + /*System.out.println("Region: " + acc.get().getWallet().getHoldings(region).isEmpty()); + System.out.println("Currency: " + !acc.get().getWallet().getHoldings(region).get().getHoldings().containsKey(currency.getUid())); if(MainConfig.yaml().getBoolean("Core.Server.ImportItems", true) && acc.get().getWallet().getHoldings(region).isEmpty() || MainConfig.yaml().getBoolean("Core.Server.ImportItems", true) - && acc.get().getWallet().getHoldings(region).get().getHoldingsEntry(currency.getUid()).isEmpty()) { + && !acc.get().getWallet().getHoldings(region).get().getHoldings().containsKey(currency.getUid())) { + System.out.println("Importing Item Currency."); TNECore.eco().account().getImporting().add(id); for(HoldingsEntry entry : acc.get().getHoldings(region, currency.getUid())) { @@ -107,7 +125,7 @@ public HandlerResponse handle(PlayerProvider provider) { TNECore.eco().account().getImporting().remove(id); continue; - } + }*/ for(HoldingsEntry entry : acc.get().getHoldings(region, currency.getUid())) {