diff --git a/Auto-Tune/dependency-reduced-pom.xml b/Auto-Tune/dependency-reduced-pom.xml index 4830f92..f2343b2 100644 --- a/Auto-Tune/dependency-reduced-pom.xml +++ b/Auto-Tune/dependency-reduced-pom.xml @@ -4,7 +4,7 @@ <groupId>unprotesting.com.github</groupId> <artifactId>Auto-Tune</artifactId> <name>Auto-Tune</name> - <version>0.12.0-pre-release-5</version> + <version>0.12.0-pre-release-6</version> <description>The automatic pricing plugin for minecraft</description> <url>https://github.com/Unprotesting/Auto-Tune</url> <issueManagement> diff --git a/Auto-Tune/pom.xml b/Auto-Tune/pom.xml index a5975c6..9f0cae2 100644 --- a/Auto-Tune/pom.xml +++ b/Auto-Tune/pom.xml @@ -9,7 +9,7 @@ <!-- Project information --> <groupId>unprotesting.com.github</groupId> <artifactId>Auto-Tune</artifactId> - <version>0.12.0-pre-release-5</version> + <version>0.12.0-pre-release-6</version> <!-- Info --> <name>Auto-Tune</name> <url>https://github.com/Unprotesting/Auto-Tune</url> diff --git a/Auto-Tune/src/unprotesting/com/github/Main.java b/Auto-Tune/src/unprotesting/com/github/Main.java index 1fefe5a..302b911 100644 --- a/Auto-Tune/src/unprotesting/com/github/Main.java +++ b/Auto-Tune/src/unprotesting/com/github/Main.java @@ -275,7 +275,7 @@ public void onEnable() { debugLog("Loaded " + enchMap.get("Auto-Tune").size() + " enchantments"); AutoTuneBuyCommand.shopTypes.add("enchantments"); loadItemPriceData(); - scheduler.scheduleAsyncRepeatingTask(this, new EnchantmentPriceHandler(), 1200*Config.getTimePeriod(), (Config.getTimePeriod()*1200)); + scheduler.scheduleAsyncRepeatingTask(this, new EnchantmentPriceHandler(), 1200*Config.getTimePeriod(), (Config.getTimePeriod()*3600)); } private boolean setupEconomy() { diff --git a/Auto-Tune/src/unprotesting/com/github/util/EnchantmentPriceHandler.java b/Auto-Tune/src/unprotesting/com/github/util/EnchantmentPriceHandler.java index 886d435..351312e 100644 --- a/Auto-Tune/src/unprotesting/com/github/util/EnchantmentPriceHandler.java +++ b/Auto-Tune/src/unprotesting/com/github/util/EnchantmentPriceHandler.java @@ -2,6 +2,7 @@ import java.util.concurrent.ConcurrentHashMap; +import org.bukkit.Bukkit; import org.json.simple.parser.ParseException; import unprotesting.com.github.Main; @@ -11,21 +12,23 @@ public class EnchantmentPriceHandler implements Runnable { @Override public void run() { Main.debugLog("Loading Enchantment Price Update Algorithm"); - for (String str : Main.enchMap.get("Auto-Tune").keySet()) { - ConcurrentHashMap<String, EnchantmentSetting> inputMap = Main.enchMap.get("Auto-Tune"); - EnchantmentSetting setting = inputMap.get(str); - ConcurrentHashMap<Integer, Double[]> buySellMap = setting.buySellData; - try { - buySellMap = EnchantmentAlgorithm.loadAverageBuyAndSellValue(buySellMap, setting); - } catch (ParseException e) { - e.printStackTrace(); + Integer playerCount = Bukkit.getServer().getOnlinePlayers().size(); + if (Config.isUpdatePricesWhenInactive() || (!Config.isUpdatePricesWhenInactive() && playerCount > 0)){ + for (String str : Main.enchMap.get("Auto-Tune").keySet()) { + ConcurrentHashMap<String, EnchantmentSetting> inputMap = Main.enchMap.get("Auto-Tune"); + EnchantmentSetting setting = inputMap.get(str); + ConcurrentHashMap<Integer, Double[]> buySellMap = setting.buySellData; + try { + buySellMap = EnchantmentAlgorithm.loadAverageBuyAndSellValue(buySellMap, setting); + } catch (ParseException e) { + e.printStackTrace(); + } + setting.buySellData = buySellMap; + Double[] arr = buySellMap.get(buySellMap.size()-1); + setting.price = arr[0]; + inputMap.put(setting.name, setting); + Main.enchMap.put("Auto-Tune", inputMap); } - setting.buySellData = buySellMap; - Double[] arr = buySellMap.get(buySellMap.size()-1); - setting.price = arr[0]; - inputMap.put(setting.name, setting); - Main.enchMap.put("Auto-Tune", inputMap); } - } - + } }