aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMoulberry <james.jenour@student.scotch.wa.edu.au>2020-08-09 07:02:36 +1000
committerMoulberry <james.jenour@student.scotch.wa.edu.au>2020-08-09 07:02:36 +1000
commitf729d5199a2acd9264f9e4244d598debdc53cbcc (patch)
treebbc3d3017c5283174eb55a1300ce4e26bf52e5ec /src/main/java
parent1b2b38531242d2f3862f5594199bd55d0bf00539 (diff)
downloadNotEnoughUpdates-f729d5199a2acd9264f9e4244d598debdc53cbcc.tar.gz
NotEnoughUpdates-f729d5199a2acd9264f9e4244d598debdc53cbcc.tar.bz2
NotEnoughUpdates-f729d5199a2acd9264f9e4244d598debdc53cbcc.zip
1.1.1
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java20
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlayPlacements.java35
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java137
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java42
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeNode.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java210
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBAnchorPoint.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroup.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java58
-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.java36
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java4
17 files changed, 400 insertions, 180 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java b/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java
index 58eaab72..dcd8cfb2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java
@@ -35,6 +35,11 @@ public class CustomItems {
"your buried duct tape problems are a thing of the past,",
"all for the low price of $7.99 or a subscription",
"to the Ducttapedigger youtube channel!");
+ public static JsonObject SPINAXX = create(
+ "SPINAXX",
+ "emerald",
+ "Spinaxx",
+ "Famous streamer btw :)");
public static JsonObject RUNE = create("RUNE", "paper", "No.", "I hate runes.");
public static JsonObject TWOBEETWOTEE = create("2B2T", "bedrock", "Minecraft's oldest anarchy Minecraft server in Minecraft.",
"This Minecraft anarchy server is the oldest server,",
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java
index 98b08fd8..8e14598f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java
@@ -36,6 +36,8 @@ public class GuiEnchantColour extends GuiScreen {
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ drawDefaultBackground();
+
List<String> enchantColours = getEnchantColours();
ySize = 53+25*enchantColours.size();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index 30dc12c4..3a84dc5c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -368,12 +368,13 @@ public class NEUManager {
*/
public void loadItemInformation() {
Thread thread = new Thread(() -> {
+ JDialog dialog = null;
try {
if(config.autoupdate.value) {
JOptionPane pane = new JOptionPane("Getting items to download from remote repository.");
- JDialog dialog = pane.createDialog("NotEnoughUpdates Remote Sync");
+ dialog = pane.createDialog("NotEnoughUpdates Remote Sync");
dialog.setModal(false);
- //dialog.setVisible(true);
+ if(config.dev.value) dialog.setVisible(true);
if (Display.isActive()) dialog.toFront();
@@ -389,6 +390,7 @@ public class NEUManager {
} catch (IOException e) {
}
} else {
+ dialog.setVisible(false);
return;
}
@@ -411,7 +413,7 @@ public class NEUManager {
for (String name : changedFiles.keySet()) {
pane.setMessage(startMessage + (++downloaded) + "/" + changedFiles.size() + ")\nCurrent: " + name);
dialog.pack();
- //dialog.setVisible(true);
+ if(config.dev.value) dialog.setVisible(true);
if (Display.isActive()) dialog.toFront();
File item = new File(repoLocation, name);
@@ -440,6 +442,7 @@ public class NEUManager {
try {
writeJson(itemShaConfig, itemShaLocation);
} catch (IOException e) {
+ e.printStackTrace();
}
} else {
Utils.recursiveDelete(repoLocation);
@@ -450,7 +453,7 @@ public class NEUManager {
pane.setMessage("Downloading NEU Master Archive. (DL# >20)");
dialog.pack();
- //dialog.setVisible(true);
+ if(config.dev.value) dialog.setVisible(true);
if (Display.isActive()) dialog.toFront();
File itemsZip = new File(repoLocation, "neu-items-master.zip");
@@ -471,6 +474,7 @@ public class NEUManager {
fileOutputStream.write(dataBuffer, 0, bytesRead);
}
} catch (IOException e) {
+ dialog.dispose();
return;
}
@@ -492,10 +496,12 @@ public class NEUManager {
}
}
}
-
- dialog.dispose();
}
- } catch(Exception e) {}
+ } catch(Exception e) {
+ e.printStackTrace();
+ } finally {
+ if(dialog != null) dialog.dispose();
+ }
File items = new File(repoLocation, "items");
if(items.exists()) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
index c2db41d0..0cb7a548 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
@@ -1103,6 +1103,9 @@ public class NEUOverlay extends Gui {
case "leocthl":
searchedItems.add(CustomItems.LEOCTHL);
break;
+ case "spinaxx":
+ searchedItems.add(CustomItems.SPINAXX);
+ break;
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlayPlacements.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlayPlacements.java
index 28ecbc8e..eb6357ae 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlayPlacements.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlayPlacements.java
@@ -4,9 +4,11 @@ import io.github.moulberry.notenoughupdates.mbgui.MBAnchorPoint;
import io.github.moulberry.notenoughupdates.mbgui.MBGuiElement;
import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroup;
import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupFloating;
+import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.input.Keyboard;
import org.lwjgl.util.vector.Vector2f;
@@ -27,6 +29,14 @@ public class NEUOverlayPlacements extends GuiScreen {
super.drawScreen(mouseX, mouseY, partialTicks);
drawDefaultBackground();
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(icons);
+ GlStateManager.enableBlend();
+
+ GlStateManager.tryBlendFuncSeparate(775, 769, 1, 0);
+ GlStateManager.enableAlpha();
+ this.drawTexturedModalRect(width / 2 - 7, height / 2 - 7, 0, 0, 16, 16);
+
if(mouseX < 300 && mouseY < 300 && clickedElement != null) {
guiButton.yPosition = height - 5 - guiButton.height;
} else {
@@ -73,9 +83,14 @@ public class NEUOverlayPlacements extends GuiScreen {
new Color(200, 200, 200, 100).getRGB());
break;
case BOTMID:
+ case INV_BOTMID:
drawRect((int)position.x, (int)(position.y+element.getHeight()*0.9f),
(int)position.x+element.getWidth(), (int)position.y+element.getHeight(),
new Color(200, 200, 200, 100).getRGB());
+ if(anchorPoint.anchorPoint == MBAnchorPoint.AnchorPoint.INV_BOTMID) {
+ Utils.drawStringCentered("Inv-Relative", Minecraft.getMinecraft().fontRendererObj,
+ position.x+element.getWidth()*0.5f, position.y+element.getHeight()*0.5f, false, 0);
+ }
break;
case MIDMID:
drawRect((int)(position.x+element.getWidth()*0.45f), (int)(position.y+element.getHeight()*0.45f),
@@ -91,6 +106,7 @@ public class NEUOverlayPlacements extends GuiScreen {
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
MBGuiGroupFloating mainGroup = NotEnoughUpdates.INSTANCE.overlay.guiGroup;
+ int index=0;
for(MBGuiElement element : mainGroup.getChildren()) {
MBAnchorPoint anchorPoint = mainGroup.getChildrenMap().get(element);
Vector2f position = mainGroup.getChildrenPosition().get(element);
@@ -104,22 +120,27 @@ public class NEUOverlayPlacements extends GuiScreen {
clickedAnchorX = (int)anchorPoint.offset.x;
clickedAnchorY = (int)anchorPoint.offset.y;
} else {
- float anchorX = (width-element.getWidth()) * anchorPoint.anchorPoint.x + anchorPoint.offset.x;
- float anchorY = (height-element.getHeight()) * anchorPoint.anchorPoint.y + anchorPoint.offset.y;
-
MBAnchorPoint.AnchorPoint[] vals = MBAnchorPoint.AnchorPoint.values();
anchorPoint.anchorPoint = vals[(anchorPoint.anchorPoint.ordinal()+1)%vals.length];
- float screenX = (width-element.getWidth()) * anchorPoint.anchorPoint.x;
- float screenY = (height-element.getHeight()) * anchorPoint.anchorPoint.y;
- anchorPoint.offset.x = anchorX - screenX;
- anchorPoint.offset.y = anchorY - screenY;
+ mainGroup.recalculate();
+
+ anchorPoint.offset.x += position.x - mainGroup.getChildrenPosition().get(element).x;
+ anchorPoint.offset.y += position.y - mainGroup.getChildrenPosition().get(element).y;
mainGroup.recalculate();
+
+ if(index == 0) {
+ NotEnoughUpdates.INSTANCE.manager.config.overlaySearchBar.value = anchorPoint.toString();
+ } else if(index == 1) {
+ NotEnoughUpdates.INSTANCE.manager.config.overlayQuickCommand.value = anchorPoint.toString();
+ }
+ try { NotEnoughUpdates.INSTANCE.manager.saveConfig(); } catch(IOException ignored) {}
}
return;
}
}
+ index++;
}
if(guiButton.mousePressed(Minecraft.getMinecraft(), mouseX, mouseY)) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index 4b1e3c3c..fbcd3de3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -52,6 +52,7 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
+import org.apache.commons.lang3.StringUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
@@ -77,7 +78,7 @@ import static io.github.moulberry.notenoughupdates.GuiTextures.*;
@Mod(modid = NotEnoughUpdates.MODID, version = NotEnoughUpdates.VERSION)
public class NotEnoughUpdates {
public static final String MODID = "notenoughupdates";
- public static final String VERSION = "REL-1.0.1";
+ public static final String VERSION = "1.1-REL";
public static NotEnoughUpdates INSTANCE = null;
@@ -180,16 +181,51 @@ public class NotEnoughUpdates {
}
});
- SimpleCommand viewProfileShortCommand = new SimpleCommand("pv", viewProfileRunnable, new SimpleCommand.TabCompleteRunnable() {
+ SimpleCommand viewProfileShortCommand = new SimpleCommand("pv", new SimpleCommand.ProcessCommandRunnable() {
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) {
+ if(!hasSkyblockScoreboard()) {
+ Minecraft.getMinecraft().thePlayer.sendChatMessage("/pv " + StringUtils.join(args, " "));
+ } else {
+ viewProfileRunnable.processCommand(sender, args);
+ }
+ }
+ }, new SimpleCommand.TabCompleteRunnable() {
@Override
public List<String> tabComplete(ICommandSender sender, String[] args, BlockPos pos) {
- if(args.length != 1) return null;
-
- String lastArg = args[args.length-1];
+ if (args.length != 1) return null;
+
+ String lastArg = args[args.length - 1];
List<String> playerMatches = new ArrayList<>();
- for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
+ for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
String playerName = player.getName();
- if(playerName.toLowerCase().startsWith(lastArg.toLowerCase())) {
+ if (playerName.toLowerCase().startsWith(lastArg.toLowerCase())) {
+ playerMatches.add(playerName);
+ }
+ }
+ return playerMatches;
+ }
+ });
+
+ SimpleCommand viewProfileShort2Command = new SimpleCommand("vp", new SimpleCommand.ProcessCommandRunnable() {
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) {
+ if(!hasSkyblockScoreboard()) {
+ Minecraft.getMinecraft().thePlayer.sendChatMessage("/vp " + StringUtils.join(args, " "));
+ } else {
+ viewProfileRunnable.processCommand(sender, args);
+ }
+ }
+ }, new SimpleCommand.TabCompleteRunnable() {
+ @Override
+ public List<String> tabComplete(ICommandSender sender, String[] args, BlockPos pos) {
+ if (args.length != 1) return null;
+
+ String lastArg = args[args.length - 1];
+ List<String> playerMatches = new ArrayList<>();
+ for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
+ String playerName = player.getName();
+ if (playerName.toLowerCase().startsWith(lastArg.toLowerCase())) {
playerMatches.add(playerName);
}
}
@@ -268,8 +304,9 @@ 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(viewProfileShort2Command);
+ ClientCommandHandler.instance.registerCommand(tutorialCommand);
ClientCommandHandler.instance.registerCommand(overlayPlacementsCommand);
ClientCommandHandler.instance.registerCommand(enchantColourCommand);
ClientCommandHandler.instance.registerCommand(neuAhCommand);
@@ -442,6 +479,7 @@ public class NotEnoughUpdates {
*/
private HashMap<String, Long> newItemAddMap = new HashMap<>();
private long lastLongUpdate = 0;
+ private long lastSkyblockScoreboard = 0;
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if(event.phase != TickEvent.Phase.START) return;
@@ -459,7 +497,7 @@ public class NotEnoughUpdates {
if(longUpdate) {
updateSkyblockScoreboard();
if(hasSkyblockScoreboard()) {
- manager.auctionManager.tick();
+ lastSkyblockScoreboard = currentTime;
if(!joinedSB && manager.config.showUpdateMsg.value) {
joinedSB = true;
displayUpdateMessageIfOutOfDate();
@@ -480,6 +518,11 @@ public class NotEnoughUpdates {
SBScoreboardData.getInstance().tick();
//GuiQuestLine.questLine.tick();
}
+ if(currentTime - lastSkyblockScoreboard < 5*60*1000) { //5 minutes
+ manager.auctionManager.tick();
+ } else {
+ manager.auctionManager.markNeedsUpdate();
+ }
//ItemRarityHalo.resetItemHaloCache();
}
if(currChatMessage != null && currentTime - lastChatMessage > CHAT_MSG_COOLDOWN) {
@@ -487,49 +530,61 @@ public class NotEnoughUpdates {
Minecraft.getMinecraft().thePlayer.sendChatMessage(currChatMessage);
currChatMessage = null;
}
- if(longUpdate && hasSkyblockScoreboard() && manager.getCurrentProfile() != null && manager.getCurrentProfile().length() > 0) {
- HashSet<String> newItem = new HashSet<>();
- if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer &&
- !(Minecraft.getMinecraft().currentScreen instanceof GuiCrafting)) {
- boolean usableContainer = true;
- for(ItemStack stack : Minecraft.getMinecraft().thePlayer.openContainer.getInventory()) {
- if(stack == null) {
- continue;
+ if(longUpdate && hasSkyblockScoreboard()) {
+ if(manager.getCurrentProfile() == null || manager.getCurrentProfile().length() == 0) {
+ ProfileViewer.Profile profile = profileViewer.getProfile(
+ Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""), (json) -> {});
+ if(profile != null) {
+ String latest = profile.getLatestProfile();
+ if(latest != null) {
+ manager.setCurrentProfileBackup(profile.getLatestProfile());
}
- if(stack.hasTagCompound()) {
- NBTTagCompound tag = stack.getTagCompound();
- if(tag.hasKey("ExtraAttributes", 10)) {
+ }
+ }
+ if(manager.getCurrentProfile() != null && manager.getCurrentProfile().length() > 0) {
+ HashSet<String> newItem = new HashSet<>();
+ if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer &&
+ !(Minecraft.getMinecraft().currentScreen instanceof GuiCrafting)) {
+ boolean usableContainer = true;
+ for(ItemStack stack : Minecraft.getMinecraft().thePlayer.openContainer.getInventory()) {
+ if(stack == null) {
continue;
}
+ if(stack.hasTagCompound()) {
+ NBTTagCompound tag = stack.getTagCompound();
+ if(tag.hasKey("ExtraAttributes", 10)) {
+ continue;
+ }
+ }
+ usableContainer = false;
+ break;
}
- usableContainer = false;
- break;
- }
- if(!usableContainer) {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest container = (ContainerChest) chest.inventorySlots;
- String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
-
- if(containerName.equals("Accessory Bag")) {
- usableContainer = true;
+ if(!usableContainer) {
+ if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+ String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
+
+ if(containerName.equals("Accessory Bag") || containerName.startsWith("Wardrobe")) {
+ usableContainer = true;
+ }
}
}
- }
- if(usableContainer) {
- for(ItemStack stack : Minecraft.getMinecraft().thePlayer.openContainer.getInventory()) {
- processUniqueStack(stack, newItem);
+ if(usableContainer) {
+ for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
+ processUniqueStack(stack, newItem);
+ }
+ for(ItemStack stack : Minecraft.getMinecraft().thePlayer.openContainer.getInventory()) {
+ processUniqueStack(stack, newItem);
+ }
}
+ } else {
for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
processUniqueStack(stack, newItem);
}
}
- } else {
- for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
- processUniqueStack(stack, newItem);
- }
+ newItemAddMap.keySet().retainAll(newItem);
}
- newItemAddMap.keySet().retainAll(newItem);
}
}
@@ -859,7 +914,6 @@ public class NotEnoughUpdates {
public void onGuiScreenDrawPost(GuiScreenEvent.DrawScreenEvent.Post event) {
if(!(event.gui instanceof CustomAHGui || manager.auctionManager.customAH.isRenderOverAuctionView())) {
if(shouldRenderOverlay(event.gui) && isOnSkyblock()) {
-
renderDungeonChestOverlay(event.gui);
if(!focusInv) {
@@ -947,7 +1001,6 @@ public class NotEnoughUpdates {
guiTop+14, true, 170, Color.BLACK.getRGB());
Utils.drawStringCenteredScaledMaxWidth(plString, Minecraft.getMinecraft().fontRendererObj, guiLeft+xSize+4+90,
guiTop+28, true, 170, Color.BLACK.getRGB());
-
}
} catch(Exception e) {
e.printStackTrace();
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 6b29655c..33012194 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
@@ -45,7 +45,9 @@ public class APIManager {
private long lastShortAuctionUpdate = 0;
private long lastCustomAHSearch = 0;
private long lastCleanup = 0;
+
private long lastApiUpdate = 0;
+ private long firstHypixelApiUpdate = 0;
public int activeAuctions = 0;
public int uniqueItems = 0;
@@ -112,6 +114,11 @@ public class APIManager {
}
}
+ public void markNeedsUpdate() {
+ firstHypixelApiUpdate = 0;
+ pagesToDownload = null;
+ }
+
public void tick() {
if(manager.config.apiKey.value == null || manager.config.apiKey.value.isEmpty()) return;
@@ -211,7 +218,7 @@ public class APIManager {
Set<String> toRemove = new HashSet<>();
for(Map.Entry<String, Auction> entry : auctionMap.entrySet()) {
long timeToEnd = entry.getValue().end - currTime;
- if(timeToEnd < -60) {
+ if(timeToEnd < -120*1000) { //2 minutes
toRemove.add(entry.getKey());
}
}
@@ -243,13 +250,15 @@ public class APIManager {
}
private void updatePageTickShort() {
+ if(pagesToDownload == null || pagesToDownload.isEmpty()) return;
+
+ if(firstHypixelApiUpdate == 0 || (System.currentTimeMillis() - firstHypixelApiUpdate)%(60*1000) > 15*1000) return;
+
JsonObject disable = Utils.getConstant("disable");
if(disable != null && disable.get("auctions").getAsBoolean()) return;
- if(pagesToDownload == null) {
- getPageFromAPI(0);
- } else if(!pagesToDownload.isEmpty()) {
- int page = pagesToDownload.getFirst();
+ while(!pagesToDownload.isEmpty()) {
+ int page = pagesToDownload.pop();
getPageFromAPI(page);
}
}
@@ -258,6 +267,10 @@ public class APIManager {
JsonObject disable = Utils.getConstant("disable");
if(disable != null && disable.get("auctions").getAsBoolean()) return;
+ if(pagesToDownload == null) {
+ getPageFromAPI(0);
+ }
+
manager.hypixelApi.getApiGZIPAsync("http://moulberry.codes/auction.json.gz", jsonObject -> {
if(jsonObject.get("success").getAsBoolean()) {
long apiUpdate = (long)jsonObject.get("time").getAsFloat();
@@ -269,18 +282,21 @@ public class APIManager {
JsonArray new_auctions = jsonObject.get("new_auctions").getAsJsonArray();
for(JsonElement auctionElement : new_auctions) {
JsonObject auction = auctionElement.getAsJsonObject();
+ //System.out.println("New auction " + auction);
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();
+ //System.out.println("new bid" + newBidUUID);
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) {
+ //System.out.println("Setting auction " + newBidUUID + " price to " + newBidAmount);
auc.highest_bid_amount = newBidAmount;
auc.end = end;
auc.bid_count = bid_count;
@@ -456,10 +472,10 @@ public class APIManager {
if(itemType >= 0 && itemType < categoryItemType.length) {
category = categoryItemType[itemType];
}
- if(internalname.contains("ENCHANTED_BOOK")) category = "ebook";
- if(extras.endsWith("Potion")) category = "potion";
- if(extras.contains("Rune")) category = "rune";
- if(item_lore.split("\n")[0].endsWith("Furniture")) category = "furniture";
+ if(category.equals("consumables") && extras.contains("enchanted book")) category = "ebook";
+ if(category.equals("consumables") && extras.endsWith("potion")) category = "potion";
+ if(category.equals("misc") && extras.contains("rune")) category = "rune";
+ if(category.equals("misc") && item_lore.split("\n")[0].endsWith("Furniture")) category = "furniture";
if(item_lore.split("\n")[0].endsWith("Pet") ||
item_lore.split("\n")[0].endsWith("Mount")) category = "pet";
@@ -500,7 +516,9 @@ public class APIManager {
pagesToDownload.add(i);
}
}
- pagesToDownload.remove(Integer.valueOf(page));
+ if(firstHypixelApiUpdate == 0) {
+ firstHypixelApiUpdate = jsonObject.get("lastUpdated").getAsLong();
+ }
activeAuctions = jsonObject.get("totalAuctions").getAsInt();
long startProcess = System.currentTimeMillis();
@@ -511,7 +529,11 @@ public class APIManager {
processAuction(auction);
}
processMillis = (int)(System.currentTimeMillis() - startProcess);
+ } else {
+ pagesToDownload.addLast(page);
}
+ }, () -> {
+ pagesToDownload.addLast(page);
}
);
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java
index 331ba8b1..9b42f5a6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java
+++ b/