From 42a7ade57c8440480f09c363b8a9b97b9e6c431a Mon Sep 17 00:00:00 2001
From: 7sat <49030779+7sat@users.noreply.github.com>
Date: Tue, 29 Mar 2022 20:34:32 +0900
Subject: [PATCH] Fixed an issue where the lore of items added from other
plugins was displayed incorrectly
---
pom.xml | 2 +-
.../me/sat7/dynamicshop/commands/Shop.java | 27 ++++---------
.../sat7/dynamicshop/utilities/ShopUtil.java | 39 +++++++++++++++++++
3 files changed, 47 insertions(+), 21 deletions(-)
diff --git a/pom.xml b/pom.xml
index b27c7ff..d797964 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.sat7
DynamicShop
- 3.6.1
+ 3.6.2
jar
DynamicShop
diff --git a/src/main/java/me/sat7/dynamicshop/commands/Shop.java b/src/main/java/me/sat7/dynamicshop/commands/Shop.java
index 7ac9128..d476aae 100644
--- a/src/main/java/me/sat7/dynamicshop/commands/Shop.java
+++ b/src/main/java/me/sat7/dynamicshop/commands/Shop.java
@@ -125,27 +125,14 @@ static void shopCommand(String[] args, CommandSender sender)
int curTime = (int) (player.getWorld().getTime()) / 1000 + 6;
if (curTime > 24) curTime -= 24;
- String[] temp = shopConf.getString("shophours").split("~");
-
- int open = Integer.parseInt(temp[0]);
- int close = Integer.parseInt(temp[1]);
-
- if (close > open)
- {
- if (!(open <= curTime && curTime < close))
- {
- player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "TIME.SHOP_IS_CLOSED").
- replace("{time}", open + "").replace("{curTime}", curTime + ""));
- return;
- }
- } else
+ if (!ShopUtil.CheckShopHour(shopName, player))
{
- if (!(open <= curTime || curTime < close))
- {
- player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "TIME.SHOP_IS_CLOSED").
- replace("{time}", open + "").replace("{curTime}", curTime + ""));
- return;
- }
+ String[] temp = shopConf.getString("shophours").split("~");
+ int open = Integer.parseInt(temp[0]);
+
+ player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "TIME.SHOP_IS_CLOSED").
+ replace("{time}", open + "").replace("{curTime}", curTime + ""));
+ return;
}
}
diff --git a/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java b/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java
index 3fb5946..f803cd4 100644
--- a/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java
+++ b/src/main/java/me/sat7/dynamicshop/utilities/ShopUtil.java
@@ -549,6 +549,7 @@ public static String[] FindTheBestShopToSell(Player player, ItemStack itemStack)
continue;
}
+ // 비활성화된 상점
boolean enable = data.get().getBoolean("Options.enable", true);
if (!enable)
continue;
@@ -557,6 +558,10 @@ public static String[] FindTheBestShopToSell(Player player, ItemStack itemStack)
if (data.get().contains("Options.flag.localshop") || data.get().contains("Options.flag.signshop") || data.get().contains("Options.flag.jobpoint"))
continue;
+ // 영업시간 확인
+ if (!CheckShopHour(entry.getKey(), player))
+ continue;
+
int sameItemIdx = ShopUtil.findItemFromShop(entry.getKey(), itemStack);
if (sameItemIdx != -1)
@@ -608,6 +613,7 @@ public static String[] FindTheBestShopToBuy(Player player, ItemStack itemStack)
continue;
}
+ // 비활성화된 상점
boolean enable = data.get().getBoolean("Options.enable", true);
if (!enable)
continue;
@@ -616,6 +622,10 @@ public static String[] FindTheBestShopToBuy(Player player, ItemStack itemStack)
if (data.get().contains("Options.flag.localshop") || data.get().contains("Options.flag.signshop") || data.get().contains("Options.flag.jobpoint"))
continue;
+ // 영업시간 확인
+ if (!CheckShopHour(entry.getKey(), player))
+ continue;
+
int sameItemIdx = ShopUtil.findItemFromShop(entry.getKey(), itemStack);
if (sameItemIdx != -1)
@@ -917,4 +927,33 @@ public static int StockStabilizing(Boolean isLegacyMode, Random generator,int st
return stock;
}
+
+ public static boolean CheckShopHour(String shopName, Player player)
+ {
+ CustomConfig shopData = ShopUtil.shopConfigFiles.get(shopName);
+ ConfigurationSection shopConf = shopData.get().getConfigurationSection("Options");
+
+ if (shopConf.contains("shophours"))
+ {
+ int curTimeHour = (int) (player.getWorld().getTime()) / 1000 + 6;
+ if (curTimeHour > 24) curTimeHour -= 24;
+
+ String[] temp = shopConf.getString("shophours").split("~");
+
+ int open = Integer.parseInt(temp[0]);
+ int close = Integer.parseInt(temp[1]);
+
+ if (close > open)
+ {
+ return open <= curTimeHour && curTimeHour < close;
+ } else
+ {
+ return open <= curTimeHour || curTimeHour < close;
+ }
+ }
+ else
+ {
+ return true;
+ }
+ }
}