|
20 | 20 | package org.maxgamer.quickshop.Shop; |
21 | 21 |
|
22 | 22 | import com.google.common.collect.Sets; |
23 | | -import java.sql.SQLException; |
24 | | -import java.text.DecimalFormat; |
25 | | -import java.util.ArrayList; |
26 | | -import java.util.Collection; |
27 | | -import java.util.HashMap; |
28 | | -import java.util.Iterator; |
29 | | -import java.util.List; |
30 | | -import java.util.Map.Entry; |
31 | | -import java.util.NoSuchElementException; |
32 | | -import java.util.Objects; |
33 | | -import java.util.Set; |
34 | | -import java.util.UUID; |
35 | | -import java.util.logging.Level; |
36 | | -import java.util.stream.Collectors; |
37 | | -import org.bukkit.Bukkit; |
38 | | -import org.bukkit.ChatColor; |
39 | | -import org.bukkit.Chunk; |
40 | | -import org.bukkit.Location; |
41 | | -import org.bukkit.Material; |
42 | | -import org.bukkit.World; |
| 23 | +import org.bukkit.*; |
43 | 24 | import org.bukkit.block.Block; |
44 | 25 | import org.bukkit.block.BlockFace; |
45 | 26 | import org.bukkit.block.BlockState; |
|
59 | 40 | import org.maxgamer.quickshop.Util.MsgUtil; |
60 | 41 | import org.maxgamer.quickshop.Util.Util; |
61 | 42 |
|
62 | | -/** Manage a lot of shops. */ |
| 43 | +import java.sql.SQLException; |
| 44 | +import java.text.DecimalFormat; |
| 45 | +import java.util.*; |
| 46 | +import java.util.Map.Entry; |
| 47 | +import java.util.logging.Level; |
| 48 | +import java.util.stream.Collectors; |
| 49 | + |
| 50 | +/** |
| 51 | + * Manage a lot of shops. |
| 52 | + */ |
63 | 53 | public class ShopManager { |
64 | 54 |
|
65 | | - private final HashMap<String, HashMap<ShopChunk, HashMap<Location, Shop>>> shops = |
66 | | - new HashMap<>(); |
67 | | - private final Set<Shop> loadedShops = QuickShop.instance.isEnabledAsyncDisplayDespawn() ? |
68 | | - Sets.newConcurrentHashSet() : Sets.newHashSet(); |
| 55 | + private final HashMap<String, HashMap<ShopChunk, HashMap<Location, Shop>>> shops = new HashMap<>(); |
| 56 | + |
| 57 | + private final Set<Shop> loadedShops = QuickShop.instance.isEnabledAsyncDisplayDespawn() ? Sets.newConcurrentHashSet() : Sets.newHashSet(); |
| 58 | + |
69 | 59 | private HashMap<UUID, Info> actions = new HashMap<>(); |
| 60 | + |
70 | 61 | private QuickShop plugin; |
| 62 | + |
71 | 63 | private boolean useFastShopSearchAlgorithm = false; |
72 | 64 |
|
| 65 | + private UUID cacheTaxAccount; |
| 66 | + |
73 | 67 | public ShopManager(@NotNull QuickShop plugin) { |
74 | 68 | this.plugin = plugin; |
75 | | - this.useFastShopSearchAlgorithm = |
76 | | - plugin.getConfig().getBoolean("shop.use-fast-shop-search-algorithm", false); |
| 69 | + this.useFastShopSearchAlgorithm = plugin.getConfig().getBoolean("shop.use-fast-shop-search-algorithm", false); |
| 70 | + String taxAccount = plugin.getConfig().getString("tax-account"); |
| 71 | + //noinspection ConstantConditions |
| 72 | + this.cacheTaxAccount = Bukkit.getOfflinePlayer(taxAccount).getUniqueId(); |
77 | 73 | } |
78 | 74 |
|
79 | | - @SuppressWarnings("deprecation") |
80 | 75 | private void actionBuy( |
81 | 76 | @NotNull Player p, |
82 | 77 | @NotNull Economy eco, |
@@ -185,9 +180,8 @@ private void actionBuy( |
185 | 180 | } |
186 | 181 | // Purchase successfully |
187 | 182 | if (tax != 0) { |
188 | | - String taxAccount = plugin.getConfig().getString("tax-account"); |
189 | | - if (taxAccount != null) { |
190 | | - eco.deposit(Bukkit.getOfflinePlayer(taxAccount).getUniqueId(), total * tax); |
| 183 | + if (cacheTaxAccount != null) { |
| 184 | + eco.deposit(cacheTaxAccount, total * tax); |
191 | 185 | } |
192 | 186 | } |
193 | 187 | // Notify the owner of the purchase. |
@@ -392,11 +386,8 @@ private void actionCreate( |
392 | 386 | return; |
393 | 387 | } |
394 | 388 | try { |
395 | | - String taxAccount = plugin.getConfig().getString("tax-account"); |
396 | | - if (taxAccount != null) { |
397 | | - plugin |
398 | | - .getEconomy() |
399 | | - .deposit(Bukkit.getOfflinePlayer(taxAccount).getUniqueId(), createCost); |
| 389 | + if (cacheTaxAccount != null) { |
| 390 | + plugin.getEconomy().deposit(cacheTaxAccount, createCost); |
400 | 391 | } |
401 | 392 | } catch (Exception e2) { |
402 | 393 | e2.printStackTrace(); |
|
0 commit comments