aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorMoulberry <james.jenour@student.scotch.wa.edu.au>2020-07-31 19:32:53 +1000
committerMoulberry <james.jenour@student.scotch.wa.edu.au>2020-07-31 19:32:53 +1000
commit1b2b38531242d2f3862f5594199bd55d0bf00539 (patch)
tree1894333585a4c85fb83068a0216a380c11f8888f /src/main/java/io
parent6166dd2cbc8acfb67165834869b5d7dee5176cff (diff)
downloadNotEnoughUpdates-1b2b38531242d2f3862f5594199bd55d0bf00539.tar.gz
NotEnoughUpdates-1b2b38531242d2f3862f5594199bd55d0bf00539.tar.bz2
NotEnoughUpdates-1b2b38531242d2f3862f5594199bd55d0bf00539.zip
1.0.5
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/GuiItemRecipe.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/HelpGUI.java189
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java41
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java138
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java40
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/Options.java63
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java12
8 files changed, 376 insertions, 120 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiItemRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiItemRecipe.java
index d0301b2c..c4040f60 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/GuiItemRecipe.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiItemRecipe.java
@@ -37,10 +37,10 @@ public class GuiItemRecipe extends GuiScreen {
private String title;
private NEUManager manager;
- private int guiLeft = 0;
- private int guiTop = 0;
- private int xSize = 176;
- private int ySize = 166;
+ public int guiLeft = 0;
+ public int guiTop = 0;
+ public int xSize = 176;
+ public int ySize = 166;
public GuiItemRecipe(String title, List<ItemStack[]> craftMatrices, List<JsonObject> results, NEUManager manager) {
this.craftMatrices = craftMatrices;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/HelpGUI.java b/src/main/java/io/github/moulberry/notenoughupdates/HelpGUI.java
new file mode 100644
index 00000000..1049dc55
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/HelpGUI.java
@@ -0,0 +1,189 @@
+package io.github.moulberry.notenoughupdates;
+
+import io.github.moulberry.notenoughupdates.util.TexLoc;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.util.vector.Vector2f;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class HelpGUI extends GuiScreen {
+
+ private int guiLeft = 0;
+ private int guiTop = 0;
+ private int sizeX = 0;
+ private int sizeY = 0;
+
+ private int page = 0;
+ private ResourceLocation screenshotBorder = new ResourceLocation("notenoughupdates:ss_border.jpg");
+ private ResourceLocation[] screenshots = null;
+
+ int scaleFactor = 0;
+
+ @Override
+ public void setWorldAndResolution(Minecraft mc, int width, int height) {
+ super.setWorldAndResolution(mc, width, height);
+
+ screenshots = new ResourceLocation[18];
+ for(int i=0; i<=17; i++) {
+ screenshots[i] = new ResourceLocation("notenoughupdates:ss_small/ss"+(i+1)+"-0.jpg");
+ }
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ Keyboard.enableRepeatEvents(true);
+ super.keyTyped(typedChar, keyCode);
+ if(keyCode == Keyboard.KEY_LEFT) {
+ page--;
+ } else if(keyCode == Keyboard.KEY_RIGHT) {
+ page++;
+ }
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ super.drawScreen(mouseX, mouseY, partialTicks);
+
+ drawDefaultBackground();
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ scaleFactor = scaledResolution.getScaleFactor();
+
+ sizeX = width/2+40/scaleFactor;
+ sizeY = height/2+40/scaleFactor;
+ guiLeft = width/4-20/scaleFactor;
+ guiTop = height/4-20/scaleFactor;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(screenshotBorder);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY);
+
+ page = Math.max(0, Math.min(17, page));
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(screenshots[page]);
+ Utils.drawTexturedRect(guiLeft+20f/scaleFactor, guiTop+20f/scaleFactor, sizeX-40f/scaleFactor, sizeY-40f/scaleFactor);
+
+ Utils.drawStringCentered(EnumChatFormatting.GOLD+"NEU Tutorial - Page "+(page+1)+"/18 - Use arrow keys", Minecraft.getMinecraft().fontRendererObj,
+ width/2, guiTop+8, true, 0);
+ if(scaleFactor != 2) Utils.drawStringCentered(EnumChatFormatting.GOLD+"Use GUI Scale normal for better reading experience", Minecraft.getMinecraft().fontRendererObj,
+ width/2, guiTop+18, true, 0);
+
+ for(Map.Entry<Vector2f, List<String>> entry : texts[page].entrySet()) {
+ Vector2f location = entry.getKey();
+ List<String> text = entry.getValue();
+
+ float x = guiLeft+20f/scaleFactor+(sizeX-40f/scaleFactor)*location.x;
+ float y = guiTop+20f/scaleFactor+(sizeY-40f/scaleFactor)*location.y;
+
+ Utils.drawHoveringText(text, (int)x, (int)y+12, 100000, 100000, 200, Minecraft.getMinecraft().fontRendererObj);
+ }
+ }
+
+
+ private static HashMap<Vector2f, List<String>>[] texts = new HashMap[18];
+ static {
+ for(int i=0; i<18; i++) {
+ texts[i] = new HashMap<>();
+ }
+ texts[0].put(new Vector2f(0.73f, 0.60f), Utils.createList(
+ EnumChatFormatting.GOLD+"Itemlist",
+ EnumChatFormatting.GRAY+"Here you will find a list of (most) skyblock items",
+ EnumChatFormatting.GRAY+"The itemlist can be accessed by opening your inventory or most menus while on skyblock"));
+ texts[1].put(new Vector2f(0.73f, 0.16f), Utils.createList(
+ EnumChatFormatting.GOLD+"Itemlist",
+ EnumChatFormatting.GRAY+"These are the page controls for the itemlist",
+ EnumChatFormatting.GRAY+"Clicking these controls will bring you to other pages of the itemlist"));
+ texts[2].put(new Vector2f(0.73f, 1.05f), Utils.createList(
+ EnumChatFormatting.GOLD+"Itemlist",
+ EnumChatFormatting.GRAY+"These are the sorting controls for the itemlist",
+ EnumChatFormatting.GRAY+"The buttons on the left control the ordering of the items",
+ EnumChatFormatting.GRAY+"The buttons on the right can be used to filter a certain type of item"));
+ texts[3].put(new Vector2f(0.39f, 1.04f), Utils.createList(
+ EnumChatFormatting.GOLD+"Itemlist",
+ EnumChatFormatting.GRAY+"This is the search bar for the itemlist",
+ EnumChatFormatting.GRAY+"Double-click the bar to enable inventory search mode",
+ EnumChatFormatting.GRAY+"The button on the left opens up the mod settings",
+ EnumChatFormatting.GRAY+"The button on the right displays this tutorial"));
+ texts[4].put(new Vector2f(0.39f, 0.99f), Utils.createList(
+ EnumChatFormatting.GOLD+"QuickCommands",
+ EnumChatFormatting.GRAY+"These are the QuickCommands",
+ EnumChatFormatting.GRAY+"They let you warp around or access certain menus more easily"));
+ texts[5].put(new Vector2f(0.7f, 0.71f), Utils.createList(
+ EnumChatFormatting.GOLD+"Itemlist",
+ EnumChatFormatting.GRAY+"Hover over an item in the list to display it's lore",
+ EnumChatFormatting.GRAY+"Left clicking some items will display the recipe for that item",
+ EnumChatFormatting.GRAY+"Right clicking some items will display a wiki page for that item",
+ EnumChatFormatting.GRAY+"'F' will favourite an item, putting it to the top of the itemlist"));
+ texts[6].put(new Vector2f(0.17f, 0.21f), Utils.createList(
+ EnumChatFormatting.GOLD+"Collection Log",
+ EnumChatFormatting.GRAY+"This is the collection log. It can be accessed using the /neucl command, or via the QuickCommand",
+ EnumChatFormatting.GRAY+"The collection log keeps track of all items that enter your inventory while you are playing skyblock",
+ EnumChatFormatting.GRAY+"If you are a completionist, this feature is for you"));
+ texts[7].put(new Vector2f(0.05f, 0.13f), Utils.createList(
+ EnumChatFormatting.GOLD+"Collection Log",
+ EnumChatFormatting.GRAY+"Clicking on 'Filter' will change the items that",
+ EnumChatFormatting.GRAY+"appear in the list"));
+ texts[8].put(new Vector2f(0.35f, 0.74f), Utils.createList(
+ EnumChatFormatting.GOLD+"NeuAH",
+ EnumChatFormatting.GRAY+"This is the NEU Auction House (NeuAH)",
+ EnumChatFormatting.GRAY+"This AH can be accessed from anywhere using the /neuah command, or via the QuickCommand",
+ EnumChatFormatting.GRAY+"The items here refresh automatically, so there is no need to close the GUI to see the latest auctions",
+ EnumChatFormatting.GRAY+"Sometimes, you might have to wait until the list is populated with items from the API"));
+ texts[9].put(new Vector2f(0.41f, 0.40f), Utils.createList(
+ EnumChatFormatting.GOLD+"NeuAH",
+ EnumChatFormatting.GRAY+"These tabs control the items that appear in NeuAH",
+ EnumChatFormatting.GRAY+"You can find the main categories on the top of the GUI and subcategories appear on the side of the GUI once a main category is selected"));
+ texts[10].put(new Vector2f(0.57f, 0.38f), Utils.createList(
+ EnumChatFormatting.GOLD+"NeuAH",
+ EnumChatFormatting.GRAY+"Search for items using the search bar at the top",
+ EnumChatFormatting.GRAY+"Boolean operators such as &, | or ! work here."));
+ texts[10].put(new Vector2f(0.40f, 0.72f), Utils.createList(
+ EnumChatFormatting.GOLD+"NeuAH",
+ EnumChatFormatting.GRAY+"This toolbar contains many useful features",
+ EnumChatFormatting.GRAY+"which control the sorting and ordering of",
+ EnumChatFormatting.GRAY+"the auction house, similar to the normal AH"));
+ texts[11].put(new Vector2f(0.55f, 0.72f), Utils.createList(
+ EnumChatFormatting.GOLD+"NeuAH",
+ EnumChatFormatting.GRAY+"Clicking on an item will bring up the auction view",
+ EnumChatFormatting.GRAY+"Here you can viewer the buyer/seller and place bids or make purchases",
+ EnumChatFormatting.GRAY+"Trying to purchase an item will result in a confirmation GUI similar to the normal AH"));
+ texts[12].put(new Vector2f(0.28f, 0.82f), Utils.createList(
+ EnumChatFormatting.GOLD+"Profile Viewer",
+ EnumChatFormatting.GRAY+"Access the profile viewer using /neuprofile (ign) or /pv (ign)",
+ EnumChatFormatting.GRAY+"This is the main page of the profile viewer",
+ EnumChatFormatting.GRAY+"This page contains basic information like stats and skill levels"));
+ texts[12].put(new Vector2f(0.72f, 0.55f), Utils.createList(
+ EnumChatFormatting.GOLD+"Profile Viewer",
+ EnumChatFormatting.GRAY+"Click the button on the left to switch profiles and use the bar on the right to switch players"));
+ texts[13].put(new Vector2f(0.28f, 0.82f), Utils.createList(
+ EnumChatFormatting.GOLD+"Profile Viewer",
+ EnumChatFormatting.GRAY+"This is the extra info page of the profile viewer",
+ EnumChatFormatting.GRAY+"This page contains all the small bits of information about a player that don't fit anywhere else"));
+ texts[14].put(new Vector2f(0.28f, 0.82f), Utils.createList(
+ EnumChatFormatting.GOLD+"Profile Viewer",
+ EnumChatFormatting.GRAY+"This is the inventories page of the profile viewer",
+ EnumChatFormatting.GRAY+"Click on the inventory icons in the top-left or use your keyboard to switch the inventory type",
+ EnumChatFormatting.GRAY+"The bar on the bottom-left searches the current inventory for matching items"));
+ texts[15].put(new Vector2f(0.28f, 0.82f), Utils.createList(
+ EnumChatFormatting.GOLD+"Profile Viewer",
+ EnumChatFormatting.GRAY+"This is the collections page of the profile viewer",
+ EnumChatFormatting.GRAY+"Click on the icons on the left or use the keyboard shortcut to switch collection type"));
+ texts[16].put(new Vector2f(0.28f, 0.82f), Utils.createList(
+ EnumChatFormatting.GOLD+"Profile Viewer",
+ EnumChatFormatting.GRAY+"This is the pets page of the profile viewer",
+ EnumChatFormatting.GRAY+"Click to select the pet on the left",
+ EnumChatFormatting.GRAY+"The selected pet's stats will display on the right"));
+ texts[17].put(new Vector2f(0.27f, 0.40f), Utils.createList(
+ EnumChatFormatting.GOLD+"Overlay",
+ EnumChatFormatting.GRAY+"Rearrange certain GUI elements of the main overlay using /neuoverlay",
+ EnumChatFormatting.GRAY+"If you accidentally move them off screen, use the button in the top left to reset the GUI"));
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
index a234ca8a..c2db41d0 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
@@ -309,8 +309,9 @@ public class NEUOverlay extends Gui {
@Override
public void mouseClick(float x, float y, int mouseX, int mouseY) {
if(Mouse.getEventButtonState()) {
- displayInformationPane(HTMLInfoPane.createFromWikiUrl(overlay, manager, "Help",
- "https://moulberry.github.io/files/neu_help.html"));
+ //displayInformationPane(HTMLInfoPane.createFromWikiUrl(overlay, manager, "Help",
+ // "https://moulberry.github.io/files/neu_help.html"));
+ Minecraft.getMinecraft().displayGuiScreen(new HelpGUI());
Utils.playPressSound();
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index a68421b8..4b1e3c3c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -220,6 +220,12 @@ public class NotEnoughUpdates {
}
});
+ SimpleCommand tutorialCommand = new SimpleCommand("neututorial", new SimpleCommand.ProcessCommandRunnable() {
+ public void processCommand(ICommandSender sender, String[] args) {
+ openGui = new HelpGUI();
+ }
+ });
+
SimpleCommand cosmeticsCommand = new SimpleCommand("neucosmetics", new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
@@ -262,6 +268,7 @@ public class NotEnoughUpdates {
ClientCommandHandler.instance.registerCommand(cosmeticsCommand);
ClientCommandHandler.instance.registerCommand(linksCommand);
ClientCommandHandler.instance.registerCommand(viewProfileCommand);
+ ClientCommandHandler.instance.registerCommand(tutorialCommand);
ClientCommandHandler.instance.registerCommand(viewProfileShortCommand);
ClientCommandHandler.instance.registerCommand(overlayPlacementsCommand);
ClientCommandHandler.instance.registerCommand(enchantColourCommand);
@@ -456,6 +463,19 @@ public class NotEnoughUpdates {
if(!joinedSB && manager.config.showUpdateMsg.value) {
joinedSB = true;
displayUpdateMessageIfOutOfDate();
+ if(!manager.config.loadedModBefore.value) {
+ manager.config.loadedModBefore.value = true;
+ try { manager.saveConfig(); } catch(IOException e) {}
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.BLUE+"It seems this is your first time using NotEnoughUpdates."));
+ ChatComponentText clickText = new ChatComponentText(
+ EnumChatFormatting.YELLOW+"Click this message if you would like to view a short tutorial.");
+ clickText.setChatStyle(Utils.createClickStyle(ClickEvent.Action.RUN_COMMAND, "/neututorial"));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(clickText);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ }
}
SBScoreboardData.getInstance().tick();
//GuiQuestLine.questLine.tick();
@@ -773,13 +793,24 @@ public class NotEnoughUpdates {
npe.printStackTrace();
focusInv = !hoverPane;
}
- if(focusInv) {
- try {
- overlay.render(event.getMouseX(), event.getMouseY(), hoverInv && focusInv);
- } catch(ConcurrentModificationException e) {e.printStackTrace();}
- GL11.glTranslatef(0, 0, 10);
+ }
+ if(event.gui instanceof GuiItemRecipe) {
+ GuiItemRecipe guiItemRecipe = ((GuiItemRecipe)event.gui);
+ hoverInv = event.getMouseX() > guiItemRecipe.guiLeft && event.getMouseX() < guiItemRecipe.guiLeft + guiItemRecipe.xSize &&
+ event.getMouseY() > guiItemRecipe.guiTop && event.getMouseY() < guiItemRecipe.guiTop + guiItemRecipe.ySize;
+
+ if(hoverPane) {
+ if(!hoverInv) focusInv = false;
+ } else {
+ focusInv = true;
}
}
+ if(focusInv) {
+ try {
+ overlay.render(event.getMouseX(), event.getMouseY(), hoverInv && focusInv);
+ } catch(ConcurrentModificationException e) {e.printStackTrace();}
+ GL11.glTranslatef(0, 0, 10);
+ }
}
}
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 0fe0cc67..6b29655c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
@@ -29,8 +29,6 @@ public class APIManager {
private NEUManager manager;
public final CustomAH customAH;
- private int totalPages = 0;
-
private TreeMap<String, Auction> auctionMap = new TreeMap<>();
public HashMap<String, HashSet<String>> internalnameToAucIdMap = new HashMap<>();
private HashSet<String> playerBids = new HashSet<>();
@@ -39,14 +37,15 @@ public class APIManager {
private HashMap<String, TreeMap<Integer, String>> internalnameToLowestBIN = new HashMap<>();
- private JsonArray playerInformation = null;
+ private LinkedList<Integer> pagesToDownload = null;
public TreeMap<String, HashMap<Integer, HashSet<String>>> extrasToAucIdMap = new TreeMap<>();
- private boolean fullDownload = false;
private long lastAuctionUpdate = 0;
+ private long lastShortAuctionUpdate = 0;
private long lastCustomAHSearch = 0;
private long lastCleanup = 0;
+ private long lastApiUpdate = 0;
public int activeAuctions = 0;
public int uniqueItems = 0;
@@ -114,13 +113,18 @@ public class APIManager {
}
public void tick() {
- if(manager.config.disableAH.value || manager.config.apiKey.value == null || manager.config.apiKey.value.isEmpty()) return;
+ if(manager.config.apiKey.value == null || manager.config.apiKey.value.isEmpty()) return;
customAH.tick();
long currentTime = System.currentTimeMillis();
if(currentTime - lastAuctionUpdate > 60*1000) {
lastAuctionUpdate = currentTime;
updatePageTick();
+ }
+
+ if(currentTime - lastShortAuctionUpdate > 10*1000) {
+ lastShortAuctionUpdate = currentTime;
+ updatePageTickShort();
ahNotification();
}
/*if(currentTime - lastProfileUpdate > 10*1000) {
@@ -238,49 +242,61 @@ public class APIManager {
}
}
- private void updatePageTick() {
+ private void updatePageTickShort() {
JsonObject disable = Utils.getConstant("disable");
- if(!fullDownload && (disable == null || !disable.get("auctions").getAsBoolean())) {
- fullDownload = true;
+ if(disable != null && disable.get("auctions").getAsBoolean()) return;
+
+ if(pagesToDownload == null) {
getPageFromAPI(0);
- for(int i=1; i<totalPages; i++) {
- getPageFromAPI(i);
- }
- } else {
- manager.hypixelApi.getApiGZIPAsync("http://51.89.22.3/auction.json.gz", jsonObject -> {
- if(jsonObject.get("success").getAsBoolean()) {
- JsonArray new_auctions = jsonObject.get("new_auctions").getAsJsonArray();
- for(JsonElement auctionElement : new_auctions) {
- JsonObject auction = auctionElement.getAsJsonObject();
- processAuction(auction);
- }
- JsonArray new_bids = jsonObject.get("new_bids").getAsJsonArray();
- for(JsonElement newBidElement : new_bids) {
- JsonObject newBid = newBidElement.getAsJsonObject();
- String newBidUUID = newBid.get("uuid").getAsString();
- int newBidAmount = newBid.get("highest_bid_amount").getAsInt();
- int end = newBid.get("end").getAsInt();
- int bid_count = newBid.get("bid_count").getAsInt();
-
- Auction auc = auctionMap.get(newBidUUID);
- if(auc != null) {
- auc.highest_bid_amount = newBidAmount;
- auc.end = end;
- auc.bid_count = bid_count;
- }
- }
- Set<String> toRemove = new HashSet<>();
- JsonArray removed_auctions = jsonObject.get("removed_auctions").getAsJsonArray();
- for(JsonElement removedAuctionsElement : removed_auctions) {
- String removed = removedAuctionsElement.getAsString();
- toRemove.add(removed);
+ } else if(!pagesToDownload.isEmpty()) {
+ int page = pagesToDownload.getFirst();
+ getPageFromAPI(page);
+ }
+ }
+
+ private void updatePageTick() {
+ JsonObject disable = Utils.getConstant("disable");
+ if(disable != null && disable.get("auctions").getAsBoolean()) return;
+
+ manager.hypixelApi.getApiGZIPAsync("http://moulberry.codes/auction.json.gz", jsonObject -> {
+ if(jsonObject.get("success").getAsBoolean()) {
+ long apiUpdate = (long)jsonObject.get("time").getAsFloat();
+ if(lastApiUpdate == apiUpdate) {
+ lastAuctionUpdate -= 30*1000;
+ }
+ lastApiUpdate = apiUpdate;
+
+ JsonArray new_auctions = jsonObject.get("new_auctions").getAsJsonArray();
+ for(JsonElement auctionElement : new_auctions) {
+ JsonObject auction = auctionElement.getAsJsonObject();
+ processAuction(auction);
+ }
+ JsonArray new_bids = jsonObject.get("new_bids").getAsJsonArray();
+ for(JsonElement newBidElement : new_bids) {
+ JsonObject newBid = newBidElement.getAsJsonObject();
+ String newBidUUID = newBid.get("uuid").getAsString();
+ int newBidAmount = newBid.get("highest_bid_amount").getAsInt();
+ int end = newBid.get("end").getAsInt();
+ int bid_count = newBid.get("bid_count").getAsInt();
+
+ Auction auc = auctionMap.get(newBidUUID);
+ if(auc != null) {
+ auc.highest_bid_amount = newBidAmount;
+ auc.end = end;
+ auc.bid_count = bid_count;
}
- remove(toRemove);
}
- }, () -> {
- System.out.println("error");
- });
- }
+ Set<String> toRemove = new HashSet<>();
+ JsonArray removed_auctions = jsonObject.get("removed_auctions").getAsJsonArray();
+ for(JsonElement removedAuctionsElement : removed_auctions) {
+ String removed = removedAuctionsElement.getAsString();
+ toRemove.add(removed);
+ }
+ remove(toRemove);
+ }
+ }, () -> {
+ System.out.println("Error downloading auction from Moulberry's jank API. :(");
+ });
}
public void calculateStats() {
@@ -368,12 +384,6 @@ public class APIManager {
NBTTagCompound tag = item_tag.getTagList("i", 10).getCompoundTagAt(0).getCompoundTag("tag");
String internalname = manager.getInternalnameFromNBT(tag);
- String displayNormal = "";
- if(manager.getItemInformation().containsKey(internalname)) {
- displayNormal = Utils.cleanColour(manager.getItemInformation().get(internalname).get("displayname").getAsString());
- } else {
-
- }
String[] lore = new String[0];
NBTTagCompound display = tag.getCompoundTag("display");
@@ -468,14 +478,13 @@ public class APIManager {
}
}
- auction1.lastUpdate = System.currentTimeMillis();
-
auctionMap.put(auctionUuid, auction1);
internalnameToAucIdMap.computeIfAbsent(internalname, k -> new HashSet<>()).add(auctionUuid);
} catch(Exception e) {e.printStackTrace();}
}
private void getPageFromAPI(int page) {
+ System.out.println("downloading page:"+page);
//System.out.println("Trying to update page: " + page);
HashMap<String, String> args = new HashMap<>();
args.put("page", ""+page);
@@ -484,19 +493,26 @@ public class APIManager {
if(jsonObject == null) return;
if (jsonObject.get("success").getAsBoolean()) {
- totalPages = jsonObject.get("totalPages").getAsInt();
- activeAuctions = jsonObject.get("totalAuctions").getAsInt();
+ if(pagesToDownload == null) {
+ int totalPages = jsonObject.get("totalPages").getAsInt();
+ pagesToDownload = new LinkedList<>();
+ for(int i=0; i<totalPages; i++) {
+ pagesToDownload.add(i);
+ }
+ }
+ pagesToDownload.remove(Integer.valueOf(page));
+ activeAuctions = jsonObject.get("totalAuctions").getAsInt();
- long startProcess = System.currentTimeMillis();
- JsonArray auctions = jsonObject.get("auctions").getAsJsonArray();
- for (int i = 0; i < auctions.size(); i++) {
- JsonObject auction = auctions.get(i).getAsJsonObject();
+ long startProcess = System.currentTimeMillis();
+ JsonArray auctions = jsonObject.get("auctions").getAsJsonArray();
+ for (int i = 0; i < auctions.size(); i++) {
+ JsonObject auction = auctions.get(i).getAsJsonObject();
- processAuction(auction);
+ processAuction(auction);
+ }
+ processMillis = (int)(System.currentTimeMillis() - startProcess);
}
- processMillis = (int)(System.currentTimeMillis() - startProcess);
}
- }
);
}
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 a1ad89a1..6fdb2924 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
@@ -870,6 +870,12 @@ public class CustomAH extends Gui {
case 8:
lore.add("");
lore.add("Current aucid: " + currentAucId);
+ if(currentAucId != null) {
+ APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(currentAucId);
+ if(auc != null) {
+ lore.add("Current auc category: " + auc.category);
+ }
+ }
lore.add(" --- Processing");
lore.add("Page Process Millis: " + manager.auctionManager.processMillis);
lore.add(" --- Auction Stats");
@@ -1051,18 +1057,19 @@ public class CustomAH extends Gui {
scrollAmount = 0;
try {
- auctionIds.clear();
+ HashSet<String> auctionIdsNew = new HashSet<>();
+ auctionIdsNew.clear();
if(filterMyAuctions) {
for(String aucid : manager.auctionManager.getPlayerBids()) {
APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid);
if(doesAucMatch(auc)) {
- auctionIds.add(aucid);
+ auctionIdsNew.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());
+ auctionIdsNew.add(entry.getKey());
}
}
} else {
@@ -1091,18 +1098,18 @@ public class CustomAH extends Gui {
if(lastOp == '|') {
HashSet<String> result = search(query2.toString(), dontMatch);
if(!invert) {
- auctionIds.addAll(result);
+ auctionIdsNew.addAll(result);
} else {
HashSet<String> allClone = (HashSet<String>) allMatch.clone();
allClone.removeAll(result);
- auctionIds.addAll(allClone);
+ auctionIdsNew.addAll(allClone);
}
} else if(lastOp == '&') {
HashSet<String> result = search(query2.toString(), dontMatch);
if(!invert) {
- auctionIds.retainAll(result);
+ auctionIdsNew.retainAll(result);
} else {
- auctionIds.removeAll(result);
+ auctionIdsNew.removeAll(result);
}
}
@@ -1116,21 +1123,22 @@ public class CustomAH extends Gui {
if(lastOp == '|') {
HashSet<String> result = search(query2.toString(), dontMatch);
if(!invert) {
- auctionIds.addAll(result);
+ auctionIdsNew.addAll(result);
} else {
HashSet<String> allClone = (HashSet<String>) allMatch.clone();
allClone.removeAll(result);
- auctionIds.addAll(allClone);
+ auctionIdsNew.addAll(allClone);
}
} else if(lastOp == '&') {
HashSet<String> result = search(query2.toString(), dontMatch);
if(!invert) {
- auctionIds.retainAll(result);
+ auctionIdsNew.retainAll(result);
} else {
- auctionIds.removeAll(result);
+ auctionIdsNew.removeAll(result);
}
}
}
+ auctionIds = auctionIdsNew;
sortItems();
} catch(Exception e) {
shouldUpdateSearch = true;
@@ -1140,9 +1148,10 @@ public class CustomAH extends Gui {
public void sortItems() throws ConcurrentModificationException {
try {
- sortedAuctionIds.clear();
- sortedAuctionIds.addAll(auctionIds);
- sortedAuctionIds.sort((o1, o2) -> {
+ List<String> sortedAuctionIdsNew = new ArrayList<>();
+
+ sortedAuctionIdsNew.addAll(auctionIds);
+ sortedAuctionIdsNew.sort((o1, o2) -> {
APIManager.Auction auc1 = manager.auctionManager.getAuctionItems().get(o1);
APIManager.Auction auc2 = manager.auctionManager.getAuctionItems().get(o2);
@@ -1177,6 +1186,8 @@ public class CustomAH extends Gui {
}
return o1.compareTo(o2);
});
+
+ sortedAuctionIds = sortedAuctionIdsNew;
} catch(Exception e) {
shouldSortItems = true;
}
@@ -1445,6 +1456,7 @@ public class CustomAH extends Gui {
aucid = sortedAuctionIds.get(id);
} catch (IndexOutOfBoundsException e) { break out; }
+ if(aucid == null) continue;
APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid);
if(auc != null) {
if(mouseX > itemX && mouseX < itemX+16) {
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 8fee7b6e..7844cf37 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java
@@ -93,11 +93,6 @@ 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",
@@ -172,6 +167,11 @@ public class Options {
"Show Dev Options",
true,
"Dev Feature. Please don't use.");
+ public Option<Boolean> loadedModBefore = new Option(
+ false,
+ "loadedModBefore",
+ true,
+ "loadedModBefore");
public Option<String> selectedCape = new Option(
"",
"Selected Cape",
@@ -219,12 +219,12 @@ public class Options {
"OverlaySearchBar");
public Option<List<String>> enchantColours = new Option(
Utils.createList("[a-zA-Z ]+:\u003e:9:6",
- "[a-zA-Z ]+:\u003e:6:c",
- "[a-zA-Z ]+:\u003e:5:5",
- "Experience:\u003e:3:5",
- "Life Steal:\u003e:3:5",
- "Scavenger:\u003e:3:5",
- "Looting:\u003e:3:5"),
+ "[a-zA-Z ]+:\u003e:6:c",
+ "[a-zA-Z ]+:\u003e:5:5",
+ "Experience:\u003e:3:5",
+ "Life Steal:\u003e:3:5",
+ "Scavenger:\u003e:3:5",
+ "Looting:\u003e:3:5"),
"enchantColours",
false,
"enchantColours");
@@ -255,14 +255,16 @@ public class Options {
}
private transient List<Button> buttons = new ArrayList<>();
+
{
buttons.add(new Button("Open Config Folder", "Opens the config folder. Be careful.", () -> {
- if(Desktop.isDesktopSupported()) {
+ if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
- if(NotEnoughUpdates.INSTANCE.manager.configFile.getParentFile().exists()) {
+ if (NotEnoughUpdates.INSTANCE.manager.configFile.getParentFile().exists()) {
try {
desktop.open(NotEnoughUpdates.INSTANCE.manager.configFile.getParentFile());
- } catch(IOException ignored) {}
+ } catch (IOException ignored) {
+ }
}
}
}));
@@ -297,7 +299,6 @@ public class Options {
tryAddOption(tooltipBorderColours, options);
tryAddOption(hideApiKey, options);
tryAddOption(streamerMode, options);
- tryAddOption(disableAH, options);
tryAddOption(quickAHUpdate, options);
tryAddOption(autoupdate, options);
tryAddOption(cacheRenderedItempane, options);
@@ -319,7 +320,7 @@ public class Options {
}
private void tryAddOption(Option<?> option, List<Option> list) {
- if(!option.secret) {// || dev.value) {
+ if (!option.secret) {// || dev.value) {
list.add(option);
}
}
@@ -348,19 +349,19 @@ public class Options {
}
public void setValue(String value) {
- if(this.value instanceof Boolean) {
+ if (this.value instanceof Boolean) {
((Option<Boolean>) this).value = Boolean.valueOf(value);
- } else if(this.value instanceof Double) {
- ((Option<Double>)this).value = Double.valueOf(value);
- } else if(this.value instanceof String) {
- ((Option<String>)this).value = value;
+ } else if (this.value instanceof Double) {
+ ((Option<Double>) this).value = Double.valueOf(value);
+ } else if (this.value instanceof String) {
+ ((Option<String>) this).value = value;
}
}
}
public static JsonSerializer<Option<?>> createSerializer() {
return (src, typeOfSrc, context) -> {
- if(src.secret && src.defaultValue.equals(src.value)) {
+ if (src.secret && src.defaultValue.equals(src.value)) {
return null;
}
return context.serialize(src.value);
@@ -371,7 +372,7 @@ public class Options {
return (json, typeOfT, context) -> {
try {
return new Option(context.deserialize(json, Object.class), "unknown", false, "unknown");
- } catch(Exception e) {
+ } catch (Exception e) {
return null;
}
};
@@ -383,22 +384,24 @@ public class Options {
Options oLoad = gson.fromJson(reader, Options.class);
Options oDefault = new Options();
- if(oLoad == null) return oDefault;
+ if (oLoad == null) return oDefault;
- for(Field f : Options.class.getDeclaredFields()) {
+ for (Field f : Options.class.getDeclaredFields()) {
try {
- if(((Option)f.get(oDefault)).value instanceof List) {
+ if (((Option) f.get(oDefault)).value instanceof List) {
//If the default size of the list is greater than the loaded size, use the default value.
//if(((List<?>)((Option)f.get(oDefault)).value).size() > ((List<?>)((Option)f.get(oLoad)).value).size()) {
// continue;
//}
}
- ((Option)f.get(oDefault)).value = ((Option)f.get(oLoad)).value;
- } catch (Exception e) { }
+ ((Option) f.get(oDefault)).value = ((Option) f.get(oLoad)).value;
+ } catch (Exception e) {
+ }
}
return oDefault;
}
+
public void saveToFile(Gson gson, File file) throws IOException {
file.createNewFile();
@@ -407,6 +410,4 @@ public class Options {
writer.write(gson.toJson(this));
}
}
-
-
-}
+} \ No newline at end of file
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 b516c6e3..24a3d49d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
@@ -517,7 +517,7 @@ public class GuiProfileViewer extends GuiScreen {
}
return;
} else if(mouseX > guiLeft+100+15 && mouseX < guiLeft+100+20+12) {
- if(sortedPets != null && petsPage < Math.ceil(sortedPets.size()/25f)-1) {
+ if(sortedPets != null && petsPage < Math.ceil(sortedPets.size()/20f)-1) {
petsPage++;
}
return;
@@ -873,7 +873,7 @@ public class GuiProfileViewer extends GuiScreen {
Utils.drawTexturedRect(guiLeft+100-15-12, guiTop+6, 12, 16,
29/256f, 53/256f, !leftHovered?0:32/256f, !leftHovered?32/256f:64/256f, GL11.GL_NEAREST);
}
- if(petsPage < Math.ceil(pets.size()/25f)-1) {
+ if(petsPage < Math.ceil(pets.size()/20f)-1) {
Utils.drawTexturedRect( guiLeft+100+15, guiTop+6, 12, 16,
5/256f, 29/256f, !rightHovered?0:32/256f, !rightHovered?32/256f:64/256f, GL11.GL_NEAREST);
}
@@ -2086,7 +2086,13 @@ public class GuiProfileViewer extends GuiScreen {
int x = guiLeft+50;
float y = guiTop+82+15*(float)Math.sin(((currentTime-startTime)/800f)%(2*Math.PI));
GlStateManager.translate(x, y, 0);
- ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(item);
+ ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(item, false);
+
+ //Remove extra attributes so no CIT
+ NBTTagCompound stackTag = stack.getTagCompound()==null?new NBTTagCompound():stack.getTagCompound();
+ stackTag.removeTag("ExtraAttributes");
+ stack.setTagCompound(stackTag);
+
GlStateManager.scale(-1.5f, 1.5f, 1);
GlStateManager.enableDepth();
Utils.drawItemStack(stack, 0, 0);