aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorCobble8 <41165207+Cobble8@users.noreply.github.com>2022-04-27 14:56:23 -0400
committerGitHub <noreply@github.com>2022-04-27 20:56:23 +0200
commit79bc28639e966415a97b1f21dd11617c6a4e0215 (patch)
treeb0bd24f4298a7b2e83f47cafe43cef441878443f /src/main/java
parent68b565d762c549bf5c1fe6bb2b57b14c37618a1e (diff)
downloadNotEnoughUpdates-79bc28639e966415a97b1f21dd11617c6a4e0215.tar.gz
NotEnoughUpdates-79bc28639e966415a97b1f21dd11617c6a4e0215.tar.bz2
NotEnoughUpdates-79bc28639e966415a97b1f21dd11617c6a4e0215.zip
HEAVY PEARL TODO TIMER THING (#120)
* HEAVY PEARL TODO TIMER THING yay hopefully this works idk don't wanna wait 21 hours to test it again but Im pretty confident it works * fix bad change thing hopefully idk maybe * fix formatting + 2.1.md 🙂 * fix formatting * fixed heavy pearls overriding gemstone powder Co-authored-by: NopoTheGamer <noahogno@gmail.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/ScoreboardLocationChangeListener.java30
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java16
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java86
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java5
6 files changed, 137 insertions, 4 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java
index d40a39f1..060dcb80 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java
@@ -6,6 +6,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.CrystalMetalDetectorSol
import io.github.moulberry.notenoughupdates.miscfeatures.StreamerMode;
import io.github.moulberry.notenoughupdates.overlays.OverlayManager;
import io.github.moulberry.notenoughupdates.overlays.SlayerOverlay;
+import io.github.moulberry.notenoughupdates.overlays.TimersOverlay;
import io.github.moulberry.notenoughupdates.util.SBInfo;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
@@ -122,6 +123,7 @@ public class ChatListener {
public void onGuiChat(ClientChatReceivedEvent e) {
if (e.type == 2) {
CrystalMetalDetectorSolver.process(e.message);
+ TimersOverlay.processActionBar(e.message.getUnformattedText());
e.message = processChatComponent(e.message);
return;
} else if (e.type == 0) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ScoreboardLocationChangeListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ScoreboardLocationChangeListener.java
new file mode 100644
index 00000000..2f4ec33c
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ScoreboardLocationChangeListener.java
@@ -0,0 +1,30 @@
+package io.github.moulberry.notenoughupdates.listener;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.overlays.TimersOverlay;
+
+public class ScoreboardLocationChangeListener {
+
+ public ScoreboardLocationChangeListener(String oldLocation, String newLocation) {
+ if (oldLocation.equals("Belly of the Beast") && newLocation.equals("Matriarchs Lair")) {
+ //Check inventory pearl count for AFTER they complete to see if it is the same as before + (amount available on actionbar)
+ Thread thread = new Thread(() -> {
+ try {
+ Thread.sleep(3000);
+ TimersOverlay.afterPearls = TimersOverlay.heavyPearlCount();
+ //Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW+"You exited the beast with ["+EnumChatFormatting.AQUA+(TimersOverlay.afterPearls-TimersOverlay.beforePearls)+EnumChatFormatting.YELLOW+"/"+EnumChatFormatting.AQUA+TimersOverlay.availablePearls+EnumChatFormatting.YELLOW+"] Heavy Pearls!"));
+ if (TimersOverlay.afterPearls - TimersOverlay.beforePearls == TimersOverlay.availablePearls) {
+ NotEnoughUpdates.INSTANCE.config.getProfileSpecific().dailyHeavyPearlCompleted = System.currentTimeMillis();
+ //Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+"Daily "+EnumChatFormatting.DARK_AQUA+"Heavy Pearls"+EnumChatFormatting.GREEN+" Complete!"));
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ });
+ thread.start();
+ } else if (oldLocation.equals("Matriarchs Lair") && newLocation.equals("Belly of the Beast")) {
+ //Check inventory pearl count BEFORE they complete so we can later check if it is complete.
+ TimersOverlay.beforePearls = TimersOverlay.heavyPearlCount();
+ }
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
index 68449ba8..5c766254 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
@@ -510,6 +510,8 @@ public class NEUConfig extends Config {
public long dailyGemstonePowderCompleted = 0L;
@Expose
public long dailyMithrilPowerCompleted = 0L;
+ @Expose
+ public long dailyHeavyPearlCompleted = 0L;
}
public HiddenLocationSpecific getLocationSpecific() {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java
index 849f5823..616e8188 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java
@@ -42,10 +42,11 @@ public class MiscOverlays {
"\u00a73Experiments: \u00a7e3h38m",
"\u00a73Daily Mithril Powder: \u00a7e3h38m",
"\u00a73Daily Gemstone Powder: \u00a7e3h38m",
+ "\u00a73Daily Heavy Pearls: \u00a7e3h38m",
}
)
@ConfigAccordionId(id = 0)
- public List<Integer> todoText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8));
+ public List<Integer> todoText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9));
@ConfigOption(
name = "Show Only If Soon",
@@ -163,6 +164,19 @@ public class MiscOverlays {
)
public int dailyGemstonePowderDisplay = 0;
+ @Expose
+ @ConfigOption(
+ name = "Daily Heavy Pearl Display",
+ desc = "Change the way the daily heavy pearl displays\n" +
+ "Only when ready, When very Soon, When soon, When kinda soon or always."
+ )
+ @ConfigAccordionId(id = 1)
+ @ConfigEditorDropdown(
+ values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
+ )
+
+ public int dailyHeavyPearlDisplay = 0;
+
@ConfigOption(
name = "Colours",
desc = ""
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
index ede30448..59a77ea3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
@@ -13,6 +13,7 @@ import net.minecraft.init.Items;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
@@ -186,6 +187,11 @@ public class TimersOverlay extends TextOverlay {
.getItemInformation()
.get("PERFECT_AMETHYST_GEM"));
break;
+ case "Daily Heavy Pearls":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("HEAVY_PEARL"));
+ break;
}
if (icon != null) {
@@ -529,6 +535,7 @@ public class TimersOverlay extends TextOverlay {
}
long midnightReset = (currentTime - 18000000) / 86400000 * 86400000 + 18000000; // 12am est
+ long pearlsReset = midnightReset - 14400000 + 86400000; //8pm est
long catacombsReset = currentTime / 86400000 * 86400000; // 7pm est
long timeDiffMidnightNow = midnightReset + 86400000 - currentTime;
long catacombsDiffNow = catacombsReset + 86400000 - currentTime;
@@ -743,6 +750,49 @@ public class TimersOverlay extends TextOverlay {
);
}
+ //Daily Heavy Pearl Display
+ if (hidden.dailyHeavyPearlCompleted < pearlsReset) {
+ map.put(
+ 9,
+ DARK_AQUA + "Daily Heavy Pearls: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour] + "Ready!"
+ );
+ } else if (
+ NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyHeavyPearlDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
+ (hidden.dailyHeavyPearlCompleted < (pearlsReset - TimeEnums.HALFANHOUR.time))) {
+ map.put(
+ 9,
+ DARK_AQUA + "Daily Heavy Pearls: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] +
+ Utils.prettyTime(pearlsReset + 86400000 - currentTime)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyHeavyPearlDisplay >= DISPLAYTYPE.SOON.ordinal() &&
+ (hidden.dailyHeavyPearlCompleted < (pearlsReset - TimeEnums.HOUR.time))) {
+ map.put(
+ 9,
+ DARK_AQUA + "Daily Heavy Pearls: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] +
+ Utils.prettyTime(pearlsReset + 86400000 - currentTime)
+ );
+ } else if (
+ NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyHeavyPearlDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
+ (hidden.dailyHeavyPearlCompleted < (pearlsReset - (TimeEnums.HOUR.time * 3)))) {
+ map.put(
+ 9,
+ DARK_AQUA + "Daily Heavy Pearls: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] +
+ Utils.prettyTime(pearlsReset + 86400000 - currentTime)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyHeavyPearlDisplay >=
+ DISPLAYTYPE.ALWAYS.ordinal()) {
+ map.put(
+ 9,
+ DARK_AQUA + "Daily Heavy Pearls: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] +
+ Utils.prettyTime(pearlsReset + 86400000 - currentTime)
+ );
+ }
+
overlayStrings = new ArrayList<>();
for (int index : NotEnoughUpdates.INSTANCE.config.miscOverlays.todoText2) {
if (map.containsKey(index)) {
@@ -752,8 +802,40 @@ public class TimersOverlay extends TextOverlay {
if (overlayStrings.isEmpty()) overlayStrings = null;
}
- public String compactRemaining(int amount) {
- return (5 - amount) + " remaining";
+ public static int beforePearls = -1;
+ public static int afterPearls = -1;
+ public static int availablePearls = -1;
+ public static int heavyPearlCount() {
+ int heavyPearls = 0;
+
+ List<ItemStack> inventory = Minecraft.getMinecraft().thePlayer.inventoryContainer.getInventory();
+ for (ItemStack item : inventory) {
+ if (item == null) {
+ continue;
+ } else if (!item.hasTagCompound()) {
+ continue;
+ }
+ NBTTagCompound itemData = item.getSubCompound("ExtraAttributes", false);
+ if (itemData == null) {
+ continue;
+ }
+ if (itemData.getString("id").equals("HEAVY_PEARL")) {
+ heavyPearls += item.stackSize;
+ }
+ }
+ return heavyPearls;
+ }
+
+ public static void processActionBar(String msg) {
+ if(SBInfo.getInstance().location.equals("Belly of the Beast")) {
+ try {
+ msg = Utils.cleanColour(msg);
+ msg = msg.substring(msg.indexOf("Pearls Collected: ")+18);
+ availablePearls = Integer.parseInt(msg.substring(msg.indexOf("/")+1));
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
}
private enum TimeEnums {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
index f1e40671..6519d547 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
@@ -3,6 +3,7 @@ package io.github.moulberry.notenoughupdates.util;
import com.google.common.reflect.TypeToken;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.listener.ScoreboardLocationChangeListener;
import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent;
import io.github.moulberry.notenoughupdates.overlays.SlayerOverlay;
import net.minecraft.client.Minecraft;
@@ -367,7 +368,9 @@ public class SBInfo {
//Replaced with for loop because in crystal hollows with events the line it's on can shift.
for (String line : lines) {
if (line.contains("⏣")) {
- location = Utils.cleanColour(line).replaceAll("[^A-Za-z0-9() ]", "").trim();
+ String l = Utils.cleanColour(line).replaceAll("[^A-Za-z0-9() ]", "").trim();
+ if(!l.equals(location)) { new ScoreboardLocationChangeListener(location, l); }
+ location = l;
break;
}
}