From 988da1db6da0371a8def1dcbdf38e5bcf60f1940 Mon Sep 17 00:00:00 2001 From: sandtechnology <20417547+sandtechnology@users.noreply.github.com> Date: Sun, 1 Mar 2020 22:33:14 +0800 Subject: [PATCH] Nullcheck for tax account Former-commit-id: c7376817d8537ee2021773f087166bc977bfbcc8 --- .../java/org/maxgamer/quickshop/Shop/ShopManager.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java index 1da1b0a2c..fa60c79bb 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java @@ -67,7 +67,10 @@ public class ShopManager { this.plugin = plugin; this.useFastShopSearchAlgorithm = plugin.getConfig().getBoolean("shop.use-fast-shop-search-algorithm", false); //noinspection ConstantConditions - this.cacheTaxAccount = Bukkit.getOfflinePlayer(plugin.getConfig().getString("tax-account", "tax")).getUniqueId(); + OfflinePlayer taxPlayer=Bukkit.getOfflinePlayer(plugin.getConfig().getString("tax-account", "tax")); + if(taxPlayer.hasPlayedBefore()) { + this.cacheTaxAccount = taxPlayer.getUniqueId(); + } } private void actionBuy(@NotNull Player p, @NotNull Economy eco, @NotNull HashMap actions2, @NotNull Info info, @NotNull String message, @NotNull Shop shop, int amount) { @@ -142,7 +145,7 @@ public class ShopManager { return; } // Purchase successfully - if (tax != 0) { + if (tax != 0&&cacheTaxAccount!=null) { eco.deposit(cacheTaxAccount, total * tax); } // Notify the owner of the purchase. @@ -296,7 +299,9 @@ public class ShopManager { return; } try { - plugin.getEconomy().deposit(cacheTaxAccount, createCost); + if(cacheTaxAccount!=null) { + plugin.getEconomy().deposit(cacheTaxAccount, createCost); + } } catch (Exception e2) { e2.printStackTrace(); plugin.getLogger().log(Level.WARNING, "QuickShop can't pay tax to account in config.yml, Please set tax account name to a existing player!");