Skip to content

Commit eb95238

Browse files
Optimize devMode variable
1 parent 1540096 commit eb95238

File tree

1 file changed

+4
-10
lines changed
  • src/main/java/org/maxgamer/quickshop/util

1 file changed

+4
-10
lines changed

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
import java.util.AbstractMap.SimpleEntry;
6969
import java.util.*;
7070
import java.util.Map.Entry;
71-
import java.util.concurrent.atomic.AtomicBoolean;
7271
import java.util.concurrent.locks.ReentrantReadWriteLock;
7372
import java.util.logging.Level;
7473
import java.util.stream.Collectors;
@@ -86,7 +85,7 @@ public class Util {
8685
private static final ThreadLocal<MineDown> mineDown = ThreadLocal.withInitial(() -> new MineDown(""));
8786
private static int bypassedCustomStackSize = -1;
8887
private static Yaml yaml = null;
89-
private static AtomicBoolean devMode = null;
88+
private static Boolean devMode = null;
9089
@Setter
9190
private static QuickShop plugin;
9291
private static Object serverInstance;
@@ -331,10 +330,7 @@ public static void debugLog(@NotNull String... logs) {
331330
if (debugLogs.size() >= 2000) {
332331
debugLogs.clear();
333332
}
334-
if(devMode == null){ //Workaround: Initial it if devMode not set while call this method
335-
devMode = new AtomicBoolean(plugin.getConfig().getBoolean("dev-mode"));
336-
}
337-
if (!devMode.get()) {
333+
if (!isDevMode()) {
338334
for (String log : logs) {
339335
debugLogs.add("[DEBUG] " + log);
340336
}
@@ -625,7 +621,7 @@ public static void initialize() {
625621
restrictedPrices.clear();
626622
customStackSize.clear();
627623
currency2Symbol.clear();
628-
devMode = new AtomicBoolean(plugin.getConfig().getBoolean("dev-mode"));
624+
devMode = plugin.getConfig().getBoolean("dev-mode");
629625

630626
for (String s : plugin.getConfig().getStringList("shop-blocks")) {
631627
Material mat = Material.matchMaterial(s.toUpperCase());
@@ -1300,9 +1296,7 @@ public static List<String> getStartupFlags() {
13001296
* @return under dev-mode
13011297
*/
13021298
public static boolean isDevMode() {
1303-
if(devMode == null)
1304-
return false;
1305-
return devMode.get();
1299+
return devMode != null ? devMode : (devMode = plugin.getConfig().getBoolean("dev-mode"));
13061300
}
13071301

13081302
/**

0 commit comments

Comments
 (0)