Skip to content

Commit

Permalink
Hot patch for server issues by limiting enchantment price calculator
Browse files Browse the repository at this point in the history
+ Hot Patch for server issues by limiting enchantment price calculator and not requesting info at the correct times
  • Loading branch information
noahbclarkson committed Dec 18, 2020
1 parent ed16072 commit 3cb1b6b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Auto-Tune/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion Auto-Tune/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion Auto-Tune/src/unprotesting/com/github/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.concurrent.ConcurrentHashMap;

import org.bukkit.Bukkit;
import org.json.simple.parser.ParseException;

import unprotesting.com.github.Main;
Expand All @@ -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);
}
}

}
}

0 comments on commit 3cb1b6b

Please sign in to comment.