aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/CountdownCalculator.kt29
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/WarpDessert.kt2
2 files changed, 18 insertions, 13 deletions
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/CountdownCalculator.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/CountdownCalculator.kt
index 068e735b..4431d3bd 100644
--- a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/CountdownCalculator.kt
+++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/CountdownCalculator.kt
@@ -32,9 +32,9 @@ import java.time.format.DateTimeFormatter
— Erymanthus / RayDeeUx (code base, math, timestamp wrangling, adaptation into overall NEU codebase)
— nea89 (enum, regex wrangling, ItemTooltipEvent integration, cleanup)
- Intended to detect countdowns within item tooltips, converting the time remaining into
- units of seconds, and then adding that result to the user's current system time
- in Unix epoch form converted into a human-readable timestamp, timezones included.
+ Intended to detect countdowns within item tooltips and then adding that result
+ to the user's current system time in Unix epoch form converted into a
+ human-readable timestamp relative to the system timezone.
Formerly a feature from SkyBlockCatia, then later attempted to be ported into Skytils.
Now has a comfy home in the NotEnoughUpdates codebase.
@@ -62,6 +62,7 @@ class CountdownCalculator {
TIMELEFT("Time left:", "Ends at"),
EVENTTIMELEFT("Event lasts for", "Ends at", isRelative = true),
SHENSUCKS("Auction ends in:", "Auction ends at"),
+ TAMINGSIXTYWASAMISTAKE("Ends:", "Finishes at"), // There would be a more specific message here seeing as this is for pet XP, but knowing Hypixel it's probably safer to leave it like this in case they use the "Ends:" prefix elsewhere besides the pet training menus.
CALENDARDETAILS(" (§e", "Starts at"); // Calendar details
}
@@ -79,15 +80,15 @@ class CountdownCalculator {
val tooltipLine = event.toolTip[i]
val countdownKind = CountdownTypes.values().find { it.match in tooltipLine } ?: continue
val match = regex.findAll(tooltipLine).maxByOrNull { it.value.length } ?: continue
-
- val years = match.groups["years"]?.value?.toInt() ?: 0
- val days = match.groups["days"]?.value?.toInt() ?: 0
- val hours = match.groups["hours"]?.value?.toInt() ?: 0
- val minutes = match.groups["minutes"]?.value?.toInt() ?: 0
- val seconds = match.groups["seconds"]?.value?.toInt() ?: 0
+ if (countdownKind == CountdownTypes.CALENDARDETAILS && !event.itemStack.displayName.startsWith("§aDay ")) return
+ val years = match.groups["years"]?.value?.toLong() ?: 0L
+ val days = match.groups["days"]?.value?.toLong() ?: 0L
+ val hours = match.groups["hours"]?.value?.toLong() ?: 0L
+ val minutes = match.groups["minutes"]?.value?.toLong() ?: 0L
+ val seconds = match.groups["seconds"]?.value?.toLong() ?: 0L
val totalSeconds = (years * 31_536_000L) + (days * 86_400L) + (hours * 3_600L) + (minutes * 60L) + seconds
if (totalSeconds == 0L) continue
- if (years != 0) formatterAsString = "${formatterAsString} yyyy"
+ if (years != 0L) formatterAsString = "${formatterAsString} yyyy"
val useFormatter = DateTimeFormatter.ofPattern(formatterAsString)!!
val countdownTarget = if (countdownKind.isRelative) {
if (lastTimer == null) {
@@ -96,8 +97,8 @@ class CountdownCalculator {
"§r§cThe above countdown is relative, but I can't find another countdown. [NEU]"
)
continue
- } else lastTimer.plusSeconds(totalSeconds)
- } else ZonedDateTime.now().plusSeconds(totalSeconds)
+ } else lastTimer.addTime(years, days, hours, minutes, seconds)
+ } else ZonedDateTime.now().addTime(years, days, hours, minutes, seconds)
val countdownTargetFormatted = useFormatter.format(countdownTarget)
event.toolTip.add(
++i,
@@ -108,4 +109,8 @@ class CountdownCalculator {
}
}
+ private fun ZonedDateTime.addTime(years: Long, days: Long, hours: Long, minutes: Long, seconds: Long): ZonedDateTime {
+ return this.plusYears(years).plusDays(days).plusHours(hours).plusMinutes(minutes).plusSeconds(seconds)
+ }
}
+
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/WarpDessert.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/WarpDessert.kt
index f6f272b9..a41ff3e3 100644
--- a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/WarpDessert.kt
+++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/WarpDessert.kt
@@ -29,7 +29,7 @@ object WarpDessert {
val message = packet.message.lowercase()
if (message == "/warp dessert") {
Minecraft.getMinecraft().thePlayer.sendChatMessage("/warp desert")
- Utils.addChatMessage("§eDid someone say §d§lDessert§e? Sand is yummy!")
+ Utils.addChatMessage("§e[NEU] Did someone say §d§lDessert§e? Sand is yummy!")
return true
}
return false