aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2023-02-22 18:33:20 +0100
committerGitHub <noreply@github.com>2023-02-22 18:33:20 +0100
commitcf3f08e4fd340ab331a4b61c1159fb527027ade7 (patch)
treef0fa524ef72817eeab73bdacc6df0f360b646060 /src/main
parent30bd46e46aab73e2927fa5631c49ace84708e590 (diff)
downloadNotEnoughUpdates-cf3f08e4fd340ab331a4b61c1159fb527027ade7.tar.gz
NotEnoughUpdates-cf3f08e4fd340ab331a4b61c1159fb527027ade7.tar.bz2
NotEnoughUpdates-cf3f08e4fd340ab331a4b61c1159fb527027ade7.zip
Added Sky Mall to Dwarven Overlay (#604)
* Added Sky Mall to Dwarven Overlay. * Made SkyBlockTime a data object. * Added color to names and display item per different perk variant. * Added daySuffix support for days greater 10. * Data classes have a copy method already. * Green color does not work. * Fixed a bug in monthName. * Add Unit Tests and make use of Instant * Fixed Sky Mall overlay showing in crystal hollows. * 11st 12nd 13rd --------- Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: nea <nea@nea.moe> Co-authored-by: nopo <nopotheemail@gmail.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java15
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java32
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/guifeatures/SkyMallDisplay.kt103
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/util/SkyBlockTime.kt122
5 files changed, 259 insertions, 21 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 301a90b9..baea367c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java
@@ -129,11 +129,11 @@ public class CalendarOverlay {
private static final long HOUR = MINUTE * 60;
private static final long DAY = HOUR * 24;
- private static final long DA_OFFSET = 1000 * 60 * 55;
- private static final long JF_OFFSET = 1000 * 60 * 15;
+ private static final long DA_OFFSET = 1000 * 60 * 55; // Dark Auction
+ private static final long JF_OFFSET = 1000 * 60 * 15; // Jacob's Farming Contest
- private static final ItemStack DA_STACK;
- private static final ItemStack JF_STACK;
+ private static final ItemStack DA_STACK; // Dark Auction
+ private static final ItemStack JF_STACK; // Jacob's Farming Contest
static {
NBTTagCompound tag = new NBTTagCompound();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java
index 74400f59..e1b2662a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java
@@ -152,16 +152,17 @@ public class Mining {
)
@ConfigEditorDraggableList(
exampleText = {
- "\u00a73Goblin Slayer: \u00a7626.5%\n\u00a73Lucky Raffle: \u00a7c0.0%",
- "\u00a73Mithril Powder: \u00a726,243",
- "\u00a73Gemstone Powder: \u00a7d6,243",
- "\u00a73Forge 1) \u00a79Diamonite\u00a77: \u00a7aReady!",
- "\u00a73Pickaxe CD: \u00a7a78s",
- "\u00a73Star Cult: \u00a7a78s"
+ "§3Goblin Slayer: §626.5%\n§3Lucky Raffle: §c0.0%",
+ "§3Mithril Powder: §26,243",
+ "§3Gemstone Powder: §d6,243",
+ "§3Forge 1) §9Diamonite§7: §aReady!",
+ "§3Pickaxe CD: §a78s",
+ "§3Star Cult: §a78s",
+ "§3Sky Mall: §a5x Titanium (78s)"
}
)
@ConfigAccordionId(id = 2)
- public List<Integer> dwarvenText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5));
+ public List<Integer> dwarvenText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6));
@Expose
public Position overlayPosition = new Position(10, 100);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java
index ea253e94..db1a7755 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java
@@ -24,6 +24,7 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.config.Position;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils;
+import io.github.moulberry.notenoughupdates.guifeatures.SkyMallDisplay;
import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.util.SBInfo;
@@ -45,6 +46,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -439,6 +441,12 @@ public class MiningOverlay extends TextTabOverlay {
DARK_AQUA + "Star Cult: " + GREEN +
StarCultCalculator.getNextStarCult());
break;
+ case 6:
+
+ if (Objects.equals(SBInfo.getInstance().getLocation(), "mining_3")) {
+ overlayStrings.add("§3Sky Mall: §a" + SkyMallDisplay.Companion.getDisplayText());
+ }
+ break;
}
}
} else {
@@ -714,17 +722,17 @@ public class MiningOverlay extends TextTabOverlay {
String cleaned = Utils.cleanColour(line);
String beforeColon = cleaned.split(":")[0];
- if (miningOverlayCommisionItems == null) {
- setupMiningOverlayCommisionItems();
+ if (miningOverlayCommissionItems == null) {
+ setupMiningOverlayCommissionItems();
}
- if (miningOverlayCommisionItems.containsKey(beforeColon)) {
- icon = miningOverlayCommisionItems.get(beforeColon);
+ if (miningOverlayCommissionItems.containsKey(beforeColon)) {
+ icon = miningOverlayCommissionItems.get(beforeColon);
} else {
if (beforeColon.startsWith("Forge")) {
- icon = miningOverlayCommisionItems.get("Forge");
+ icon = miningOverlayCommissionItems.get("Forge");
} else if (beforeColon.contains("Mithril")) {
- icon = miningOverlayCommisionItems.get("Mithril");
+ icon = miningOverlayCommissionItems.get("Mithril");
} else if (beforeColon.endsWith(" Gemstone Collector")) {
String gemName = "ROUGH_"
+ beforeColon.replace(" Gemstone Collector", "").toUpperCase() + "_GEM";
@@ -748,7 +756,11 @@ public class MiningOverlay extends TextTabOverlay {
miningOverlayPerfectGems.put(gemName, icon);
}
} else if (beforeColon.contains("Titanium")) {
- icon = miningOverlayCommisionItems.get("Titanium");
+ icon = miningOverlayCommissionItems.get("Titanium");
+ } else if (beforeColon.contains("Sky Mall")) {
+ if (Objects.equals(SBInfo.getInstance().getLocation(), "mining_3")) {
+ icon = SkyMallDisplay.Companion.getDisplayItem();
+ }
}
}
@@ -768,10 +780,10 @@ public class MiningOverlay extends TextTabOverlay {
private static final HashMap<String, ItemStack> miningOverlayRoughGems = new HashMap<String, ItemStack>() {};
private static final HashMap<String, ItemStack> miningOverlayPerfectGems = new HashMap<String, ItemStack>() {};
- private static HashMap<String, ItemStack> miningOverlayCommisionItems;
+ private static HashMap<String, ItemStack> miningOverlayCommissionItems;
- private static void setupMiningOverlayCommisionItems() {
- miningOverlayCommisionItems = new HashMap<String, ItemStack>() {{
+ private static void setupMiningOverlayCommissionItems() {
+ miningOverlayCommissionItems = new HashMap<String, ItemStack>() {{
put(
"Mithril Powder",
NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/guifeatures/SkyMallDisplay.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/guifeatures/SkyMallDisplay.kt
new file mode 100644
index 00000000..2821473b
--- /dev/null
+++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/guifeatures/SkyMallDisplay.kt
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2023 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.guifeatures
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates
+import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe
+import io.github.moulberry.notenoughupdates.util.SBInfo
+import io.github.moulberry.notenoughupdates.util.SkyBlockTime
+import io.github.moulberry.notenoughupdates.util.Utils
+import net.minecraft.init.Items
+import net.minecraft.item.ItemStack
+import net.minecraftforge.client.event.ClientChatReceivedEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.time.Duration
+import java.time.Instant
+import java.util.regex.Pattern
+
+@NEUAutoSubscribe
+class SkyMallDisplay {
+
+ private val pattern = Pattern.compile("§r§eNew buff§r§r§r: (.*)§r")
+
+ @SubscribeEvent(receiveCanceled = true)
+ fun onChatReceive(event: ClientChatReceivedEvent) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return
+ if (SBInfo.getInstance().getLocation() != "mining_3") return
+
+ val matcher = pattern.matcher(event.message.formattedText)
+ if (!matcher.matches()) return
+
+ val message = matcher.group(1) ?: return
+ currentPerk = SkyMallPerk.values().find { it.chatMessage == message }
+
+ currentPerk?.let {
+ val manager = NotEnoughUpdates.INSTANCE.manager
+ displayItem = manager.jsonToStack(manager.itemInformation[it.displayItemId])
+ }
+ }
+
+ companion object {
+ private var displayText = ""
+ private var displayItem: ItemStack? = null
+ private var lastUpdated = 0L
+ private var currentPerk: SkyMallPerk? = null
+
+ fun getDisplayText(): String {
+ return if (lastUpdated + 1_000 > System.currentTimeMillis()) {
+ displayText
+ } else {
+ update()
+ displayText
+ }
+ }
+
+ fun getDisplayItem(): ItemStack {
+ return displayItem ?: ItemStack(Items.apple)
+ }
+
+ private fun update() {
+ val nextDayBeginning = SkyBlockTime.now()
+ .let { it.copy(day = it.day + 1, hour = 0, minute = 0, second = 0) }
+ .toInstant()
+ val untilNextDay = Duration.between(Instant.now(), nextDayBeginning)
+ displayText = (currentPerk?.displayName ?: "?") + " §a(${
+ Utils.prettyTime(untilNextDay.toMillis())
+ })"
+ lastUpdated = System.currentTimeMillis()
+ }
+ }
+
+ enum class SkyMallPerk(val displayName: String, val displayItemId: String, val chatMessage: String) {
+ PICKAXE_COOLDOWN(
+ "20% §6Pickaxe Ability cooldown", "DIAMOND_PICKAXE",
+ "§r§fReduce Pickaxe Ability cooldown by §r§a20%§r§f."
+ ),
+ MORE_POWDER("+15% more §6Powder", "MITHRIL_ORE", "§r§fGain §r§a+15% §r§fmore Powder while mining."),
+ MINING_FORTUNE("+50 §6☘ Mining Fortune", "ENCHANTED_RABBIT_FOOT", "§r§fGain §r§a+50 §r§6☘ Mining Fortune§r§f."),
+ MINING_SPEED("+100 §6⸕ Mining Speed", "ENCHANTED_FEATHER", "§r§fGain §r§a+100 §r§6⸕ Mining Speed§r§f."),
+ MORE_GOBLINS("10x §6Goblin chance", "GOBLIN_HELMET", "§r§f§r§a10x §r§fchance to find Goblins while mining."),
+ TITANIUM_DROPS("5x §9Titanium drops", "TITANIUM_ORE", "§r§fGain §r§a5x §r§9Titanium §r§fdrops"),
+
+ // In case hypixel finds some day the missing dot at the end.
+ TITANIUM_DROPS_WITH_DOT("5x §9Titanium drops", "TITANIUM_ORE", "§r§fGain §r§a5x §r§9Titanium §r§fdrops."),
+ ;
+ }
+}
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/SkyBlockTime.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/SkyBlockTime.kt
new file mode 100644
index 00000000..8ceb1c51
--- /dev/null
+++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/SkyBlockTime.kt
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2023 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.util
+
+import java.time.Instant
+
+data class SkyBlockTime(
+ val year: Int = 1,
+ val month: Int = 1,
+ val day: Int = 1,
+ val hour: Int = 0,
+ val minute: Int = 0,
+ val second: Int = 0,
+) {
+
+ val monthName get() = monthName(month)
+ val dayName get() = "$day${daySuffix(day)}"
+
+
+ fun toInstant(): Instant? {
+ return Instant.ofEpochMilli(toMillis())
+ }
+
+ fun toMillis(): Long {
+ val skyBlockYear = 124 * 60 * 60.0
+ val skyBlockMonth = skyBlockYear / 12
+ val skyBlockDay = skyBlockMonth / 31
+ val skyBlockHour = skyBlockDay / 24
+ val skyBlockMinute = skyBlockHour / 60
+ val skyBlockSecond = skyBlockMinute / 60
+
+ var time = 0.0
+ time += year * skyBlockYear
+ time += (month - 1) * skyBlockMonth
+ time += (day - 1) * skyBlockDay
+ time += hour * skyBlockHour
+ time += minute * skyBlockMinute
+ time += second * skyBlockSecond
+ time += 1559829300
+ return time.toLong() * 1000
+ }
+
+ companion object {
+ fun fromInstant(instant: Instant): SkyBlockTime {
+ val skyBlockTimeZero = 1559829300000 // Day 1, Year 1
+ var realMillis = (instant.toEpochMilli() - skyBlockTimeZero)
+
+ val skyBlockYear = 124 * 60 * 60 * 1000
+ val skyBlockMonth = skyBlockYear / 12
+ val skyBlockDay = skyBlockMonth / 31
+ val skyBlockHour = skyBlockDay / 24
+ val skyBlockMinute = skyBlockHour / 60
+ val skyBlockSecond = skyBlockMinute / 60
+
+ fun getUnit(factor: Int): Int {
+ val result = realMillis / factor
+ realMillis %= factor
+ return result.toInt()
+ }
+
+ val year = getUnit(skyBlockYear)
+ val month = getUnit(skyBlockMonth) + 1
+ val day = getUnit(skyBlockDay) + 1
+ val hour = getUnit(skyBlockHour)
+ val minute = getUnit(skyBlockMinute)
+ val second = getUnit(skyBlockSecond)
+ return SkyBlockTime(year, month, day, hour, minute, second)
+
+ }
+
+ fun now(): SkyBlockTime {
+ return fromInstant(Instant.now())
+ }
+
+ fun monthName(month: Int): String {
+ val prefix = when ((month - 1) % 3) {
+ 0 -> "Early "
+ 1 -> ""
+ 2 -> "Late "
+ else -> "Undefined!"
+ }
+
+ val name = when ((month - 1) / 3) {
+ 0 -> "Spring"
+ 1 -> "Summer"
+ 2 -> "Autumn"
+ 3 -> "Winter"
+ else -> "lol"
+ }
+
+ return prefix + name
+ }
+
+ fun daySuffix(n: Int): String {
+ return if (n in 11..13) {
+ "th"
+ } else when (n % 10) {
+ 1 -> "st"
+ 2 -> "nd"
+ 3 -> "rd"
+ else -> "th"
+ }
+ }
+ }
+}