Skip to content
This repository was archived by the owner on Dec 5, 2021. It is now read-only.

Commit 5aa3949

Browse files
Merge remote-tracking branch 'origin/master'
Former-commit-id: 29c94aa
2 parents 1c66e95 + 69df709 commit 5aa3949

6 files changed

Lines changed: 177 additions & 409 deletions

File tree

src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,7 @@
2020
package org.maxgamer.quickshop.Shop;
2121

2222
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.*;
4324
import org.bukkit.block.Block;
4425
import org.bukkit.block.BlockFace;
4526
import org.bukkit.block.BlockState;
@@ -59,24 +40,38 @@
5940
import org.maxgamer.quickshop.Util.MsgUtil;
6041
import org.maxgamer.quickshop.Util.Util;
6142

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+
*/
6353
public class ShopManager {
6454

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+
6959
private HashMap<UUID, Info> actions = new HashMap<>();
60+
7061
private QuickShop plugin;
62+
7163
private boolean useFastShopSearchAlgorithm = false;
7264

65+
private UUID cacheTaxAccount;
66+
7367
public ShopManager(@NotNull QuickShop plugin) {
7468
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();
7773
}
7874

79-
@SuppressWarnings("deprecation")
8075
private void actionBuy(
8176
@NotNull Player p,
8277
@NotNull Economy eco,
@@ -185,9 +180,8 @@ private void actionBuy(
185180
}
186181
// Purchase successfully
187182
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);
191185
}
192186
}
193187
// Notify the owner of the purchase.
@@ -392,11 +386,8 @@ private void actionCreate(
392386
return;
393387
}
394388
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);
400391
}
401392
} catch (Exception e2) {
402393
e2.printStackTrace();

src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,25 @@ public static void loadCfgMessages() throws InvalidConfigurationException {
321321
Util.debugLog("Loading language file from exist file...");
322322
if (!new File(plugin.getDataFolder(), "messages.json").exists()) {
323323
plugin.getLanguage().saveFile(languageCode, "messages", "messages.json");
324-
nJson.loadFromString(
325-
Util.readToString(new File(plugin.getDataFolder(), "messages.json").getAbsolutePath()));
324+
nJson.loadFromString(Util.readToString(new File(plugin.getDataFolder(), "messages.json").getAbsolutePath()));
326325
}
327326
}
328327
messagei18n = nJson;
329328
/* Set default language vesion and update messages.yml */
330-
if (messagei18n.getInt("language-version") == 0) {
329+
Optional<String> ver = messagei18n.getString("language-version");
330+
int versi = 0;
331+
if (ver.isPresent()) {
332+
String vers = ver.get();
333+
try {
334+
versi = Integer.parseInt(vers);
335+
} catch (NumberFormatException ignore) {
336+
337+
}
338+
}
339+
if (messagei18n.getInt("language-version") == 0 && versi == 0) {
331340
messagei18n.set("language-version", 1);
341+
} else {
342+
messagei18n.set("language-version", versi);
332343
}
333344
updateMessages(messagei18n.getInt("language-version"));
334345
messagei18n.loadFromString(Util.parseColours(messagei18n.saveToString()));

src/main/resources/messages/en.json

Lines changed: 0 additions & 234 deletions
This file was deleted.

src/main/resources/messages/fi.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@
225225
"github": "[Github]",
226226
"spigotmc": "[SpigotMC]",
227227
"bukkitdev": "[BukkitDev]",
228-
"master": "[Master]"
228+
"master": "[master]"
229229
}
230230
},
231231
"shop-removed-cause-ongoing-fee": "&cKauppasi ({0}) poistettiin, sill\u00e4 sinulla ei ollut varaa yll\u00e4pit\u00e4\u00e4 sit\u00e4!",
232232
"digits-reach-the-limit": "&cOlet saavuttanut desimaalirajan.",
233-
"complete": "&aComplete!"
233+
"complete": "&aValmis!"
234234
}

0 commit comments

Comments
 (0)