From f84623f1f3068eaaa336c600ca0f784337ac7ca7 Mon Sep 17 00:00:00 2001 From: sandtechnology <20417547+sandtechnology@users.noreply.github.com> Date: Sun, 1 Mar 2020 20:51:05 +0800 Subject: [PATCH] Fix #349 Former-commit-id: 7f4925e110f563f766ae65e7be1f3fb44d240d8b --- src/main/java/org/maxgamer/quickshop/BootError.java | 2 +- .../org/maxgamer/quickshop/Shop/ShopManager.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/BootError.java b/src/main/java/org/maxgamer/quickshop/BootError.java index 97d071d5d..cb99a77c3 100644 --- a/src/main/java/org/maxgamer/quickshop/BootError.java +++ b/src/main/java/org/maxgamer/quickshop/BootError.java @@ -32,7 +32,7 @@ public class BootError { private String[] errors; - BootError(@NotNull String... errors) { + public BootError(@NotNull String... errors) { this.errors = errors; for (String err : errors) { QuickShop.instance.getLogger().severe(err); diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java index 83a008f4f..dcef168b3 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java @@ -37,6 +37,7 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.plugin.RegisteredListener; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.maxgamer.quickshop.BootError; import org.maxgamer.quickshop.Economy.Economy; import org.maxgamer.quickshop.Event.ShopCreateEvent; import org.maxgamer.quickshop.Event.ShopPreCreateEvent; @@ -67,8 +68,15 @@ public class ShopManager { this.plugin = plugin; this.useFastShopSearchAlgorithm = plugin.getConfig().getBoolean("shop.use-fast-shop-search-algorithm", false); String taxAccount = plugin.getConfig().getString("tax-account"); - //noinspection ConstantConditions - this.cacheTaxAccount = Bukkit.getOfflinePlayer(taxAccount).getUniqueId(); + for(OfflinePlayer player:Bukkit.getOfflinePlayers()){ + if(player.getName()!=null&&player.getName().equalsIgnoreCase(taxAccount)){ + cacheTaxAccount=player.getUniqueId(); + } + } + if(cacheTaxAccount==null){ + new BootError("Tax account never join the server","you should set a player which have joined the server in config.yml"); + throw new RuntimeException("Tax account never join the server!"); + } } private void actionBuy(@NotNull Player p, @NotNull Economy eco, @NotNull HashMap actions2, @NotNull Info info, @NotNull String message, @NotNull Shop shop, int amount) {