From f257bc78721634e4c90b0719baa84a6ab6296961 Mon Sep 17 00:00:00 2001 From: "Noah Clarkson (Unprotesting)" Date: Sun, 3 Jan 2021 18:00:24 +0000 Subject: [PATCH] Fixed more bugs + Fixed buying enchantments when item isn't in the shop + Fixed shop not paginating properly when items in section were less than (pane-size + 7) + Improved getting item price data locally + Improved some default values + Updated to 0.12.3 --- Auto-Tune/dependency-reduced-pom.xml | 2 +- Auto-Tune/pom.xml | 2 +- Auto-Tune/src/resources/config.yml | 10 ++-- Auto-Tune/src/resources/enchantments.yml | 54 +++++++++---------- .../github/Commands/AutoTuneBuyCommand.java | 8 ++- .../Commands/AutoTuneGUIShopUserCommand.java | 34 ++++++++---- .../com/github/util/EnchantmentAlgorithm.java | 9 ++-- 7 files changed, 70 insertions(+), 49 deletions(-) diff --git a/Auto-Tune/dependency-reduced-pom.xml b/Auto-Tune/dependency-reduced-pom.xml index ea06b8a..06237cb 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.12.2 + 0.12.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 2bb4f5c..62b21f0 100644 --- a/Auto-Tune/pom.xml +++ b/Auto-Tune/pom.xml @@ -9,7 +9,7 @@ unprotesting.com.github Auto-Tune - 0.12.2 + 0.12.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 a1ed9cd..8877683 100644 --- a/Auto-Tune/src/resources/config.yml +++ b/Auto-Tune/src/resources/config.yml @@ -99,10 +99,10 @@ currency-symbol: '$' sell-price-difference-variation-enabled: true ## Starting percententage sell price difference for sell price variation -sell-price-difference-variation-start: 22.5 +sell-price-difference-variation-start: 25 -## 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 until sell price reaches sell-price-difference set in pricing model settings (default 4 weeks) +sell-price-variation-time-period: 43200 ## Time in minutes that the sell-price-difference updates ## Info: Must be a factor of sell-price-variation-time-period or it won't work! @@ -128,11 +128,11 @@ static-inflation-value: 0.1 ## Intrest rate per interest-rate-update-period ## Info: This is the increase in the current debt payment per-time period -interest-rate: 0.005 +interest-rate: 0.0075 ## Intrest rate for compound-intrest loans ## Info: Compound interest loans grow faster so should have a lower initial interest rate -compound-interest-rate: 0.0025 +compound-interest-rate: 0.005 ## Time period in ticks between updates of the interest rate for users loans interest-rate-update-period: 1200 diff --git a/Auto-Tune/src/resources/enchantments.yml b/Auto-Tune/src/resources/enchantments.yml index 0bb28e0..bd5793b 100644 --- a/Auto-Tune/src/resources/enchantments.yml +++ b/Auto-Tune/src/resources/enchantments.yml @@ -54,109 +54,109 @@ enchantments: ## Increases the rate at which you mine/dig DURABILITY: price: 850.00 - ratio: 0.85 + ratio: 0.425 ## Decreases the rate at which a tool looses durability FIRE_ASPECT: price: 1000.00 - ratio: 0.9 + ratio: 0.45 ## When attacking a target, has a chance to set them on fire FROST_WALKER: price: 1100.00 - ratio: 1.0 + ratio: 0.5 ## Freezes any still water adjacent to ice / frost which player is walking on IMPALING: price: 650.00 - ratio: 0.8 + ratio: 0.4 ## Deals more damage to mobs that live in the ocean KNOCKBACK: price: 975.00 - ratio: 0.8 + ratio: 0.4 ## All damage to other targets will knock them back when hit LOOT_BONUS_BLOCKS: price: 1250.00 - ratio: 1.45 + ratio: 0.725 ## Provides a chance of gaining extra loot when destroying blocks LOOT_BONUS_MOBS: price: 1200.00 - ratio: 1.35 + ratio: 0.65 ## Provides a chance of gaining extra loot when killing monsters LOYALTY: price: 1100.00 - ratio: 0.8 + ratio: 0.4 ## Causes a thrown trident to return to the player who threw it LUCK: price: 750.00 - ratio: 1.2 + ratio: 0.6 ## Decreases odds of catching worthless junk LURE: price: 550.00 - ratio: 0.5 + ratio: 0.25 ## Increases rate of fish biting your hook MENDING: price: 4000.00 - ratio: 2.25 + ratio: 1.1 ## Allows mending the item using experience orbs MULTISHOT: price: 800.00 - ratio: 0.8 + ratio: 0.4 ## Shoot multiple arrows from crossbows OXYGEN: price: 600.00 - ratio: 0.7 + ratio: 0.35 ## Decreases the rate of air loss whilst underwater PIERCING: price: 750.00 - ratio: 0.8 + ratio: 0.4 ## Crossbow projectiles pierce entities PROTECTION_ENVIRONMENTAL: price: 900.00 - ratio: 0.8 + ratio: 0.4 ## Provides protection against environmental damage PROTECTION_EXPLOSIONS: price: 950.00 - ratio: 0.85 + ratio: 0.425 ## Provides protection against explosive damage PROTECTION_FALL: price: 950.00 - ratio: 0.85 + ratio: 0.425 ## Provides protection against fall damage PROTECTION_FIRE: price: 950.00 - ratio: 0.8 + ratio: 0.4 ## Provides protection against fire damage PROTECTION_PROJECTILE: price: 950.00 - ratio: 0.85 + ratio: 0.425 ## Provides protection against projectile damage QUICK_CHARGE: price: 800.00 - ratio: 0.85 + ratio: 0.425 ## Charges crossbows quickly RIPTIDE: price: 1050.00 - ratio: 0.8 + ratio: 0.4 ## When it is rainy, launches the player in the direction their trident is thrown SILK_TOUCH: price: 1300.00 - ratio: 1.2 + ratio: 0.6 ## Allows blocks to drop themselves instead of fragments (for example, stone instead of cobblestone) SOUL_SPEED: price: 1450.00 - ratio: 1.5 + ratio: 0.75 ## Walk quicker on soul blocks SWEEPING_EDGE: price: 1900.00 - ratio: 0.9 + ratio: 0.4 ## Increases damage against targets when using a sweep attack THORNS: price: 1600.00 - ratio: 1.25 + ratio: 0.6 ## Damages the attacker VANISHING_CURSE: price: 50.00 - ratio: 0.3 + ratio: 0.15 ## Item disappears instead of dropping WATER_WORKER: price: 800.00 - ratio: 0.85 + ratio: 0.45 ## Increases the speed at which a player may mine underwater \ No newline at end of file diff --git a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneBuyCommand.java b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneBuyCommand.java index d30bfa8..90a744f 100644 --- a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneBuyCommand.java +++ b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneBuyCommand.java @@ -84,7 +84,13 @@ public boolean onCommand(CommandSender sender, Command command, String label, St ex.printStackTrace(); return true; } - double price = setting.price + Main.map.get(is.getType().toString()).get(Main.map.get(is.getType().toString()).size()-1)[0]*setting.ratio; + double price = setting.price; + try{ + price = setting.price + AutoTuneGUIShopUserCommand.getItemPrice(is.getType().toString(), false)*setting.ratio; + } + catch(NullPointerException e){ + price = setting.price; + } Main.getEconomy().withdrawPlayer(player, Double.parseDouble(AutoTuneGUIShopUserCommand.df1.format(price))); player.sendMessage(ChatColor.GOLD + "Purchased " + setting.name + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + AutoTuneGUIShopUserCommand.df2.format(price)); diff --git a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java index 5573da0..3ad0cc0 100644 --- a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java +++ b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java @@ -141,7 +141,7 @@ public static void loadGUIMAIN(Player player, Section sec, boolean twoArgs, bool } Gui main = new Gui((lines + 2), Config.getMenuTitle()); Integer paneSize = (lines + 1) * 7; - Integer paneAmount = (int) Math.ceil(itemAmount / paneSize) + 1; + Integer paneAmount = (int) Math.ceil((itemAmount+7) / paneSize) + 1; PaginatedPane pPane = new PaginatedPane(0, 0, 9, (lines + 2)); OutlinePane[] shopPanes = new OutlinePane[paneAmount]; for (int i = 0; i < shopPanes.length; i++) { @@ -459,26 +459,38 @@ public double getSellPriceDifference(String item) { } public static Double getItemPrice(String item, boolean sell) { + Double output = 0.0; if (!sell) { - Double output = Main.getItemPrices().get(item).price; - if (output != null){ + try{ + output = Main.getItemPrices().get(item).price; return output; } - else{ + catch(NullPointerException e){ ConcurrentHashMap map = Main.map.get(item); - output = map.get(map.size()-1)[0]; - return output; + try{ + output = map.get(map.size()-1)[0]; + return output; + } + catch(NullPointerException e2){ + return null; + } + } } else { - Double output = Main.getItemPrices().get(item).sellPrice; - if (output != null){ + try{ + output = Main.getItemPrices().get(item).sellPrice; return output; } - else{ + catch(NullPointerException e){ ConcurrentHashMap map = Main.map.get(item); output = map.get(map.size()-1)[0]; - output = output - output*0.01*getSellDifference(item); - return output; + try{ + output = output - output*0.01*getSellDifference(item); + return output; + } + catch(NullPointerException e2){ + return null; + } } } } diff --git a/Auto-Tune/src/unprotesting/com/github/util/EnchantmentAlgorithm.java b/Auto-Tune/src/unprotesting/com/github/util/EnchantmentAlgorithm.java index b1f2e75..ba4794d 100644 --- a/Auto-Tune/src/unprotesting/com/github/util/EnchantmentAlgorithm.java +++ b/Auto-Tune/src/unprotesting/com/github/util/EnchantmentAlgorithm.java @@ -8,6 +8,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import unprotesting.com.github.Main; +import unprotesting.com.github.Commands.AutoTuneGUIShopUserCommand; public class EnchantmentAlgorithm { @@ -39,10 +40,12 @@ public static void loadEnchantmentSettings() { public static double calculatePriceWithEnch(ItemStack is, boolean buy) { ItemMeta iMeta = is.getItemMeta(); Map enchants = iMeta.getEnchants(); - ConcurrentHashMap inMap = Main.map.get(is.getType().toString()); double price = 0.0; - if (inMap != null) { - price = inMap.get(inMap.size() - 1)[0]; + try{ + price = AutoTuneGUIShopUserCommand.getItemPrice(is.getType().toString(), !buy); + } + catch(NullPointerException e){ + price = 0.0; } double cachePrice = 0; for (Map.Entry ench : enchants.entrySet()) {