Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
7sat committed Apr 1, 2023
1 parent ab00055 commit 4965ae9
Show file tree
Hide file tree
Showing 18 changed files with 58 additions and 54 deletions.
15 changes: 15 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,20 @@
<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>
6 changes: 1 addition & 5 deletions src/main/java/me/sat7/dynamicshop/DynaShopAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ public static void openItemTradeGui(Player player, String shopName, String trade
{
if(!IsShopEnable(shopName))
{
if(player.hasPermission(P_ADMIN_SHOP_EDIT))
{
//player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "MESSAGE.SHOP_DISABLED"));
}
else
if(!player.hasPermission(P_ADMIN_SHOP_EDIT))
{
player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "MESSAGE.SHOP_IS_CLOSED_BY_ADMIN"));
return;
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/me/sat7/dynamicshop/DynamicShop.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,34 @@
import me.sat7.dynamicshop.commands.Optional;
import me.sat7.dynamicshop.commands.Root;
import me.sat7.dynamicshop.constants.Constants;
import me.sat7.dynamicshop.economyhook.JobsHook;
import me.sat7.dynamicshop.economyhook.PlayerpointHook;
import me.sat7.dynamicshop.events.*;
import me.sat7.dynamicshop.events.JoinQuit;
import me.sat7.dynamicshop.events.OnChat;
import me.sat7.dynamicshop.events.OnClick;
import me.sat7.dynamicshop.events.OnSignClick;
import me.sat7.dynamicshop.files.CustomConfig;
import me.sat7.dynamicshop.guis.QuickSell;
import me.sat7.dynamicshop.guis.StartPage;
import me.sat7.dynamicshop.guis.UIManager;
import me.sat7.dynamicshop.economyhook.JobsHook;
import me.sat7.dynamicshop.utilities.*;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.milkbowl.vault.economy.Economy;

import org.black_ixx.playerpoints.PlayerPoints;
import org.black_ixx.playerpoints.PlayerPointsAPI;
import org.bstats.bukkit.Metrics;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

import java.io.File;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/sat7/dynamicshop/commands/Shop.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static void shopCommand(String[] args, CommandSender sender)
int open = Integer.parseInt(temp[0]);

player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "TIME.SHOP_IS_CLOSED").
replace("{time}", open + "").replace("{curTime}", curTime + ""));
replace("{time}", String.valueOf(open)).replace("{curTime}", String.valueOf(curTime)));
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import me.sat7.dynamicshop.DynamicShop;
import me.sat7.dynamicshop.commands.DSCMD;
import me.sat7.dynamicshop.commands.Shop;
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.OfflinePlayer;
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/me/sat7/dynamicshop/guis/ItemPalette.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,7 @@ else if (o2.getType().getMaxDurability() > 0)
if (isInteractable != 0)
return isInteractable;

int isRecord = Boolean.compare(o2.getType().isRecord(), o1.getType().isRecord());
if (isRecord != 0)
return isRecord;

return 0;
return Boolean.compare(o2.getType().isRecord(), o1.getType().isRecord());
}).thenComparing(ItemPalette::GetArmorType).thenComparing(ItemPalette::GetPotionType).thenComparing(ItemPalette::GetSortName));

sortedList = allItems;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/me/sat7/dynamicshop/guis/ItemSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,13 @@ public Inventory getGui(Player player, String shopName, int shopSlotIndex, int t
int discountMatAmount = dsItem.discount/10;
if (discountMatAmount < 1)
discountMatAmount = 1;
CreateButton(DISCOUNT, discountMat, t(player, "ITEM_SETTING.DISCOUNT"), t(player, "ITEM_SETTING.DISCOUNT_LORE_2").replace("{num}", dsItem.discount+""), discountMatAmount);
CreateButton(DISCOUNT, discountMat, t(player, "ITEM_SETTING.DISCOUNT"), t(player, "ITEM_SETTING.DISCOUNT_LORE_2").replace("{num}", String.valueOf(dsItem.discount)), discountMatAmount);

String tradeLimitIntervalString = dsItem.tradeLimitInterval / 1000 / 60 / 60 + "";
String tradeLimitIntervalString = String.valueOf(dsItem.tradeLimitInterval / 1000 / 60 / 60);
String tradeLimitNextTimerString = sdf.format(dsItem.tradeLimitNextTimer);
CreateButton(TRADE_LIMIT_AMOUNT, Material.PLAYER_HEAD,
t(player, "ITEM_SETTING.TRADE_LIMIT_AMOUNT"),
t(player, "ITEM_SETTING.TRADE_LIMIT_AMOUNT_LORE").replace("{num}", dsItem.tradeLimit + ""));
t(player, "ITEM_SETTING.TRADE_LIMIT_AMOUNT_LORE").replace("{num}", String.valueOf(dsItem.tradeLimit)));

if (dsItem.tradeLimit != 0)
{
Expand All @@ -285,7 +285,7 @@ public Inventory getGui(Player player, String shopName, int shopSlotIndex, int t

CreateButton(TRADE_LIMIT_INTERVAL_TIMER, Material.CLOCK,
t(player, "ITEM_SETTING.TRADE_LIMIT_TIMER"),
t(player, "ITEM_SETTING.TRADE_LIMIT_TIMER_LORE").replace("{num}", timerOffset / 1000 / 60 / 60 + "").replace("{time}", tradeLimitNextTimerString));
t(player, "ITEM_SETTING.TRADE_LIMIT_TIMER_LORE").replace("{num}", String.valueOf(timerOffset / 1000 / 60 / 60)).replace("{time}", tradeLimitNextTimerString));
}

CreateButton(RECOMMEND, Material.NETHER_STAR, t(player, "ITEM_SETTING.RECOMMEND"), recommendLore); // 추천 버튼
Expand Down Expand Up @@ -484,7 +484,7 @@ private void SetToRecommend()
dsItem.tradeLimit, dsItem.tradeLimitInterval, dsItem.tradeLimitNextTimer);
DynaShopAPI.openItemSettingGui(player, shopName, shopSlotIndex, currentTab, newDSItem, timerOffset);

player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "MESSAGE.RECOMMEND_APPLIED").replace("{playerNum}", ConfigUtil.GetNumberOfPlayer() + ""));
player.sendMessage(DynamicShop.dsPrefix(player) + t(player, "MESSAGE.RECOMMEND_APPLIED").replace("{playerNum}", String.valueOf(ConfigUtil.GetNumberOfPlayer())));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/sat7/dynamicshop/guis/ItemTrade.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private void CreateTradeButtons(boolean sell)
int limit = ShopUtil.GetTradeLimitPerPlayer(shopName, tradeIdxInt);
String limitString = limit > 0 ? t(player, "SHOP.PURCHASE_LIMIT_PER_PLAYER") : t(player, "SHOP.SALES_LIMIT_PER_PLAYER");
String tradeLimitResetTime = ShopUtil.GetTradeLimitNextResetTime(shopName, tradeIdxInt);
tradeLimitString = limitString.replace("{num}", tradeLimitLeft + "").replace("{time}", tradeLimitResetTime);
tradeLimitString = limitString.replace("{num}", String.valueOf(tradeLimitLeft)).replace("{time}", tradeLimitResetTime);
}

int amount = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/sat7/dynamicshop/guis/PageEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private void SetupPageButtons(String shopName, int page)
String pageLore = ShopUtil.IsPageEmpty(shopName, pageNum) ? t(null, "PAGE_EDITOR.EMPTY") + "\n" : "";
pageLore += t(null, "PAGE_EDITOR.PAGE_LORE_PREMIUM");

CreateButton(PAGE_BUTTON_START + i, InGameUI.GetPageButtonIconMat(), pageNum + "", pageLore, pageNum);
CreateButton(PAGE_BUTTON_START + i, InGameUI.GetPageButtonIconMat(), String.valueOf(pageNum), pageLore, pageNum);
}

if (temp > 0)
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/me/sat7/dynamicshop/guis/Shop.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ else if (DynaShopAPI.isPlayerPointShop(shopName))

if (!stockText.isEmpty())
stockText += "\n";
stockText += limitString.replace("{num}", tradeLimitLeft + "").replace("{time}", tradeLimitResetTime);
stockText += limitString.replace("{num}", String.valueOf(tradeLimitLeft)).replace("{time}", tradeLimitResetTime);
}

String tradeLoreText = "";
Expand Down Expand Up @@ -366,8 +366,8 @@ else if (DynaShopAPI.isPlayerPointShop(shopName))
private String CreatePageButtonName()
{
String pageString = t(player, "SHOP.PAGE_TITLE");
pageString = pageString.replace("{curPage}", page + "");
pageString = pageString.replace("{maxPage}", maxPage + "");
pageString = pageString.replace("{curPage}", String.valueOf(page));
pageString = pageString.replace("{maxPage}", String.valueOf(maxPage));
return pageString;
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/me/sat7/dynamicshop/guis/ShopSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public Inventory getGui(Player player, String shopName)
int close = Integer.parseInt(temp[1]);

ArrayList<String> shopHourLore = new ArrayList<>(Arrays.asList(
t(player, "TIME.CUR").replace("{time}", curTime + ""),
t(player, "TIME.CUR").replace("{time}", String.valueOf(curTime)),
"§9" + t(player, "CUR_STATE") + ": ",
"§9 - " + t(player, "TIME.OPEN") + ": " + open,
"§9 - " + t(player, "TIME.CLOSE") + ": " + close,
Expand All @@ -150,7 +150,7 @@ public Inventory getGui(Player player, String shopName)
} else
{
ArrayList<String> shopHourLore = new ArrayList<>(Arrays.asList(
t(player, "TIME.CUR").replace("{time}", curTime + ""),
t(player, "TIME.CUR").replace("{time}", String.valueOf(curTime)),
"§9" + t(player, "CUR_STATE") + ": " + t(player, "TIME.OPEN24"),
"§e" + t(player, "CLICK") + ": " + t(player, "TIME.SET_SHOPHOURS")));
CreateButton(SHOP_HOUR, Material.CLOCK, t(player, "TIME.SHOPHOURS"), shopHourLore);
Expand Down Expand Up @@ -284,7 +284,7 @@ public Inventory getGui(Player player, String shopName)
ArrayList<String> taxLore = new ArrayList<>(Arrays.asList(
"§9" + t(player, "CUR_STATE") + ": " + t(player, "TAX.USE_LOCAL"),
"§e" + t(player, "CLICK") + ": " +
t(player, "TAX.USE_GLOBAL").replace("{tax}", globalTax + "")));
t(player, "TAX.USE_GLOBAL").replace("{tax}", String.valueOf(globalTax))));
CreateButton(TAX_TOGGLE, Material.IRON_INGOT, t(player, "TAX.SALES_TAX"), taxLore);

ArrayList<String> taxLore2 = new ArrayList<>(Arrays.asList(
Expand All @@ -295,7 +295,7 @@ public Inventory getGui(Player player, String shopName)
{
ArrayList<String> taxLore = new ArrayList<>(Arrays.asList(
"§9" + t(player, "CUR_STATE") + ": " +
t(player, "TAX.USE_GLOBAL").replace("{tax}", globalTax + ""),
t(player, "TAX.USE_GLOBAL").replace("{tax}", String.valueOf(globalTax)),
"§e" + t(player, "CLICK") + ": " + t(player, "TAX.USE_LOCAL")));
CreateButton(TAX_TOGGLE, Material.IRON_INGOT, t(player, "TAX.SALES_TAX"), taxLore);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/me/sat7/dynamicshop/transactions/Buy.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ else if (currency == ItemTrade.CURRENCY.PLAYER_POINT)
priceSum = Math.ceil(priceSum);
}

EconomyResponse r = null;
EconomyResponse r;
if (currency == ItemTrade.CURRENCY.VAULT)
{
r = DynamicShop.getEconomy().withdrawPlayer(player, priceSum);
Expand Down Expand Up @@ -258,8 +258,8 @@ private static void RunBuyCommand(CustomConfig data, Player player, String shopN
.replace("{player}", player.getName())
.replace("{shop}", shopName)
.replace("{itemType}", tempIS.getType().toString())
.replace("{amount}", actualAmount + "")
.replace("{priceSum}", priceSum + "");
.replace("{amount}", String.valueOf(actualAmount))
.replace("{priceSum}", String.valueOf(priceSum));
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), buyCmd);
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/me/sat7/dynamicshop/transactions/Sell.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.sat7.dynamicshop.transactions;

import java.util.HashMap;
import java.util.Map;

import me.sat7.dynamicshop.economyhook.PlayerpointHook;
Expand All @@ -21,7 +20,6 @@

import static me.sat7.dynamicshop.utilities.LangUtil.n;
import static me.sat7.dynamicshop.utilities.LangUtil.t;
import static me.sat7.dynamicshop.utilities.MathUtil.Clamp;

public final class Sell
{
Expand Down Expand Up @@ -394,9 +392,9 @@ private static void RunSellCommand(CustomConfig data, Player player, String shop
.replace("{player}", player.getName())
.replace("{shop}", shopName)
.replace("{itemType}", tempIS.getType().toString())
.replace("{amount}", actualAmount + "")
.replace("{priceSum}", priceSum + "")
.replace("{tax}", tax + "");
.replace("{amount}", String.valueOf(actualAmount))
.replace("{priceSum}", String.valueOf(priceSum))
.replace("{tax}", String.valueOf(tax));
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), sellCmd);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import me.sat7.dynamicshop.files.CustomConfig;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;

import java.util.ArrayList;
import java.util.Map;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/me/sat7/dynamicshop/utilities/HashUtil.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.sat7.dynamicshop.utilities;

import me.sat7.dynamicshop.DynamicShop;
import org.bukkit.inventory.ItemStack;

import java.math.BigInteger;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/sat7/dynamicshop/utilities/ItemsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static String getBeautifiedName(String matName)
StringBuilder finalStr = new StringBuilder();
for (String s : temparr)
{
s = ("" + s.charAt(0)).toUpperCase() + s.substring(1);
s = (String.valueOf(s.charAt(0))).toUpperCase() + s.substring(1);
finalStr.append(s).append(" ");
}
finalStr = new StringBuilder(finalStr.substring(0, finalStr.length() - 1));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/me/sat7/dynamicshop/utilities/LangUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ public static String t(Player player, String key, boolean hexConvert)
Matcher matcher = HEX_PATTERN.matcher(temp);
while (matcher.find())
{
temp = temp.replace(matcher.group(), "" + ChatColor.of(matcher.group()));
temp = temp.replace(matcher.group(), String.valueOf(ChatColor.of(matcher.group())));
}
}

Expand All @@ -943,7 +943,7 @@ public static String TranslateHexColor(String message)
Matcher matcher = HEX_PATTERN.matcher(message);
while (matcher.find())
{
message = message.replace(matcher.group(), "" + ChatColor.of(matcher.group()));
message = message.replace(matcher.group(), String.valueOf(ChatColor.of(matcher.group())));
}
return message;
}
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/me/sat7/dynamicshop/utilities/LogUtil.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package me.sat7.dynamicshop.utilities;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

import com.opencsv.CSVWriter;
import me.sat7.dynamicshop.DynamicShop;
import me.sat7.dynamicshop.constants.Constants;
import me.sat7.dynamicshop.files.CustomConfig;
import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

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

public final class LogUtil
Expand Down Expand Up @@ -58,7 +60,7 @@ public static void addLog(String shopName, String itemName, int amount, double v
.replace("{player}", player)
.replace("{shop}", shopName)
.replace("{item}", ItemsUtil.getBeautifiedName( itemName))
.replace("{amount}", Math.abs(amount) + "");
.replace("{amount}", String.valueOf(Math.abs(amount)));

if(data.get().contains("Options.log.printToConsole") && data.get().getBoolean("Options.log.printToConsole"))
{
Expand Down

0 comments on commit 4965ae9

Please sign in to comment.