aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMoulberry <james.jenour@student.scotch.wa.edu.au>2020-07-29 12:21:03 +1000
committerMoulberry <james.jenour@student.scotch.wa.edu.au>2020-07-29 12:21:03 +1000
commit6115246bf36fb98037ca0df2faac869eba7845c3 (patch)
tree4e659cf3d0bae323346ef251c995179c490c1115 /src
parent9716e11a253a370e16dd1f0bdfdd70ac21ee4102 (diff)
downloadNotEnoughUpdates-6115246bf36fb98037ca0df2faac869eba7845c3.tar.gz
NotEnoughUpdates-6115246bf36fb98037ca0df2faac869eba7845c3.tar.bz2
NotEnoughUpdates-6115246bf36fb98037ca0df2faac869eba7845c3.zip
1.11.10.5
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java189
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java71
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java170
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/Options.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java166
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java16
-rw-r--r--src/main/resources/assets/notenoughupdates/pv_pets.pngbin3420 -> 4370 bytes
9 files changed, 375 insertions, 249 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index ffd57b41..14dc61fb 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -21,6 +21,7 @@ import org.lwjgl.opengl.Display;
import javax.swing.*;
import java.io.*;
import java.net.URL;
+import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.ExecutorService;
@@ -367,121 +368,139 @@ public class NEUManager {
* repository.
*/
public void loadItemInformation() {
- try {
- if(config.autoupdate.value) {
- JOptionPane pane = new JOptionPane("Getting items to download from remote repository.");
- JDialog dialog = pane.createDialog("NotEnoughUpdates Remote Sync");
- dialog.setModal(false);
- //dialog.setVisible(true);
+ Thread thread = new Thread(() -> {
+ try {
+ if(config.autoupdate.value) {
+ JOptionPane pane = new JOptionPane("Getting items to download from remote repository.");
+ JDialog dialog = pane.createDialog("NotEnoughUpdates Remote Sync");
+ dialog.setModal(false);
+ //dialog.setVisible(true);
- if (Display.isActive()) dialog.toFront();
+ if (Display.isActive()) dialog.toFront();
- HashMap<String, String> oldShas = new HashMap<>();
- for (Map.Entry<String, JsonElement> entry : itemShaConfig.entrySet()) {
- if (new File(repoLocation, entry.getKey() + ".json").exists()) {
- oldShas.put(entry.getKey() + ".json", entry.getValue().getAsString());
+ HashMap<String, String> oldShas = new HashMap<>();
+ for (Map.Entry<String, JsonElement> entry : itemShaConfig.entrySet()) {
+ if (new File(repoLocation, entry.getKey() + ".json").exists()) {
+ oldShas.put(entry.getKey() + ".json", entry.getValue().getAsString());
+ }
}
- }
- Map<String, String> changedFiles = neuio.getChangedItems(oldShas);
+ Map<String, String> changedFiles = neuio.getChangedItems(oldShas);
- if (changedFiles != null) {
- for (Map.Entry<String, String> changedFile : changedFiles.entrySet()) {
- itemShaConfig.addProperty(changedFile.getKey().substring(0, changedFile.getKey().length() - 5),
- changedFile.getValue());
- }
- try {
- writeJson(itemShaConfig, itemShaLocation);
- } catch (IOException e) {
- }
- }
- if (Display.isActive()) dialog.toFront();
- if (changedFiles != null && changedFiles.size() <= 20) {
- String startMessage = "NotEnoughUpdates: Syncing with remote repository (";
- int downloaded = 0;
+ if (Display.isActive()) dialog.toFront();
+
+ if (changedFiles != null && changedFiles.size() <= 20) {
+ String startMessage = "NotEnoughUpdates: Syncing with remote repository (";
+ int downloaded = 0;
+
+ String dlUrl = "https://raw.githubusercontent.com/Moulberry/NotEnoughUpdates-REPO/master/";
+
+ for (String name : changedFiles.keySet()) {
+ pane.setMessage(startMessage + (++downloaded) + "/" + changedFiles.size() + ")\nCurrent: " + name);
+ dialog.pack();
+ //dialog.setVisible(true);
+ if (Display.isActive()) dialog.toFront();
+
+ File item = new File(repoLocation, name);
+ try {
+ item.getParentFile().mkdirs();
+ item.createNewFile();
+ } catch (IOException e) {
+ continue;
+ }
+ URL url = new URL(dlUrl+name);
+ URLConnection urlConnection = url.openConnection();
+ urlConnection.setConnectTimeout(3000);
+ urlConnection.setReadTimeout(3000);
+ try (BufferedInputStream inStream = new BufferedInputStream(urlConnection.getInputStream());
+ FileOutputStream fileOutputStream = new FileOutputStream(item)) {
+ byte dataBuffer[] = new byte[1024];
+ int bytesRead;
+ while ((bytesRead = inStream.read(dataBuffer, 0, 1024)) != -1) {
+ fileOutputStream.write(dataBuffer, 0, bytesRead);
+ }
+ itemShaConfig.addProperty(name.substring(0, name.length() - 5),
+ changedFiles.get(name));
+ } catch (IOException e) {
+ }
+ }
+ try {
+ writeJson(itemShaConfig, itemShaLocation);
+ } catch (IOException e) {
+ }
+ } else {
+ Utils.recursiveDelete(repoLocation);
+ repoLocation.mkdirs();
- String dlUrl = "https://raw.githubusercontent.com/Moulberry/NotEnoughUpdates-REPO/master/";
+ //TODO: Store hard-coded value somewhere else
+ String dlUrl = "https://github.com/Moulberry/NotEnoughUpdates-REPO/archive/master.zip";
- for (String name : changedFiles.keySet()) {
- pane.setMessage(startMessage + (++downloaded) + "/" + changedFiles.size() + ")\nCurrent: " + name);
+ pane.setMessage("Downloading NEU Master Archive. (DL# >20)");
dialog.pack();
- dialog.setVisible(true);
+ //dialog.setVisible(true);
if (Display.isActive()) dialog.toFront();
- File item = new File(repoLocation, name);
+ File itemsZip = new File(repoLocation, "neu-items-master.zip");
try {
- item.getParentFile().mkdirs();
- item.createNewFile();
+ itemsZip.createNewFile();
} catch (IOException e) {
+ return;
}
- try (BufferedInputStream inStream = new BufferedInputStream(new URL(dlUrl+name).openStream());
- FileOutputStream fileOutputStream = new FileOutputStream(item)) {
+ try (BufferedInputStream inStream = new BufferedInputStream(new URL(dlUrl).openStream());
+ FileOutputStream fileOutputStream = new FileOutputStream(itemsZip)) {
byte dataBuffer[] = new byte[1024];
int bytesRead;
while ((bytesRead = inStream.read(dataBuffer, 0, 1024)) != -1) {
fileOutputStream.write(dataBuffer, 0, bytesRead);
}
} catch (IOException e) {
+ return;
}
- }
- } else {
- Utils.recursiveDelete(repoLocation);
- repoLocation.mkdirs();
- //TODO: Store hard-coded value somewhere else
- String dlUrl = "https://github.com/Moulberry/NotEnoughUpdates-REPO/archive/master.zip";
+ pane.setMessage("Unzipping NEU Master Archive.");
+ dialog.pack();
+ //dialog.setVisible(true);
+ if (Display.isActive()) dialog.toFront();
- pane.setMessage("Downloading NEU Master Archive. (DL# >20)");
- dialog.pack();
- dialog.setVisible(true);
- if (Display.isActive()) dialog.toFront();
+ unzipIgnoreFirstFolder(itemsZip.getAbsolutePath(), repoLocation.getAbsolutePath());
- File itemsZip = new File(repoLocation, "neu-items-master.zip");
- try {
- itemsZip.createNewFile();
- } catch (IOException e) {
- }
- try (BufferedInputStream inStream = new BufferedInputStream(new URL(dlUrl).openStream());
- FileOutputStream fileOutputStream = new FileOutputStream(itemsZip)) {
- byte dataBuffer[] = new byte[1024];
- int bytesRead;
- while ((bytesRead = inStream.read(dataBuffer, 0, 1024)) != -1) {
- fileOutputStream.write(dataBuffer, 0, bytesRead);
+ if (changedFiles != null) {
+ for (Map.Entry<String, String> changedFile : changedFiles.entrySet()) {
+ itemShaConfig.addProperty(changedFile.getKey().substring(0, changedFile.getKey().length() - 5),
+ changedFile.getValue());
+ }
+ try {
+ writeJson(itemShaConfig, itemShaLocation);
+ } catch (IOException e) {
+ }
}
- } catch (IOException e) {
- e.printStackTrace();
}
- pane.setMessage("Unzipping NEU Master Archive.");
- dialog.pack();
- dialog.setVisible(true);
- if (Display.isActive()) dialog.toFront();
-
- unzipIgnoreFirstFolder(itemsZip.getAbsolutePath(), repoLocation.getAbsolutePath());
+ dialog.dispose();
}
+ } catch(Exception e) {}
- dialog.dispose();
+ Set<String> currentlyInstalledItems = new HashSet<>();
+ for(File f : new File(repoLocation, "items").listFiles()) {
+ currentlyInstalledItems.add(f.getName().substring(0, f.getName().length()-5));
}
- } catch(Exception e) {}
- Set<String> currentlyInstalledItems = new HashSet<>();
- for(File f : new File(repoLocation, "items").listFiles()) {
- currentlyInstalledItems.add(f.getName().substring(0, f.getName().length()-5));
- }
-
- Set<String> removedItems;
- if(config.autoupdate.value) {
- removedItems = neuio.getRemovedItems(currentlyInstalledItems);
- } else {
- removedItems = new HashSet<>();
- }
- for(File f : new File(repoLocation, "items").listFiles()) {
- String internalname = f.getName().substring(0, f.getName().length()-5);
- if(!removedItems.contains(internalname)) {
- loadItem(internalname);
+ Set<String> removedItems;
+ if(config.autoupdate.value) {
+ removedItems = neuio.getRemovedItems(currentlyInstalledItems);
+ } else {
+ removedItems = new HashSet<>();
}
- }
+ for(File f : new File(repoLocation, "items").listFiles()) {
+ String internalname = f.getName().substring(0, f.getName().length()-5);
+ if(!removedItems.contains(internalname)) {
+ loadItem(internalname);
+ }
+ }
+ });
+
+ thread.start();
}
/**
@@ -1408,7 +1427,7 @@ public class NEUManager {
for(Map.Entry<String, JsonElement> entry : max.get("statNums").getAsJsonObject().entrySet()) {
int statMax = (int)Math.floor(entry.getValue().getAsFloat());
int statMin = (int)Math.floor(min.get("statNums").getAsJsonObject().get(entry.getKey()).getAsFloat());
- String statStr = "+"+statMin+"\u27A1"+statMax;
+ String statStr = (statMin>0?"+":"")+statMin+"\u27A1"+statMax;
replacements.put(entry.getKey(), statStr);
}
} else {
@@ -1426,7 +1445,7 @@ public class NEUManager {
float statMax = entry.getValue().getAsFloat();
float statMin = min.get("statNums").getAsJsonObject().get(entry.getKey()).getAsFloat();
float val = statMin*minMix + statMax*maxMix;
- String statStr = "+"+(int)Math.floor(val);
+ String statStr = (statMin>0?"+":"")+(int)Math.floor(val);
replacements.put(entry.getKey(), statStr);
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index f5475123..9e4e851a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -411,6 +411,7 @@ public class NotEnoughUpdates {
return true;
} catch(Exception ignored) {}
+ return true;
}
return false;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
index 07c21304..ea6d2f9f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
@@ -19,6 +19,8 @@ import net.minecraft.util.EnumChatFormatting;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
public class APIManager {
@@ -142,23 +144,25 @@ public class APIManager {
}
public void tick() {
+ if(manager.config.disableAH.value || manager.config.apiKey.value == null || manager.config.apiKey.value.isEmpty()) return;
+
customAH.tick();
long currentTime = System.currentTimeMillis();
if(currentTime - lastPageUpdate > 5*1000) {
- lastPageUpdate = System.currentTimeMillis();
+ lastPageUpdate = currentTime;
updatePageTick();
ahNotification();
}
- if(currentTime - lastProfileUpdate > 10*1000) {
+ /*if(currentTime - lastProfileUpdate > 10*1000) {
lastProfileUpdate = System.currentTimeMillis();
updateProfiles(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""));
- }
+ }*/
if(currentTime - lastCleanup > 120*1000) {
- lastCleanup = System.currentTimeMillis();
+ lastCleanup = currentTime;
cleanup();
}
if(currentTime - lastCustomAHSearch > 60*1000) {
- lastCustomAHSearch = System.currentTimeMillis();
+ lastCustomAHSearch = currentTime;
if(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || customAH.isRenderOverAuctionView()) {
customAH.updateSearch();
calculateStats();
@@ -263,38 +267,41 @@ public class APIManager {
}
}
+ private ExecutorService es = Executors.newSingleThreadExecutor();
private void cleanup() {
- try {
- long currTime = System.currentTimeMillis();
- Set<String> toRemove = new HashSet<>();
- for(Map.Entry<String, Auction> entry : auctionMap.entrySet()) {
- long timeToEnd = entry.getValue().end - currTime;
- if(timeToEnd < -60) {
- toRemove.add(entry.getKey());
- } else if(currTime - entry.getValue().lastUpdate > 5*60*1000) {
- toRemove.add(entry.getKey());
+ es.submit(() -> {
+ try {
+ long currTime = System.currentTimeMillis();
+ Set<String> toRemove = new HashSet<>();
+ for(Map.Entry<String, Auction> entry : auctionMap.entrySet()) {
+ long timeToEnd = entry.getValue().end - currTime;
+ if(timeToEnd < -60) {
+ toRemove.add(entry.getKey());
+ } else if(currTime - entry.getValue().lastUpdate > 5*60*1000) {
+ toRemove.add(entry.getKey());
+ }
}
- }
- toRemove.removeAll(playerBids);
- for(String aucid : toRemove) {
- auctionMap.remove(aucid);
- }
- for(HashMap<Integer, HashSet<String>> extrasMap : extrasToAucIdMap.values()) {
- for(HashSet<String> aucids : extrasMap.values()) {
- for(String aucid : toRemove) {
- aucids.remove(aucid);
+ toRemove.removeAll(playerBids);
+ for(String aucid : toRemove) {
+ auctionMap.remove(aucid);
+ }
+ for(HashMap<Integer, HashSet<String>> extrasMap : extrasToAucIdMap.values()) {
+ for(HashSet<String> aucids : extrasMap.values()) {
+ for(String aucid : toRemove) {
+ aucids.remove(aucid);
+ }
}
}
+ for(HashSet<String> aucids : internalnameToAucIdMap.values()) {
+ aucids.removeAll(toRemove);
+ }
+ for(TreeMap<Integer, String> lowestBINs : internalnameToLowestBIN.values()) {
+ lowestBINs.values().removeAll(toRemove);
+ }
+ } catch(ConcurrentModificationException e) {
+ lastCleanup = System.currentTimeMillis() - 110*1000;
}
- for(HashSet<String> aucids : internalnameToAucIdMap.values()) {
- aucids.removeAll(toRemove);
- }
- for(TreeMap<Integer, String> lowestBINs : internalnameToLowestBIN.values()) {
- lowestBINs.values().removeAll(toRemove);
- }
- } catch(ConcurrentModificationException e) {
- cleanup();
- }
+ });
}
private void updatePageTick() {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
index 2bbabd64..f7409c97 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
@@ -34,6 +34,8 @@ import java.awt.datatransfer.StringSelection;
import java.text.NumberFormat;
import java.util.*;
import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -1038,109 +1040,107 @@ public class CustomAH extends Gui {
return matches;
}
+ private ExecutorService es = Executors.newSingleThreadExecutor();
public void updateSearch() {
if(searchField == null || priceField == null) init();
+ long currentTime = System.currentTimeMillis();
- /*if(searchField.getText().length() > 0 && searchField.getText().length() <= 2 &&
- System.currentTimeMillis() - lastSearchFieldUpdate < 200) {
- shouldUpdateSearch = true;
- return;
- }*/
-
- if(System.currentTimeMillis() - lastUpdateSearch < 500) {
- shouldUpdateSearch = true;
- return;
- }
+ es.submit(() -> {
+ if(currentTime - lastUpdateSearch < 500) {
+ shouldUpdateSearch = true;
+ return;
+ }
- lastUpdateSearch = System.currentTimeMillis();
- shouldUpdateSearch = false;
+ lastUpdateSearch = currentTime;
+ shouldUpdateSearch = false;
- scrollAmount = 0;
- try {
- auctionIds.clear();
- if(filterMyAuctions) {
- for(String aucid : manager.auctionManager.getPlayerBids()) {
- APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid);
- if(doesAucMatch(auc)) {
- auctionIds.add(aucid);
- }
- }
- } else if(searchField.getText().length() == 0) {
- for(Map.Entry<String, APIManager.Auction> entry : manager.auctionManager.getAuctionItems().entrySet()) {
- if(doesAucMatch(entry.getValue())) {
- auctionIds.add(entry.getKey());
+ scrollAmount = 0;
+ try {
+ auctionIds.clear();
+ if(filterMyAuctions) {
+ for(String aucid : manager.auctionManager.getPlayerBids()) {
+ APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid);
+ if(doesAucMatch(auc)) {
+ auctionIds.add(aucid);
+ }
}
- }
- } else {
- String query = searchField.getText();
- Set<String> dontMatch = new HashSet<>();
-
- HashSet<String> allMatch = new HashSet<>();
- if(query.contains("!")) { //only used for inverted queries, so dont need to populate unless ! in query
+ } else if(searchField.getText().length() == 0) {
for(Map.Entry<String, APIManager.Auction> entry : manager.auctionManager.getAuctionItems().entrySet()) {
if(doesAucMatch(entry.getValue())) {
- allMatch.add(entry.getKey());
- } else {
- dontMatch.add(entry.getKey());
+ auctionIds.add(entry.getKey());
}
}
- }
-
- boolean invert = false;
-
- StringBuilder query2 = new StringBuilder();
- char lastOp = '|';
- for(char c : query.toCharArray()) {
- if(query2.toString().trim().isEmpty() && c == '!') {
- invert = true;
- } else if(c == '|' || c == '&') {
- if(lastOp == '|') {
- HashSet<String> result = search(query2.toString(), dontMatch);
- if(!invert) {
- auctionIds.addAll(result);
- } else {
- HashSet<String> allClone = (HashSet<String>) allMatch.clone();
- allClone.removeAll(result);
- auctionIds.addAll(allClone);
- }
- } else if(lastOp == '&') {
- HashSet<String> result = search(query2.toString(), dontMatch);
- if(!invert) {
- auctionIds.retainAll(result);
+ } else {
+ String query = searchField.getText();
+ Set<String> dontMatch = new HashSet<>();
+
+ HashSet<String> allMatch = new HashSet<>();
+ if(query.contains("!")) { //only used for inverted queries, so dont need to populate unless ! in query
+ for(Map.Entry<String, APIManager.Auction> entry : manager.auctionManager.getAuctionItems().entrySet()) {
+ if(doesAucMatch(entry.getValue())) {
+ allMatch.add(entry.getKey());
} else {
- auctionIds.removeAll(result);
+ dontMatch.add(entry.getKey());
}
}
-
- query2 = new StringBuilder();
- invert = false;
- lastOp = c;
- } else {
- query2.append(c);
}
- }
- if(lastOp == '|') {
- HashSet<String> result = search(query2.toString(), dontMatch);
- if(!invert) {
- auctionIds.addAll(result);
- } else {
- HashSet<String> allClone = (HashSet<String>) allMatch.clone();
- allClone.removeAll(result);
- auctionIds.addAll(allClone);
+
+ boolean invert = false;
+
+ StringBuilder query2 = new StringBuilder();
+ char lastOp = '|';
+ for(char c : query.toCharArray()) {
+ if(query2.toString().trim().isEmpty() && c == '!') {
+ invert = true;
+ } else if(c == '|' || c == '&') {
+ if(lastOp == '|') {
+ HashSet<String> result = search(query2.toString(), dontMatch);
+ if(!invert) {
+ auctionIds.addAll(result);
+ } else {
+ HashSet<String> allClone = (HashSet<String>) allMatch.clone();
+ allClone.removeAll(result);
+ auctionIds.addAll(allClone);
+ }
+ } else if(lastOp == '&') {
+ HashSet<String> result = search(query2.toString(), dontMatch);
+ if(!invert) {
+ auctionIds.retainAll(result);
+ } else {
+ auctionIds.removeAll(result);
+ }
+ }
+
+ query2 = new StringBuilder();
+ invert = false;
+ lastOp = c;
+ } else {
+ query2.append(c);
+ }
}
- } else if(lastOp == '&') {
- HashSet<String> result = search(query2.toString(), dontMatch);
- if(!invert) {
- auctionIds.retainAll(result);
- } else {
- auctionIds.removeAll(result);
+ if(lastOp == '|') {
+ HashSet<String> result = search(query2.toString(), dontMatch);
+ if(!invert) {
+ auctionIds.addAll(result);
+ } else {
+ HashSet<String> allClone = (HashSet<String>) allMatch.clone();
+ allClone.removeAll(result);
+ auctionIds.addAll(allClone);
+ }
+ } else if(lastOp == '&') {
+ HashSet<String> result = search(query2.toString(), dontMatch);
+ if(!invert) {
+ auctionIds.retainAll(result);
+ } else {
+ auctionIds.removeAll(result);
+ }
}
}
+ sortItems();
+ } catch(Exception e) {
+ shouldUpdateSearch = true;
}
- sortItems();
- } catch(Exception e) {
- shouldUpdateSearch = true;
- }
+ });
}
public void sortItems() throws ConcurrentModificationException {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java
index 0de6cafc..8fee7b6e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java
@@ -93,6 +93,11 @@ public class Options {
"Api Key",
false,
"Type /api new to receive key and put it here.");
+ public Option<Boolean> disableAH = new Option(
+ true,
+ "Disable AH",
+ false,
+ "Disables all AH-related features. Reduces network usage and may improve performance");
public Option<Boolean> autoupdate = new Option(
true,
"Automatically Update Items",
@@ -292,6 +297,7 @@ public class Options {
tryAddOption(tooltipBorderColours, options);
tryAddOption(hideApiKey, options);
tryAddOption(streamerMode, options);
+ tryAddOption(disableAH, options);
tryAddOption(quickAHUpdate, options);
tryAddOption(autoupdate, options);
tryAddOption(cacheRenderedItempane, options);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
index 295bce12..8224bb6d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
@@ -337,19 +337,17 @@ public class GuiProfileViewer extends GuiScreen {
}
break;
case PETS:
- JsonObject petsInfo = profile.getPetsInfo(profileId);
- if(petsInfo == null) break;
- JsonArray pets = petsInfo.get("pets").getAsJsonArray();
- for(int i=petsPage*20; i<Math.min(petsPage*20+20, pets.size()); i++) {
- int xIndex = i % COLLS_XCOUNT;
- int yIndex = i / COLLS_XCOUNT;
+ if(sortedPets == null) break;
+ for(int i=petsPage*20; i<Math.min(petsPage*20+20, sortedPets.size()); i++) {
+ int xIndex = (i%20) % COLLS_XCOUNT;
+ int yIndex = (i%20) / COLLS_XCOUNT;
float x = 5 + COLLS_XPADDING + (COLLS_XPADDING + 20) * xIndex;
float y = 7 + COLLS_YPADDING + (COLLS_YPADDING + 20) * yIndex;
if(mouseX > guiLeft+x && mouseX < guiLeft+x+20) {
if(mouseY > guiTop+y && mouseY < guiTop+y+20) {
- selectedPet = pets.get(i).getAsJsonObject();
+ selectedPet = i;
return;
}
}
@@ -447,6 +445,9 @@ public class GuiProfileViewer extends GuiScreen {
break;
case COLS:
mouseReleasedCols(mouseX, mouseY, mouseButton);
+ break;
+ case PETS:
+ mouseReleasedPets(mouseX, mouseY, mouseButton);
}
}
@@ -500,6 +501,22 @@ public class GuiProfileViewer extends GuiScreen {
Utils.playPressSound();
}
+ private void mouseReleasedPets(int mouseX, int mouseY, int mouseButton) {
+ if(mouseY > guiTop+6 && mouseY < guiTop+22) {
+ if(mouseX > guiLeft+100-15-12 && mouseX < guiLeft+100-20) {
+ if(petsPage > 0) {
+ petsPage--;
+ }
+ return;
+ } else if(mouseX > guiLeft+100+15 && mouseX < guiLeft+100+20+12) {