aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java
diff options
context:
space:
mode:
authorErymanthus[#5074] | (u/)RayDeeUx <51521765+RayDeeUx@users.noreply.github.com>2023-10-20 10:46:58 -0400
committerGitHub <noreply@github.com>2023-10-20 16:46:58 +0200
commit5e3a573493a47f9a6208093925a8c4b5d1f324ce (patch)
tree732d821690dd941ef520a1f15315528870ed9668 /src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java
parentbf7467b5808a9868877b1766aa6a3bfa16c8f605 (diff)
downloadnotenoughupdates-5e3a573493a47f9a6208093925a8c4b5d1f324ce.tar.gz
notenoughupdates-5e3a573493a47f9a6208093925a8c4b5d1f324ce.tar.bz2
notenoughupdates-5e3a573493a47f9a6208093925a8c4b5d1f324ce.zip
Feature: CountdownCalculator (collab with @nea89o) (#874)
* COUNTDOWNCALCULATOR IS COMING HOME * COUNTDOWNCALCULATOR IS COMING HOME LESGO * condense labels * fix compile * fix compile (ty nopo) + fix mismatch in .kt class * remove timezone * consistency with nopo's changes * prevent empty lines from being added to neucal * remove seconds, fix math for calendaroverlay.java * shen label mayhaps? * attempt to fix calculation errors * bloody fuckoing hell * ok this *SHOULD* fix everything * rm debug msgs * add ampm back to ampx format overlay * forogt what the emdyhmas format was * rm useless conditional --------- Co-authored-by: nopo <nopotheemail@gmail.com>
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java
index c83b310c..4e4b147e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java
@@ -63,6 +63,8 @@ import org.lwjgl.opengl.GL11;
import java.io.File;
import java.time.Duration;
import java.time.Instant;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
@@ -140,6 +142,8 @@ public class CalendarOverlay {
"NEU Calendar Item"
); // Star Cult Stack
+ private boolean canAddcountdownCalc = (NotEnoughUpdates.INSTANCE.config.misc.showWhenCountdownEnds == 1 || NotEnoughUpdates.INSTANCE.config.misc.showWhenCountdownEnds == 2);
+
static {
NBTTagCompound tag = new NBTTagCompound();
tag.setString("event_id", "dark_auction");
@@ -730,12 +734,15 @@ public class CalendarOverlay {
sbEvent.display,
EnumChatFormatting.GRAY + "Starts in: " + EnumChatFormatting.YELLOW + prettyTime(timeUntilMillis, false)
);
+ addCountdownCalculatorToTooltip(timeUntilMillis, tooltipToDisplay);
if (sbEvent.lastsFor >= 0) {
tooltipToDisplay.add(EnumChatFormatting.GRAY + "Lasts for: " + EnumChatFormatting.YELLOW +
prettyTime(sbEvent.lastsFor, true));
+ addCountdownCalculatorToTooltip(sbEvent.lastsFor + timeUntilMillis, tooltipToDisplay);
if (timeUntilMillis < 0) {
tooltipToDisplay.add(EnumChatFormatting.GRAY + "Time left: " + EnumChatFormatting.YELLOW +
prettyTime(sbEvent.lastsFor + timeUntilMillis, true));
+ addCountdownCalculatorToTooltip(timeUntilMillis, tooltipToDisplay);
}
}
if (sbEvent.desc != null) {
@@ -786,6 +793,10 @@ public class CalendarOverlay {
Instant.now(),
Instant.ofEpochMilli(pair.getFirst())
)));
+ addCountdownCalculatorToTooltip(Duration.between(
+ Instant.now(),
+ Instant.ofEpochMilli(pair.getFirst())
+ ).toMillis(), tooltipToDisplay);
}
}
}
@@ -830,12 +841,15 @@ public class CalendarOverlay {
nextEvent.display,
EnumChatFormatting.GRAY + "Starts in: " + EnumChatFormatting.YELLOW + prettyTime(timeUntilNext, false)
);
+ addCountdownCalculatorToTooltip(timeUntilNext, tooltipToDisplay);
if (nextEvent.lastsFor >= 0) {
tooltipToDisplay.add(EnumChatFormatting.GRAY + "Lasts for: " + EnumChatFormatting.YELLOW +
prettyTime(nextEvent.lastsFor, true));
+ addCountdownCalculatorToTooltip(nextEvent.lastsFor + timeUntilNext, tooltipToDisplay);
if (timeUntilNext < 0) {
tooltipToDisplay.add(EnumChatFormatting.GRAY + "Time left: " + EnumChatFormatting.YELLOW +
prettyTime(nextEvent.lastsFor + timeUntilNext, true));
+ addCountdownCalculatorToTooltip(nextEvent.lastsFor + timeUntilNext, tooltipToDisplay);
}
}
@@ -1471,12 +1485,15 @@ public class CalendarOverlay {
tooltipToDisplay.add(sbEvent.display);
tooltipToDisplay.add(
EnumChatFormatting.GRAY + "Starts in: " + EnumChatFormatting.YELLOW + prettyTime(timeUntil, false));
+ addCountdownCalculatorToTooltip(timeUntil, tooltipToDisplay);
if (sbEvent.lastsFor >= 0) {
tooltipToDisplay.add(EnumChatFormatting.GRAY + "Lasts for: " + EnumChatFormatting.YELLOW +
prettyTime(sbEvent.lastsFor, true));
+ addCountdownCalculatorToTooltip(sbEvent.lastsFor + timeUntil, tooltipToDisplay);
if (timeUntil < 0) {
tooltipToDisplay.add(EnumChatFormatting.GRAY + "Time left: " + EnumChatFormatting.YELLOW +
prettyTime(sbEvent.lastsFor + timeUntil, true));
+ addCountdownCalculatorToTooltip(sbEvent.lastsFor + timeUntil, tooltipToDisplay);
}
}
if (sbEvent.id.split(":")[0].equals("jacob_farming") && sbEvent.desc != null) {
@@ -1491,9 +1508,11 @@ public class CalendarOverlay {
tooltipToDisplay.add(nextMayorEvent.display);
tooltipToDisplay.add(EnumChatFormatting.GRAY + "Starts in: " + EnumChatFormatting.YELLOW +
prettyTime(timeUntilMayor, false));
+ addCountdownCalculatorToTooltip(timeUntilMayor, tooltipToDisplay);
if (nextMayorEvent.lastsFor >= 0) {
tooltipToDisplay.add(EnumChatFormatting.GRAY + "Lasts for: " + EnumChatFormatting.YELLOW +
prettyTime(nextMayorEvent.lastsFor, true));
+ addCountdownCalculatorToTooltip(nextMayorEvent.lastsFor + timeUntilMayor, tooltipToDisplay);
}
}
@@ -1636,4 +1655,14 @@ public class CalendarOverlay {
return endsIn;
}
+
+ private List<String> addCountdownCalculatorToTooltip(long millis, List<String> tooltipToModify) {
+ if (NotEnoughUpdates.INSTANCE.config.misc.showWhenCountdownEnds == 1 || NotEnoughUpdates.INSTANCE.config.misc.showWhenCountdownEnds == 2) {
+ String formatString = "EEEE, MMM d h:mm a";
+ if (NotEnoughUpdates.INSTANCE.config.misc.showWhenCountdownEnds == 2) { formatString = "EEEE, MMM d HH:mm"; }
+ tooltipToModify.add("§b" + DateTimeFormatter.ofPattern(formatString).format(ZonedDateTime.now().plusSeconds(((millis / 1000)))));
+
+ }
+ return tooltipToModify;
+ }
}