Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
7sat authored Jul 30, 2024
2 parents e8c35d7 + 71ec200 commit 3de976a
Show file tree
Hide file tree
Showing 26 changed files with 2,331 additions and 90 deletions.
17 changes: 1 addition & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.sat7</groupId>
<artifactId>DynamicShop</artifactId>
<version>3.16.2</version>
<version>3.120.1</version>
<packaging>jar</packaging>

<name>DynamicShop</name>
Expand Down Expand Up @@ -170,20 +170,5 @@
<version>3.2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
</project>
14 changes: 10 additions & 4 deletions src/main/java/me/sat7/dynamicshop/DynaShopAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public static void openShopSettingGui(Player player, String shopName)
// 상점 로테이트 편집기
public static void OpenRotationEditor(Player player, String shopName)
{
DynamicShop.PaidOnlyMsg(player);
RotationEditor uiClass = new RotationEditor();
Inventory inventory = uiClass.getGui(player, shopName);
UIManager.Open(player, inventory, uiClass);
}

// 거래화면 생성 및 열기
Expand Down Expand Up @@ -123,13 +125,17 @@ public static void openPageEditor(Player player, String shopName, int page)
// 로그뷰어 열기
public static void openLogViewer(Player player, String shopName)
{
DynamicShop.PaidOnlyMsg(player);
LogViewer uiClass = new LogViewer();
Inventory inventory = uiClass.getGui(player, shopName);
UIManager.Open(player, inventory, uiClass);
}

// 재고 시뮬레이터 열기
public static void openStockSimulator(Player player, String shopName)
{
DynamicShop.PaidOnlyMsg(player);
StockSimulator uiClass = new StockSimulator();
Inventory inventory = uiClass.getGui(player, shopName);
UIManager.Open(player, inventory, uiClass);
}

// 스타트 페이지
Expand Down Expand Up @@ -225,7 +231,7 @@ public static ArrayList<ItemStack> getShopItems(@NonNull String shopName)
if (validateShopName(shopName))
{
CustomConfig data = ShopUtil.shopConfigFiles.get(shopName);

ArrayList<ItemStack> list = new ArrayList<>();
for (String s : data.get().getKeys(false))
{
Expand Down
39 changes: 24 additions & 15 deletions src/main/java/me/sat7/dynamicshop/DynamicShop.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
import java.io.File;
import java.util.*;

import static me.sat7.dynamicshop.utilities.LangUtil.t;

public final class DynamicShop extends JavaPlugin implements Listener
{
private static Economy econ = null; // 볼트에 물려있는 이코노미
Expand Down Expand Up @@ -84,6 +82,7 @@ public static String dsPrefix(Player player)
private BukkitTask periodicRepetitiveTask;
private BukkitTask saveLogsTask;
private BukkitTask cullLogsTask;
private BukkitTask backupTask;
private BukkitTask shopSaveTask;
private BukkitTask userDataRepetitiveTask;

Expand Down Expand Up @@ -149,11 +148,11 @@ public static void DebugLog()

UIManager.DebugLog();

//console.sendMessage("---------------------");
console.sendMessage("---------------------");

//console.sendMessage("RotationTaskMap: size" + RotationUtil.RotationTaskMap.size());
//for(Map.Entry<String, Integer> entry : RotationUtil.RotationTaskMap.entrySet())
// console.sendMessage(entry.getKey() + ": " + entry.getValue());
console.sendMessage("RotationTaskMap: size: " + RotationUtil.RotationTaskMap.size());
for(Map.Entry<String, Integer> entry : RotationUtil.RotationTaskMap.entrySet())
console.sendMessage(entry.getKey() + ": " + entry.getValue());

console.sendMessage("---------------------");

Expand Down Expand Up @@ -195,11 +194,14 @@ private void Init()
PeriodicRepetitiveTask();
startSaveLogsTask();
startCullLogsTask();
StartBackupTask();
StartShopSaveTask();
StartUserDataTask();
hookIntoJobs();
hookIntoPlayerPoints();
InitPapi();

RotationUtil.RestartAllRotationTask();

// 완료
console.sendMessage(Constants.DYNAMIC_SHOP_PREFIX + " Enabled! :)");
Expand Down Expand Up @@ -400,6 +402,19 @@ private void RepeatAction()
UIManager.RefreshUI();
}

public void StartBackupTask()
{
if (!ConfigUtil.GetShopYmlBackup_Enable())
return;

if (backupTask != null)
{
backupTask.cancel();
}
long interval = (20L * 60L * (long) ConfigUtil.GetShopYmlBackup_IntervalMinutes());
backupTask = Bukkit.getScheduler().runTaskTimer(DynamicShop.plugin, ShopUtil::ShopYMLBackup, interval, interval);
}

public void StartShopSaveTask()
{
if (shopSaveTask != null)
Expand Down Expand Up @@ -471,6 +486,9 @@ private void makeFolders()
File shopFolder = new File(getDataFolder(), "Shop");
shopFolder.mkdir(); // new 하고 같은줄에서 바로 하면 폴더 안만들어짐.

File rotationFolder = new File(getDataFolder(), "Rotation");
rotationFolder.mkdir();

File LogFolder = new File(getDataFolder(), "Log");
LogFolder.mkdir();
}
Expand Down Expand Up @@ -519,13 +537,4 @@ public void onDisable()
Bukkit.getScheduler().cancelTasks(this);
console.sendMessage(Constants.DYNAMIC_SHOP_PREFIX + " Disabled");
}

public static void PaidOnlyMsg(Player p)
{
TextComponent text = new TextComponent("");
text.addExtra(DynamicShop.dsPrefix(p) + t(p, "PAID_VERSION.DESC"));
text.addExtra(DynamicShop.CreateLink(t(p, "PAID_VERSION.GET_PREMIUM"), false, ChatColor.WHITE, "https://spigotmc.org/resources/100058"));

p.spigot().sendMessage(text);
}
}
2 changes: 1 addition & 1 deletion src/main/java/me/sat7/dynamicshop/UpdateChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class UpdateChecker
{
public static final int PROJECT_ID = 65603;
public static final int PROJECT_ID = 65603;//100058;
private final JavaPlugin plugin;
private final int resourceId;

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/me/sat7/dynamicshop/commands/DeleteShop.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.sat7.dynamicshop.commands;

import me.sat7.dynamicshop.files.CustomConfig;
import me.sat7.dynamicshop.utilities.RotationUtil;
import me.sat7.dynamicshop.utilities.UserUtil;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -42,6 +43,7 @@ public void RunCMD(String[] args, CommandSender sender)

ShopUtil.shopConfigFiles.remove(args[1]);
ShopUtil.shopDirty.remove(args[1]);
RotationUtil.OnShopDeleted(args[1]);
UserUtil.ClearTradeLimitData(args[1]);

sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "MESSAGE.SHOP_DELETED"));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/sat7/dynamicshop/commands/Help.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void showHelp(String helpcode, Player player, String[] args)
if (player.hasPermission(P_ADMIN_SHOP_EDIT) || player.hasPermission(P_ADMIN_EDIT_ALL))
{
player.sendMessage(" - " + t(player, "HELP.USAGE")
+ ": /ds shop <shopname> <enable | addhand | add | edit | editall | setToRecAll | sellbuy | permission | maxpage | flag | currency | position | shophours | fluctuation | stockStabilizing | command | account | log | resetTradingVolume | background>");
+ ": /ds shop <shopname> <enable | addhand | add | edit | editall | setToRecAll | sellbuy | permission | maxpage | flag | currency | position | shophours | fluctuation | stockStabilizing | command | account | log | resetTradingVolume | background>");
}

if (player.hasPermission(P_ADMIN_SHOP_EDIT))
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/me/sat7/dynamicshop/commands/Reload.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public void RunCMD(String[] args, CommandSender sender)

DynamicShop.plugin.startSaveLogsTask();
DynamicShop.plugin.startCullLogsTask();

DynamicShop.plugin.StartBackupTask();
DynamicShop.plugin.StartShopSaveTask();

DynamicShop.plugin.StartUserDataTask();
Expand All @@ -65,6 +67,8 @@ public void RunCMD(String[] args, CommandSender sender)

LangUtil.setupLangFile(ConfigUtil.GetLanguage()); // ConfigUtil.Load() 보다 밑에 있어야함.

RotationUtil.Reload();

sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "HELP.RELOADED"));
}
}
33 changes: 30 additions & 3 deletions src/main/java/me/sat7/dynamicshop/commands/shop/Background.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

import me.sat7.dynamicshop.DynamicShop;
import me.sat7.dynamicshop.commands.DSCMD;
import me.sat7.dynamicshop.commands.Shop;
import me.sat7.dynamicshop.constants.Constants;
import me.sat7.dynamicshop.files.CustomConfig;
import me.sat7.dynamicshop.utilities.ShopUtil;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

Expand Down Expand Up @@ -32,8 +37,30 @@ public void RunCMD(String[] args, CommandSender sender)
if(!CheckValid(args, sender))
return;

Player player = (Player) sender;
if (player != null)
DynamicShop.PaidOnlyMsg(player);
if (args[3].equalsIgnoreCase("clear"))
{
String shopName = Shop.GetShopName(args);
CustomConfig shopData = ShopUtil.shopConfigFiles.get(shopName);
shopData.get().set("Options.background", null);
shopData.save();

sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "MESSAGE.CHANGES_APPLIED") + args[2] + " " + args[3]);

return;
}

Material mat = Material.getMaterial(args[3].toUpperCase() + "_STAINED_GLASS_PANE");
if (mat == null)
{
sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "ERR.WRONG_DATATYPE"));
return;
}

String shopName = Shop.GetShopName(args);
CustomConfig shopData = ShopUtil.shopConfigFiles.get(shopName);
shopData.get().set("Options.background", args[3].toUpperCase());
shopData.save();

sender.sendMessage(DynamicShop.dsPrefix(sender) + t(sender, "MESSAGE.CHANGES_APPLIED") + args[2] + " " + args[3]);
}
}
6 changes: 1 addition & 5 deletions src/main/java/me/sat7/dynamicshop/events/JoinQuit.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,9 @@ public void onPlayerJoin(PlayerJoinEvent e)
if (e.getPlayer().hasPermission(P_ADMIN_SHOP_EDIT) || e.getPlayer().hasPermission(P_ADMIN_RELOAD))
{
TextComponent text = new TextComponent("");
text.addExtra(DynamicShop.CreateLink("DShop3", false, ChatColor.DARK_AQUA, UpdateChecker.getResourceUrl()));
text.addExtra(DynamicShop.CreateLink("DShop3 Premium", false, ChatColor.DARK_AQUA, UpdateChecker.getResourceUrl()));
text.addExtra(" ");
text.addExtra(DynamicShop.CreateLink("Download", false, ChatColor.WHITE, UpdateChecker.getResourceUrl()));
text.addExtra(" ");
text.addExtra(DynamicShop.CreateLink("Premium", false, ChatColor.WHITE, "https://spigotmc.org/resources/100058"));
text.addExtra(" ");
text.addExtra(DynamicShop.CreateLink("Donate", false, ChatColor.WHITE, "https://www.paypal.com/paypalme/7sat"));

e.getPlayer().sendMessage("");
e.getPlayer().spigot().sendMessage(text);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/me/sat7/dynamicshop/events/OnChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import me.sat7.dynamicshop.utilities.UserUtil;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand Down
28 changes: 27 additions & 1 deletion src/main/java/me/sat7/dynamicshop/guis/ColorPicker.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package me.sat7.dynamicshop.guis;

import me.sat7.dynamicshop.DynaShopAPI;
import me.sat7.dynamicshop.DynamicShop;
import me.sat7.dynamicshop.files.CustomConfig;
import me.sat7.dynamicshop.utilities.ShopUtil;
import me.sat7.dynamicshop.utilities.UserUtil;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
Expand Down Expand Up @@ -40,7 +44,29 @@ public void OnClickUpperInventory(InventoryClickEvent e)

if (e.getSlot() == CLOSE)
{
DynaShopAPI.openStartPageSettingGui(player, slotIndex);
if (slotIndex == -1)
{
String shopName = UserUtil.userInteractItem.get(player.getUniqueId()).split("/")[0];
DynaShopAPI.openShopSettingGui(player, shopName);
}
else
{
DynaShopAPI.openStartPageSettingGui(player, slotIndex);
}
}
else if (slotIndex == -1)
{
String shopName = UserUtil.userInteractItem.get(player.getUniqueId()).split("/")[0];
CustomConfig data = ShopUtil.shopConfigFiles.get(shopName);

String color = null;
if (e.getCurrentItem() != null && !e.getCurrentItem().getType().isAir())
color = ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName());

data.get().set("Options.background", color);
data.save();

DynaShopAPI.openShopSettingGui(player, shopName);
}
else if(e.getCurrentItem() != null && !e.getCurrentItem().getType().isAir())
{
Expand Down
Loading

0 comments on commit 3de976a

Please sign in to comment.