diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java index 37873e151..11bd7b72b 100644 --- a/src/main/java/org/maxgamer/quickshop/QuickShop.java +++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java @@ -638,7 +638,7 @@ public class QuickShop extends JavaPlugin { if (this.display) { if (getConfig().getBoolean("shop.display-auto-despawn")) { this.displayAutoDespawnWatcher = new DisplayAutoDespawnWatcher(this); - this.displayAutoDespawnWatcher.runTaskTimer(this, 0, getConfig().getInt("shop.display-check-time")); // not worth async + this.displayAutoDespawnWatcher.runTaskTimerAsynchronously(this, 0, getConfig().getInt("shop.display-check-time")); // not worth async } } registerIntegrations(); diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java b/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java index 0c96fb508..a8d600d2e 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java @@ -55,6 +55,7 @@ public class ContainerShop implements Shop { private final ItemStack item; @NotNull private final Location location; + @Nullable private DisplayItem displayItem; @EqualsAndHashCode.Exclude private boolean isLoaded = false; @@ -565,7 +566,7 @@ public class ContainerShop implements Shop { * * @return The display item associated with this shop. */ - @NotNull + @Nullable public DisplayItem getDisplayItem() { return this.displayItem; } @@ -874,7 +875,7 @@ public class ContainerShop implements Shop { } this.isLoaded = true; - plugin.getShopManager().getLoadedShops().add(this); + Objects.requireNonNull(plugin.getShopManager().getLoadedShops()).add(this); plugin.getShopContainerWatcher().scheduleCheck(this); // check price restriction Entry priceRestriction = Util.getPriceRestriction(this.getMaterial()); diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java index f36379993..ca5d10d41 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/Util.java +++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java @@ -206,7 +206,8 @@ public class Util { } } long startTime = System.currentTimeMillis(); - String className = Thread.currentThread().getStackTrace()[2].getClassName(); + StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[2]; + String className = stackTraceElement.getClassName(); try { Class c = Class.forName(className); className = c.getSimpleName(); @@ -216,8 +217,8 @@ public class Util { } catch (ClassNotFoundException e) { //Ignore } - String methodName = Thread.currentThread().getStackTrace()[2].getMethodName(); - int codeLine = Thread.currentThread().getStackTrace()[2].getLineNumber(); + String methodName = stackTraceElement.getMethodName(); + int codeLine = stackTraceElement.getLineNumber(); for (String log : logs) { String text = "[" + ChatColor.DARK_GREEN + ChatColor.BOLD + "DEBUG" + ChatColor.RESET + "] [" + ChatColor.DARK_GREEN + className + ChatColor.RESET + "]" + " [" + ChatColor.DARK_GREEN + methodName + ChatColor.RESET + "] (" + ChatColor.DARK_GREEN + codeLine + ChatColor.RESET + ") " + log; @@ -254,7 +255,8 @@ public class Util { return; } long startTime = System.currentTimeMillis(); - String className = Thread.currentThread().getStackTrace()[2].getClassName(); + StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[2]; + String className = stackTraceElement.getClassName(); try { Class c = Class.forName(className); className = c.getSimpleName(); @@ -264,8 +266,8 @@ public class Util { } catch (ClassNotFoundException e) { //Ignore } - String methodName = Thread.currentThread().getStackTrace()[2].getMethodName(); - int codeLine = Thread.currentThread().getStackTrace()[2].getLineNumber(); + String methodName = stackTraceElement.getMethodName(); + int codeLine = stackTraceElement.getLineNumber(); for (String log : logs) { String text = "[" + ChatColor.DARK_GREEN + ChatColor.BOLD + "DEBUG" + ChatColor.RESET + "] [" + ChatColor.DARK_GREEN + className + ChatColor.RESET + "]" + " [" + ChatColor.DARK_GREEN + methodName + ChatColor.RESET + "] (" + ChatColor.DARK_GREEN + codeLine + ChatColor.RESET + ") " + log;