diff --git a/Auto-Tune/src/resources/config.yml b/Auto-Tune/src/resources/config.yml index c5a9795..002a794 100644 --- a/Auto-Tune/src/resources/config.yml +++ b/Auto-Tune/src/resources/config.yml @@ -24,8 +24,8 @@ web-server-enabled: true port: 8123 ## The maximum length in data points that the trade-short.html will show (this doesn't affect data) -## Info: When the time-period is set to 10, 144 is one day. -maximum-short-trade-length: 144 +## Info: When the time-period is set to 5, 288 is one day. +maximum-short-trade-length: 288 ## Server name that will show up in commands and requests server-name: 'My Server' @@ -139,7 +139,7 @@ interest-rate-update-period: 1200 ## lowest value in $ a player can go into debt ## Example: -10.00 -max-debt-value: -10000.00 +max-debt-value: -100.00 ## The percentage value to decrease items sold with enchantments ## Info: Stacked enchantments etc. can become very expensive so a number between 10% - 25% is usually fine diff --git a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java index 3ad0cc0..2935799 100644 --- a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java +++ b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java @@ -220,6 +220,20 @@ public static OutlinePane loadTradingItems(String itemName, Section sec, Outline GuiItem gItem; if (i < 7) { iStack = loadTradingItem(itemName, amounts[i], true, sec); + int maxStackSize = iStack.getMaxStackSize(); + int maxBuys = sec.itemMaxBuySell.get(itemName)[0]; + if (maxStackSize < amounts[i] || maxBuys < amounts[i]){ + Material mat = Material.RED_STAINED_GLASS_PANE; + ItemStack itemPane = new ItemStack(mat); + ItemMeta itemPaneMeta = itemPane.getItemMeta(); + itemPaneMeta.setDisplayName(ChatColor.MAGIC + "_"); + itemPane.setItemMeta(itemPaneMeta); + GuiItem gItemPane = new GuiItem(itemPane, event ->{ + event.setCancelled(true); + }); + front.addItem(gItemPane); + continue; + } gItem = new GuiItem(iStack, event -> { Player player = (Player) event.getWhoClicked(); if (event.getClick() == ClickType.LEFT) { @@ -277,6 +291,20 @@ public static OutlinePane loadTradingItems(String itemName, Section sec, Outline }); } else { iStack = loadTradingItem(itemName, amounts[i - 7], false, sec); + int maxStackSize = iStack.getMaxStackSize(); + int maxSells = sec.itemMaxBuySell.get(itemName)[1]; + if (maxStackSize < amounts[i - 7] || maxSells < amounts[i - 7]){ + Material mat = Material.RED_STAINED_GLASS_PANE; + ItemStack itemPane = new ItemStack(mat); + ItemMeta itemPaneMeta = itemPane.getItemMeta(); + itemPaneMeta.setDisplayName(ChatColor.MAGIC + "_"); + itemPane.setItemMeta(itemPaneMeta); + GuiItem gItemPane = new GuiItem(itemPane, event ->{ + event.setCancelled(true); + }); + front.addItem(gItemPane); + continue; + } gItem = new GuiItem(iStack, event -> { Player player = (Player) event.getWhoClicked(); if (event.getClick() == ClickType.LEFT) { diff --git a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneLoanCommand.java b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneLoanCommand.java index ed3b807..a87e1f8 100644 --- a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneLoanCommand.java +++ b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneLoanCommand.java @@ -52,6 +52,10 @@ public boolean onCommand(CommandSender sender, Command command, String label, St player.sendMessage(ChatColor.RED + "Correct Usage: /loan (Optional)"); return true; } + if (!canPlayerTakeOutThisLoan(value, player)){ + player.sendMessage(ChatColor.RED + "Error: Minimum balance for loaning is " + Config.getCurrencySymbol() + AutoTuneGUIShopUserCommand.df6.format(Config.getMaxDebt())); + return true; + } loan = new Loan(value, Config.getInterestRate(), (Config.getInterestRateUpdateRate()/20), Instant.now(), player, false); return true; } @@ -67,7 +71,10 @@ public boolean onCommand(CommandSender sender, Command command, String label, St player.sendMessage(ChatColor.RED + "Correct Usage: /loan (Optional)"); return true; } - + if (!canPlayerTakeOutThisLoan(value, player)){ + player.sendMessage(ChatColor.RED + "Error: Minimum balance for loaning is " + Config.getCurrencySymbol() + AutoTuneGUIShopUserCommand.df6.format(Config.getMaxDebt())); + return true; + } boolean cIntrest = Boolean.parseBoolean(args[1]); if (cIntrest == true){ loan = new Loan(value, Config.getCompoundInterestRate(), (Config.getInterestRateUpdateRate()/20), Instant.now(), player, true); @@ -167,6 +174,19 @@ public Gui loadLoanBars(Gui gui, Player player){ return gui; } + public boolean canPlayerTakeOutThisLoan(double loan_value, Player player){ + double balance = Main.getEconomy().getBalance(player); + double loanTotalValue = LoanEventHandler.getPlayerLoanValue(player); + double netWorth = balance - loanTotalValue; + double netWorthWithNewLoan = netWorth - loan_value; + if (netWorthWithNewLoan <= Config.getMaxDebt()){ + return false; + } + else{ + return true; + } + } + public String generateCompoundEnabledLore(Loan loan){ if (loan.compound_enabled){ return (ChatColor.GREEN + "Enabled"); diff --git a/Auto-Tune/src/unprotesting/com/github/util/Config.java b/Auto-Tune/src/unprotesting/com/github/util/Config.java index 18094ab..16cd071 100644 --- a/Auto-Tune/src/unprotesting/com/github/util/Config.java +++ b/Auto-Tune/src/unprotesting/com/github/util/Config.java @@ -122,11 +122,11 @@ public static void loadDefaults() { Config.setDurabilityLimiter(Main.getMainConfig().getDouble("durability-limiter", 5.0)); Config.setInterestRate(Main.getMainConfig().getDouble("interest-rate", 0.005)); Config.setCompoundInterestRate(Main.getMainConfig().getDouble("compound-interest-rate", 0.0025)); - Config.setMaxDebt(Main.getMainConfig().getDouble("max-debt-value", -5000.00)); + Config.setMaxDebt(Main.getMainConfig().getDouble("max-debt-value", -100.00)); Config.setSellPriceDifferenceVariationStart(Main.getMainConfig().getDouble("sell-price-difference-variation-start", 25.0)); Config.setShopConfigGUIShopSellValue(Main.getMainConfig().getDouble("shop-config-guishop-sell-value", 20.00)); if (getTimePeriod() < 4){ - Main.debugLog("Time-Period Setting reverting to 4 to reduce memory usage."); + Main.debugLog("Time-Period Setting reverting to 4 to reduce memory usage. If you would like lower time periods open a ticket in the offical discord."); Config.setTimePeriod(4); } }