diff --git a/Auto-Tune/dependency-reduced-pom.xml b/Auto-Tune/dependency-reduced-pom.xml index b658fc8..0e4c424 100644 --- a/Auto-Tune/dependency-reduced-pom.xml +++ b/Auto-Tune/dependency-reduced-pom.xml @@ -4,7 +4,7 @@ unprotesting.com.github Auto-Tune Auto-Tune - 0.10.2 + 0.10.3 The automatic pricing plugin for minecraft https://github.com/Unprotesting/Auto-Tune diff --git a/Auto-Tune/pom.xml b/Auto-Tune/pom.xml index 1788db0..36c64a0 100644 --- a/Auto-Tune/pom.xml +++ b/Auto-Tune/pom.xml @@ -9,7 +9,7 @@ unprotesting.com.github Auto-Tune - 0.10.2 + 0.10.3 Auto-Tune https://github.com/Unprotesting/Auto-Tune diff --git a/Auto-Tune/src/resources/config.yml b/Auto-Tune/src/resources/config.yml index bc23585..ae0ee28 100644 --- a/Auto-Tune/src/resources/config.yml +++ b/Auto-Tune/src/resources/config.yml @@ -32,6 +32,8 @@ server-name: 'Auto-Tune Test Server' pricing-model: 'Exponential' ## Time Period in minutes +## Info: This should be around a tenth of the total items in your shop (i.e with 150 items this would be 15) to prevent overload +## Info: When decreasing or increasing this adjust your volatility settings accordingly time-period: 10 ## The amount of menu rows in the GUI shop, value of 4-6. @@ -47,6 +49,8 @@ no-permission: '&eYou do not have permission to perform this command' auto-sell-enabled: true ## How often auto-sell updates in ticks +## Info: Set this higher if few players use autosell +## Info: Set it lower if many players use autosell auto-sell-update-period: 15 ## How often players are shown their auto-sell profits in ticks @@ -57,6 +61,7 @@ auto-sell-profit-update-period: 1200 ## Volatility Calulation Algorithim ## Info: A fixed rate locks the maxiumum change to a certain price ## Info: A variable rate changes the maxiumum price-change based on current price calculations +## Most people dont need to change this off of Variable as they will be using the Exponential model Volatility-Algorithim: 'Variable' ## Percentage difference in sell price to buy price @@ -68,7 +73,7 @@ Fixed-Max-Volatility: 2.00 Fixed-Min-Volatility: 0.05 ## Maximum Volatility per Time Period for the Variable Volatility price calculation algorithim as a percentage of total price -Variable-Max-Volatility: 3.00 +Variable-Max-Volatility: 1.50 ## Minimum Volatility per Time Period for the Fixed Volatility price calculation algorithim in economy units Variable-Min-Volatility: 0.05 @@ -91,9 +96,9 @@ data-selection-c: 1.25 currency-symbol: '$' ## Enable sell price difference variation to ease out sell price varition -sell-price-difference-variation-enabled: false +sell-price-difference-variation-enabled: true ## Starting percententage sell price difference for sell price varition -sell-price-difference-variation-start: 25.0 +sell-price-difference-variation-start: 12.5 ## Time in minutes until sell price reaches sell-price-difference set in pricing model settings (default 7 days) sell-price-variation-time-period: 10080 ## Time in minutes that the sell-price-difference updates @@ -120,8 +125,9 @@ intrest-rate: 0.001 ## Time period in ticks between updates of the intrest rate for users loans intrest-rate-update-period: 1200 -## Maximum value in $ a player can go into debt -max-debt-value: -1000.00 +## lowest value in $ a player can go into debt +## Example: -10.00 +max-debt-value: 0.00 ## -- Other Settings -- diff --git a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneAutoSellCommand.java b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneAutoSellCommand.java index 5ab416a..1c149d0 100644 --- a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneAutoSellCommand.java +++ b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneAutoSellCommand.java @@ -62,6 +62,8 @@ public void loadGUIMAIN(Player player, CommandSender senderpub) { Gui gui1; StaticPane pageTwo = new StaticPane(1, 1, 7, menuRows - 2); StaticPane pageThree = new StaticPane(1, 1, 7, menuRows - 2); + StaticPane pageFour = new StaticPane(1, 1, 7, menuRows - 2); + StaticPane pageFive = new StaticPane(1, 1, 7, menuRows - 2); StaticPane back = new StaticPane(0, menuRows-1, 1, 1); StaticPane forward = new StaticPane(8, menuRows-1, 1, 1); @@ -72,16 +74,22 @@ public void loadGUIMAIN(Player player, CommandSender senderpub) { PaginatedPane pane = new PaginatedPane(0, 0, 9, menuRows); Integer paneSize = (menuRows-2)*7; Integer pageAmount = 2; - if (size > paneSize){ - pageTwo = new StaticPane(1, 1, 7, menuRows - 2); + if (size > paneSize) { pageAmount = 3; pane.addPane(1, pageTwo); } - if (size > paneSize*2){ - pageThree = new StaticPane(1, 1, 7, menuRows - 2); + if (size > paneSize * 2) { pageAmount = 4; pane.addPane(2, pageThree); } + if (size > paneSize * 3) { + pageAmount = 5; + pane.addPane(3, pageFour); + } + if (size > paneSize * 4) { + pageAmount = 6; + pane.addPane(4, pageFive); + } final Integer finalPageAmount = pageAmount; @@ -126,110 +134,177 @@ public void loadGUIMAIN(Player player, CommandSender senderpub) { im.setLore(Arrays.asList(ChatColor.GOLD + fullprice)); is.setItemMeta(im); if (Config.getMenuRows() == 4) { - if (i < 7) { + if (i<7) { pageOne.addItem(a, i, 0); } - if (i >= 7 && i < 14) { + else if (i >= 7 && i<14) { pageOne.addItem(a, i - 7, 1); } - if (i >= 14 && i < 21) { + else if (i >= 14 && i<21) { pageTwo.addItem(a, i - 14, 0); } - if (i >= 21 && i < 28) { + else if (i >= 21 && i<28) { pageTwo.addItem(a, i - 21, 1); } - if (i >= 28 && i < 35) { - pageThree.addItem(a, i - 28, 1); + else if (i >= 28 && i<35) { + pageThree.addItem(a, i - 28, 0); + } + else if (i >= 35 && i<42) { + pageThree.addItem(a, i - 35, 1); + } + else if (i >= 42 && i<49) { + pageFour.addItem(a, i - 42, 0); + } + else if (i >= 49 && i<56) { + pageFour.addItem(a, i - 49, 1); + } + else if (i >= 56 && i<63) { + pageFive.addItem(a, i - 56, 0); } - if (i >= 35 && i < 42) { - pageThree.addItem(a, i - 35, 2); + else if (i >= 63 && i<70) { + pageFive.addItem(a, i - 63, 1); } } if (Config.getMenuRows() == 5) { - if (i < 7) { + if (i<7) { pageOne.addItem(a, i, 0); } - if (i >= 7 && i < 14) { + else if (i >= 7 && i<14) { pageOne.addItem(a, i - 7, 1); } - if (i >= 14 && i < 21) { + else if (i >= 14 && i<21) { pageOne.addItem(a, i - 14, 2); } - if (i >= 21 && i < 28) { + else if (i >= 21 && i<28) { pageTwo.addItem(a, i - 21, 0); } - if (i >= 28 && i < 35) { + else if (i >= 28 && i<35) { pageTwo.addItem(a, i - 28, 1); } - if (i >= 35 && i < 42) { + else if (i >= 35 && i<42) { pageTwo.addItem(a, i - 35, 2); } - if (i >= 42 && i < 49) { + else if (i >= 42 && i<49) { pageThree.addItem(a, i - 42, 0); } - if (i >= 49 && i < 56) { + else if (i >= 49 && i<56) { pageThree.addItem(a, i - 49, 1); } - if (i >= 56 && i < 63) { + else if (i >= 56 && i<63) { pageThree.addItem(a, i - 56, 2); } + else if (i >= 63 && i<70) { + pageFour.addItem(a, i - 63, 0); + } + else if (i >= 70 && i<77) { + pageFour.addItem(a, i - 70, 1); + } + else if (i >= 77 && i<84) { + pageFour.addItem(a, i - 77, 2); + } + else if (i >= 84 && i<91) { + pageFive.addItem(a, i - 84, 0); + } + else if (i >= 91 && i<98) { + pageFive.addItem(a, i - 91, 1); + } + else if (i >= 98 && i<105) { + pageFive.addItem(a, i - 98, 2); + } } if (Config.getMenuRows() == 6) { - if (i < 7) { + if (i<7) { pageOne.addItem(a, i, 0); } - if (i >= 7 && i < 14) { + else if (i >= 7 && i<14) { pageOne.addItem(a, i - 7, 1); } - if (i >= 14 && i < 21) { + else if (i >= 14 && i<21) { pageOne.addItem(a, i - 14, 2); } - if (i >= 21 && i < 28) { + else if (i >= 21 && i<28) { pageOne.addItem(a, i - 21, 3); } - if (i >= 28 && i < 35) { + else if (i >= 28 && i<35) { pageTwo.addItem(a, i - 28, 0); } - if (i >= 35 && i < 42) { + else if (i >= 35 && i<42) { pageTwo.addItem(a, i - 35, 1); } - if (i >= 42 && i < 49) { + else if (i >= 42 && i<49) { pageTwo.addItem(a, i - 42, 2); } - if (i >= 49 && i < 56) { + else if (i >= 49 && i<56) { pageTwo.addItem(a, i - 49, 3); } - if (i >= 56 && i < 63) { + else if (i >= 56 && i<63) { pageThree.addItem(a, i - 56, 0); } - if (i >= 63 && i < 70) { + else if (i >= 63 && i<70) { pageThree.addItem(a, i - 63, 1); } - if (i >= 70 && i < 77) { + else if (i >= 70 && i<77) { pageThree.addItem(a, i - 70, 2); } - if (i >= 77 && i < 84) { + else if (i >= 77 && i<84) { pageThree.addItem(a, i - 77, 3); } - + else if (i >= 84 && i<91) { + pageFour.addItem(a, i - 84, 0); + } + else if (i >= 91 && i<98) { + pageFour.addItem(a, i - 91, 1); + } + else if (i >= 98 && i<105) { + pageFour.addItem(a, i - 98, 2); + } + else if (i >= 105 && i<112) { + pageFour.addItem(a, i - 105, 3); + } + else if (i >= 112 && i<119) { + pageFive.addItem(a, i - 112, 0); + } + else if (i >= 119 && i<126) { + pageFive.addItem(a, i - 119, 1); + } + else if (i >= 126 && i<135) { + pageFive.addItem(a, i - 126, 2); + } + else if (i >= 135 && i<142) { + pageFive.addItem(a, i - 135, 3); + } } i++; } } - pane.addPane(0, pageOne); - if (finalPageAmount == 3) { - pane.addPane(1, pageTwo); - pane.addPane(2, SBPane); - } - if (finalPageAmount == 4) { - pane.addPane(1, pageTwo); - pane.addPane(2, pageThree); - pane.addPane(3, SBPane); - } else { - pane.addPane(1, SBPane); - } + pane.addPane(0, pageOne); + if (finalPageAmount == 3) { + pane.addPane(1, pageTwo); + pane.addPane(2, SBPane); + } + else if (finalPageAmount == 4) { + pane.addPane(1, pageTwo); + pane.addPane(2, pageThree); + pane.addPane(3, SBPane); + } + else if (finalPageAmount == 5) { + pane.addPane(1, pageTwo); + pane.addPane(2, pageThree); + pane.addPane(3, pageFour); + pane.addPane(4, SBPane); + } + else if (finalPageAmount == 6) { + pane.addPane(1, pageTwo); + pane.addPane(2, pageThree); + pane.addPane(3, pageFour); + pane.addPane(4, pageFive); + pane.addPane(5, SBPane); + } + else { + pane.addPane(1, SBPane); + } gui1.addPane(pane); @@ -245,6 +320,16 @@ public void loadGUIMAIN(Player player, CommandSender senderpub) { imforward.setLore(Arrays.asList(ChatColor.BOLD + "Click to go to the next page")); isforward.setItemMeta(imforward); + if (pane.getPage() == 0 && finalPageAmount == 6) { + back.setVisible(false); + forward.setVisible(true); + } + + if (pane.getPage() == 0 && finalPageAmount == 5) { + back.setVisible(false); + forward.setVisible(true); + } + if (pane.getPage() == 0 && finalPageAmount == 4) { back.setVisible(false); forward.setVisible(true); @@ -260,22 +345,25 @@ public void loadGUIMAIN(Player player, CommandSender senderpub) { } back.addItem(new GuiItem(new ItemStack(isback), event -> { - if (pane.getPage() != 3) { + if (pane.getPage() != 0) { pane.setPage(pane.getPage() - 1); } - if (pane.getPage() == 3) { - pane.setPage(0); + if (pane.getPage() == 0 && finalPageAmount == 6) { + back.setVisible(false); + forward.setVisible(true); + } + if (pane.getPage() == 0 && finalPageAmount == 5) { + back.setVisible(false); + forward.setVisible(true); } if (pane.getPage() == 0 && finalPageAmount == 4) { back.setVisible(false); forward.setVisible(true); } - if (pane.getPage() == 0 && finalPageAmount == 3) { back.setVisible(false); forward.setVisible(true); } - if (pane.getPage() == 0 && finalPageAmount == 2) { forward.setVisible(false); } @@ -288,16 +376,13 @@ public void loadGUIMAIN(Player player, CommandSender senderpub) { forward.addItem(new GuiItem(new ItemStack(isforward), event -> { pane.setPage(pane.getPage() + 1); forward.setVisible(false); - if (pane.getPage() == 1 && finalPageAmount == 4) { - forward.setVisible(true); - } - if (pane.getPage() == 4 || pane.getPage() == 3) { + if ((pane.getPage() == (finalPageAmount)) || (pane.getPage() == (finalPageAmount)-1) || (pane.getPage() == (finalPageAmount)-2)) { forward.setVisible(false); } - if (pane.getPage() == 0 && finalPageAmount == 2) { - forward.setVisible(false); + else{ + forward.setVisible(true); } back.setVisible(true); diff --git a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneCommand.java b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneCommand.java index af58280..b4bcfc5 100644 --- a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneCommand.java +++ b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneCommand.java @@ -119,6 +119,7 @@ else if (!(player.hasPermission("at.help")) && !(player.isOp())){ TextHandler.noPermssion(player); return true; } + return false; } return false; } diff --git a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java index 0c62e82..a66e2e3 100644 --- a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java +++ b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java @@ -34,6 +34,7 @@ public class AutoTuneGUIShopUserCommand implements CommandExecutor { public static DecimalFormat df1 = new DecimalFormat("###########0.00"); public static DecimalFormat df2 = new DecimalFormat("###,###,###,##0.00"); static DecimalFormat df3 = new DecimalFormat("###,###,###,##0.00000"); + public static DecimalFormat df4 = new DecimalFormat("###########0.0000"); public Economy economy = Main.getEconomy(); @@ -494,13 +495,13 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, }; tempMap2.put(tempMap2Size - 1, tempDArray); Main.map.put(matClickedString, tempMap2); - if (hasAvaliableSlot(player) == true) { + if (hasAvaliableSlot(player) == true && (Main.econ.getBalance(player)) > price) { Main.econ.withdrawPlayer(player, price); player.getInventory().addItem(new ItemStack(Material.matchMaterial(matClickedString), 1)); sendPlayerShopMessageAndUpdateGDP(1, price, player, matClickedString, false); } else { - player.sendMessage(ChatColor.GOLD + "Cannot purchased 1x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price)); - player.sendMessage(ChatColor.GOLD + "Inventory Full!"); + player.sendMessage(ChatColor.GOLD + "Cannot purchase 1x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price)); + } player.setItemOnCursor(null); SBPane.clear(); @@ -525,13 +526,13 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, }; tempMap2.put(tempMap2Size - 1, tempDArray); Main.map.put(matClickedString, tempMap2); - if (hasAvaliableSlot(player) == true) { + if (hasAvaliableSlot(player) == true && Main.econ.getBalance(player) > price) { Main.econ.withdrawPlayer(player, price * 2); player.getInventory().addItem(new ItemStack(Material.matchMaterial(matClickedString), 2)); sendPlayerShopMessageAndUpdateGDP(2, price, player, matClickedString, false); } else { - player.sendMessage(ChatColor.GOLD + "Cannot purchased 2x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price * 2)); - player.sendMessage(ChatColor.GOLD + "Inventory Full!"); + player.sendMessage(ChatColor.GOLD + "Cannot purchase 2x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price * 2)); + } player.setItemOnCursor(null); SBPane.clear(); @@ -556,13 +557,13 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, }; tempMap2.put(tempMap2Size - 1, tempDArray); Main.map.put(matClickedString, tempMap2); - if (hasAvaliableSlot(player) == true) { + if (hasAvaliableSlot(player) == true && Main.econ.getBalance(player) > price) { Main.econ.withdrawPlayer(player, price * 4); player.getInventory().addItem(new ItemStack(Material.matchMaterial(matClickedString), 4)); sendPlayerShopMessageAndUpdateGDP(4, price, player, matClickedString, false); } else { - player.sendMessage(ChatColor.GOLD + "Cannot purchased 4x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price * 4)); - player.sendMessage(ChatColor.GOLD + "Inventory Full!"); + player.sendMessage(ChatColor.GOLD + "Cannot purchase 4x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price * 4)); + } player.setItemOnCursor(null); SBPane.clear(); @@ -586,13 +587,13 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, sellAmount }; tempMap2.put(tempMap2Size - 1, tempDArray); - if (hasAvaliableSlot(player) == true) { + if (hasAvaliableSlot(player) == true && Main.econ.getBalance(player) > price) { Main.econ.withdrawPlayer(player, price * 8); player.getInventory().addItem(new ItemStack(Material.matchMaterial(matClickedString), 8)); sendPlayerShopMessageAndUpdateGDP(8, price, player, matClickedString, false); } else { - player.sendMessage(ChatColor.GOLD + "Cannot purchased 8x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price * 8)); - player.sendMessage(ChatColor.GOLD + "Inventory Full!"); + player.sendMessage(ChatColor.GOLD + "Cannot purchase 8x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price * 8)); + } player.setItemOnCursor(null); SBPane.clear(); @@ -617,13 +618,13 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, }; tempMap2.put(tempMap2Size - 1, tempDArray); Main.map.put(matClickedString, tempMap2); - if (hasAvaliableSlot(player) == true) { + if (hasAvaliableSlot(player) == true && Main.econ.getBalance(player) > price) { Main.econ.withdrawPlayer(player, price * 16); player.getInventory().addItem(new ItemStack(Material.matchMaterial(matClickedString), 16)); sendPlayerShopMessageAndUpdateGDP(16, price, player, matClickedString, false); } else { - player.sendMessage(ChatColor.GOLD + "Cannot purchased 16x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price * 16)); - player.sendMessage(ChatColor.GOLD + "Inventory Full!"); + player.sendMessage(ChatColor.GOLD + "Cannot purchase 16x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price * 16)); + } player.setItemOnCursor(null); SBPane.clear(); @@ -648,13 +649,13 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, }; tempMap2.put(tempMap2Size - 1, tempDArray); Main.map.put(matClickedString, tempMap2); - if (hasAvaliableSlot(player) == true) { + if (hasAvaliableSlot(player) == true && Main.econ.getBalance(player) > price) { Main.econ.withdrawPlayer(player, price * 32); player.getInventory().addItem(new ItemStack(Material.matchMaterial(matClickedString), 32)); sendPlayerShopMessageAndUpdateGDP(32, price, player, matClickedString, false); } else { - player.sendMessage(ChatColor.GOLD + "Cannot purchased 32x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price * 32)); - player.sendMessage(ChatColor.GOLD + "Inventory Full!"); + player.sendMessage(ChatColor.GOLD + "Cannot purchase 32x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price * 32)); + } player.setItemOnCursor(null); SBPane.clear(); @@ -679,13 +680,12 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, }; tempMap2.put(tempMap2Size - 1, tempDArray); Main.map.put(matClickedString, tempMap2); - if (hasAvaliableSlot(player) == true) { + if (hasAvaliableSlot(player) == true && Main.econ.getBalance(player) > price) { Main.econ.withdrawPlayer(player, price * 64); player.getInventory().addItem(new ItemStack(Material.matchMaterial(matClickedString), 64)); sendPlayerShopMessageAndUpdateGDP(64, price, player, matClickedString, false); } else { - player.sendMessage(ChatColor.GOLD + "Cannot purchased 64x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price * 64)); - player.sendMessage(ChatColor.GOLD + "Inventory Full!"); + player.sendMessage(ChatColor.GOLD + "Cannot purchase 64x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price * 64)); } player.setItemOnCursor(null); SBPane.clear(); diff --git a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneLoansCommand.java b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneLoansCommand.java index bf02b08..3059a0c 100644 --- a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneLoansCommand.java +++ b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneLoansCommand.java @@ -38,14 +38,16 @@ public boolean onCommand(CommandSender sender, Command command, String loans, St } if (!loanpresent){ p.sendMessage(ChatColor.RED + "No loans currently active. Do /loan to make a loan"); + return true; } } else if (!(p.hasPermission("at.loan")) && !(p.isOp())){ TextHandler.noPermssion(p); return true; } + return false; } - return true; + return false; } public void sendLoanInfo(Player p, String str){ diff --git a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTunePaybackLoanCommand.java b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTunePaybackLoanCommand.java index 55af90c..5c2e6b7 100644 --- a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTunePaybackLoanCommand.java +++ b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTunePaybackLoanCommand.java @@ -37,31 +37,33 @@ else if (!(p.hasPermission("at.loan")) && !(p.isOp())){ public static void paybackLoan(OfflinePlayer p, String args){ UUID uuid = p.getUniqueId(); - Set set = Main.loanMap.getKeys(); - boolean loaded = false; - for (String str : set){ - if (str.contains(uuid.toString())){ - String lastChar = str.substring(str.length() - 1); - if (lastChar.equals(args)){ - double[] arr = Main.loanMap.get(uuid.toString() + args); - double curVal = arr[0]; - Main.loanMap.remove(uuid.toString() + args); - Main.getEconomy().withdrawPlayer(p, (Math.round(curVal*1000)/1000)); - if (p.isOnline()){ - Player player = (Player)p; - player.sendMessage(ChatColor.YELLOW + "Removed loan No: "+ ChatColor.GREEN + args + ChatColor.YELLOW + ". Withdrew " + ChatColor.GREEN + Config.getCurrencySymbol() + AutoTuneGUIShopUserCommand.df2.format(curVal) + ChatColor.YELLOW + " from your balance."); - } - if (!(p.isOnline())){ - Main.log("Removed loan No: "+ args + ". Withdrew " + Config.getCurrencySymbol() + AutoTuneGUIShopUserCommand.df2.format(curVal) + " from " + p.getName() +"'s balance."); - } - loaded = true; - } - } - } - if (!loaded){ + Set set = Main.loanMap.getKeys(); + boolean loaded = false; + for (String str : set){ + if (str.contains(uuid.toString())){ + String lastChar = str.substring(str.length() - 1); + if (lastChar.equals(args)){ + double[] arr = Main.loanMap.get(uuid.toString() + args); + double curVal = arr[0]; + curVal = Double.parseDouble(AutoTuneGUIShopUserCommand.df4.format(curVal)); + Main.loanMap.remove(uuid.toString() + args); if (p.isOnline()){ Player player = (Player)p; - player.sendMessage(ChatColor.RED + "Loan is not present, do /loans to view your current loans or /loan to make one"); + player.sendMessage(ChatColor.YELLOW + "Removed loan No: "+ ChatColor.GREEN + args + ChatColor.YELLOW + ". Withdrew " + ChatColor.GREEN + Config.getCurrencySymbol() + AutoTuneGUIShopUserCommand.df2.format(curVal) + ChatColor.YELLOW + " from your balance."); + Main.getEconomy().withdrawPlayer(p, (Math.round(curVal*10000)/10000)); + } + else if (!(p.isOnline())){ + Main.log("Removed loan No: "+ args + ". Withdrew " + Config.getCurrencySymbol() + AutoTuneGUIShopUserCommand.df2.format(curVal) + " from " + p.getName() +"'s balance."); + Main.getEconomy().withdrawPlayer(p, (Math.round(curVal*10000)/10000)); + } + loaded = true; + } + } + } + if (!loaded){ + if (p.isOnline()){ + Player player = (Player)p; + player.sendMessage(ChatColor.RED + "Loan is not present, do /loans to view your current loans or /loan to make one"); } } } diff --git a/Auto-Tune/src/unprotesting/com/github/util/CSVHandler.java b/Auto-Tune/src/unprotesting/com/github/util/CSVHandler.java index 9376960..b84092a 100644 --- a/Auto-Tune/src/unprotesting/com/github/util/CSVHandler.java +++ b/Auto-Tune/src/unprotesting/com/github/util/CSVHandler.java @@ -6,6 +6,7 @@ import java.util.concurrent.ConcurrentHashMap; import unprotesting.com.github.Main; +import unprotesting.com.github.Commands.AutoTuneGUIShopUserCommand; public class CSVHandler { @@ -23,7 +24,7 @@ public static void writeCSV() throws InterruptedException, csvWriter.append(","); csvWriter.append("\n"); - for (int i = 0; i > -10; i++) { + for (int i = 0; i > -1; i++) { String k = String.valueOf(i); csvWriter.append(k); Double[] l = (item.get(i)); @@ -70,8 +71,12 @@ public static void writeShortCSV() throws InterruptedException, csvWriter.append("\n"); int size = item.size(); + Main.log(AutoTuneGUIShopUserCommand.df2.format(size)); - for (int i = size-Config.getMaximumShortTradeLength(); i > -10; i++) { + for (int i = size-Config.getMaximumShortTradeLength(); i < size; i++) { + if (i < 0){ + continue; + } String k = String.valueOf(i); csvWriter.append(k); Double[] l = (item.get(i)); diff --git a/Auto-Tune/src/unprotesting/com/github/util/LoanEventHandler.java b/Auto-Tune/src/unprotesting/com/github/util/LoanEventHandler.java index c89a0ff..b15d8f7 100644 --- a/Auto-Tune/src/unprotesting/com/github/util/LoanEventHandler.java +++ b/Auto-Tune/src/unprotesting/com/github/util/LoanEventHandler.java @@ -28,6 +28,12 @@ public void run() { UUID id = UUID.fromString(str2); OfflinePlayer p = Bukkit.getOfflinePlayer(id); double totalLoanVal = AutoTuneLoanCommand.getTotalLoanValue(p); + try { + Double a = Main.getEconomy().getBalance(p); + } + catch(IllegalArgumentException e){ + continue; + } if ((Main.getEconomy().getBalance(p) - totalLoanVal) < Config.getMaxDebt()){ for (String str : set){ if (str.contains(id.toString())){ diff --git a/Auto-Tune/src/unprotesting/com/github/util/MaterialUtil.java b/Auto-Tune/src/unprotesting/com/github/util/MaterialUtil.java index aa6244c..0cddae3 100644 --- a/Auto-Tune/src/unprotesting/com/github/util/MaterialUtil.java +++ b/Auto-Tune/src/unprotesting/com/github/util/MaterialUtil.java @@ -29,7 +29,6 @@ public static Material[] matchMaterials(final String... names) { } public static Material[] MatchInputToSet(String input) { - int i = 0; input = input.toLowerCase(); if (input.equals("air") || input.equals("water") || input.equals("lava")){ return null; @@ -40,7 +39,6 @@ public static Material[] MatchInputToSet(String input) { if (input.equals(str)){ return new Material[] {mat}; } - i++; } Material output = Material.matchMaterial((input.toUpperCase())); if (output != null){ diff --git a/README.md b/README.md index b424b88..3cda3d1 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ An example of a shop setup using Auto-Tune: - Exponential contains 7 pricing model options. [Volatility Options and algorithim, data-selection-algorithim, and more] - 2 forced-inflation methods with individual options [Dynamic and Static Inflation, configurable update periods] - 2 integrated web-servers to display prices online in graphs [Server port settings and more] - - Configurable GUI with sizing and naming options [80+ supported item-slots] + - Configurable GUI with sizing and naming options - Config settings can easily be modified with an in-built GUI editor - Configurable shops with options to lock price and sell-price-differences [For more look at shops.yml configuration below] - Configurable sell-price-difference