diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java index a63199bf7..6626d4386 100644 --- a/src/main/java/org/maxgamer/quickshop/QuickShop.java +++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java @@ -402,21 +402,23 @@ public class QuickShop extends JavaPlugin { //getLogger().info("Checking the tax account infos..."); try { String taxAccount = getConfig().getString("tax-account", "tax"); - OfflinePlayer tax = Bukkit.getOfflinePlayer(Objects.requireNonNull(taxAccount)); //FIXME: Should we use player UUID? - if (!tax.hasPlayedBefore()) { - Economy_Vault vault = (Economy_Vault) core; - if (vault.isValid()) { - if (!Objects.requireNonNull(vault.getVault()).hasAccount(tax)) { - try { - Util.debugLog("Tax account not exists! Creating..."); - vault.getVault().createPlayerAccount(tax); - } catch (Exception ignored) { + if (!(taxAccount == null || taxAccount.isEmpty())) { + OfflinePlayer tax = Bukkit.getOfflinePlayer(Objects.requireNonNull(taxAccount)); //FIXME: Should we use player UUID? + if (!tax.hasPlayedBefore()) { + Economy_Vault vault = (Economy_Vault) core; + if (vault.isValid()) { + if (!Objects.requireNonNull(vault.getVault()).hasAccount(tax)) { + try { + Util.debugLog("Tax account not exists! Creating..."); + vault.getVault().createPlayerAccount(tax); + } catch (Exception ignored) { + } + if (!vault.getVault().hasAccount(tax)) { + getLogger().warning("Tax account's player never played this server before, that may cause server lagg or economy system error, you should change that name. But if this warning not cause any issues, you can safety ignore this."); + } } - if (!vault.getVault().hasAccount(tax)) { - getLogger().warning("Tax account's player never played this server before, that may cause server lagg or economy system error, you should change that name. But if this warning not cause any issues, you can safety ignore this."); - } - } + } } } } catch (Exception ignored) { diff --git a/src/main/java/org/maxgamer/quickshop/economy/Economy_Vault.java b/src/main/java/org/maxgamer/quickshop/economy/Economy_Vault.java index 2e8ab8cac..bada1c988 100644 --- a/src/main/java/org/maxgamer/quickshop/economy/Economy_Vault.java +++ b/src/main/java/org/maxgamer/quickshop/economy/Economy_Vault.java @@ -52,8 +52,9 @@ public class Economy_Vault implements EconomyCore, Listener { this.plugin = plugin; this.allowLoan = plugin.getConfig().getBoolean("shop.allow-economy-loan"); Util.debugLog("Loading caching tax account..."); + String taxAccount = plugin.getConfig().getString("tax-account"); //noinspection deprecation - this.taxAccountUUID = Bukkit.getOfflinePlayer(Objects.requireNonNull(plugin.getConfig().getString("tax-account", "tax"))).getUniqueId(); + this.taxAccountUUID = taxAccount == null || taxAccount.isEmpty() ? null : Bukkit.getOfflinePlayer(taxAccount).getUniqueId(); setupEconomy(); } diff --git a/src/main/java/org/maxgamer/quickshop/shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/shop/ShopManager.java index c59b812e7..f7771a96e 100644 --- a/src/main/java/org/maxgamer/quickshop/shop/ShopManager.java +++ b/src/main/java/org/maxgamer/quickshop/shop/ShopManager.java @@ -73,10 +73,14 @@ public class ShopManager { this.plugin = plugin; this.useFastShopSearchAlgorithm = plugin.getConfig().getBoolean("shop.use-fast-shop-search-algorithm", false); Util.debugLog("Loading caching tax account..."); - // noinspection ConstantConditions - OfflinePlayer taxPlayer = Bukkit.getOfflinePlayer(plugin.getConfig().getString("tax-account", "tax")); - - this.cacheTaxAccount = taxPlayer.getUniqueId(); + String taxAccount = plugin.getConfig().getString("tax-account", "tax"); + if (!(taxAccount == null || taxAccount.isEmpty())) { + OfflinePlayer taxPlayer = Bukkit.getOfflinePlayer(taxAccount); + this.cacheTaxAccount = taxPlayer.getUniqueId(); + } else { + //disable tax account + cacheTaxAccount = null; + } this.priceLimiter = new PriceLimiter(plugin.getConfig().getDouble("shop.minimum-price"), plugin.getConfig().getInt("shop.maximum-price"), plugin.getConfig().getBoolean("shop.allow-free-shop")); this.useOldCanBuildAlgorithm = plugin.getConfig().getBoolean("limits.old-algorithm"); this.autoSign = plugin.getConfig().getBoolean("shop.auto-sign");