From 140219f75b361fce1d9dec265f78b70202d06d3b Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:45:32 +0200 Subject: [PATCH 01/12] Backend: Alert Clock Offsets (#2623) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: CalMWolfs --- build.gradle.kts | 4 + .../config/features/misc/MiscConfig.java | 9 ++ .../skyhanni/utils/ComputerTimeOffset.kt | 122 ++++++++++++++++++ .../at/hannibal2/skyhanni/utils/OSUtils.kt | 13 +- 4 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/ComputerTimeOffset.kt diff --git a/build.gradle.kts b/build.gradle.kts index 71a882ac96bf..3e3b002ff9aa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -171,6 +171,9 @@ dependencies { implementation("net.hypixel:mod-api:0.3.1") + // getting clock offset + shadowImpl("commons-net:commons-net:3.8.0") + detektPlugins("org.notenoughupdates:detektrules:1.0.0") detektPlugins(project(":detekt")) detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.7") @@ -279,6 +282,7 @@ tasks.shadowJar { relocate("io.github.notenoughupdates.moulconfig", "at.hannibal2.skyhanni.deps.moulconfig") relocate("moe.nea.libautoupdate", "at.hannibal2.skyhanni.deps.libautoupdate") relocate("com.jagrosh.discordipc", "at.hannibal2.skyhanni.deps.discordipc") + relocate("org.apache.commons.net", "at.hannibal2.skyhanni.deps.commons.net") } tasks.jar { archiveClassifier.set("nodeps") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java index 9d503c3986be..df1ae1da5c04 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java @@ -334,4 +334,13 @@ public class MiscConfig { @ConfigEditorBoolean @FeatureToggle public boolean userluckEnabled = true; + + @Expose + @ConfigOption(name = "Computer Time Offset Warning", + desc = "Sends a Chat Warning if your computer time is not synchronized with the actual time.\n" + + "§cMaking sure your computer time is correct is important for SkyHanni to display times correctly." + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean warnAboutPcTimeOffset = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ComputerTimeOffset.kt b/src/main/java/at/hannibal2/skyhanni/utils/ComputerTimeOffset.kt new file mode 100644 index 000000000000..83ea15ecc437 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/ComputerTimeOffset.kt @@ -0,0 +1,122 @@ +package at.hannibal2.skyhanni.utils + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.DebugDataCollectEvent +import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.TimeUtils.format +import kotlinx.coroutines.launch +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import org.apache.commons.net.ntp.NTPUDPClient +import java.net.InetAddress +import kotlin.concurrent.thread +import kotlin.time.Duration +import kotlin.time.Duration.Companion.milliseconds +import kotlin.time.Duration.Companion.seconds + +@SkyHanniModule +object ComputerTimeOffset { + private var offsetMillis: Duration? = null + + private val config get() = SkyHanniMod.feature.misc.warnAboutPcTimeOffset + + private val offsetFixLinks by lazy { + when { + OSUtils.isWindows -> { + "https://support.microsoft.com/en-us/windows/how-to-set-your-time-and-time-zone-dfaa7122-479f-5b98-2a7b-fa0b6e01b261" + } + + OSUtils.isLinux -> "https://unix.stackexchange.com/a/79116" + OSUtils.isMac -> "https://support.apple.com/guide/mac-help/set-the-date-and-time-automatically-mchlp2996/mac" + else -> null + } + } + + init { + thread { + while (true) { + Thread.sleep(1000) + detectTimeChange() + } + } + } + + private fun checkOffset() { + val wasOffsetBefore = (offsetMillis?.absoluteValue ?: 0.seconds) > 5.seconds + SkyHanniMod.coroutineScope.launch { + offsetMillis = getNtpOffset("time.google.com") + offsetMillis?.let { + tryDisplayOffset(wasOffsetBefore) + } + } + } + + private fun getNtpOffset(ntpServer: String): Duration? = try { + val client = NTPUDPClient() + val address = InetAddress.getByName(ntpServer) + val timeInfo = client.getTime(address) + + timeInfo.computeDetails() + timeInfo.offset.milliseconds + } catch (e: Exception) { + if (LorenzUtils.inSkyBlock && config) ErrorManager.logErrorWithData( + e, "Failed to get NTP offset", + "server" to ntpServer, + ) + else e.printStackTrace() + null + } + + private var lastSystemTime = System.currentTimeMillis() + + private fun detectTimeChange() { + val currentSystemTime = System.currentTimeMillis() + val timeDifference = (currentSystemTime - lastSystemTime).milliseconds + lastSystemTime = currentSystemTime + + val expectedDuration = 1.seconds + val deviation = timeDifference - expectedDuration + + if (deviation.absoluteValue > 1.seconds) { + checkOffset() + } + } + + @SubscribeEvent + fun onProfileJoin(event: ProfileJoinEvent) { + DelayedRun.runDelayed(5.seconds) { + checkOffset() + } + } + + private fun tryDisplayOffset(wasOffsetBefore: Boolean) { + if (!config || !LorenzUtils.onHypixel) return + val offsetMillis = offsetMillis ?: return + if (offsetMillis.absoluteValue < 5.seconds) { + if (wasOffsetBefore) { + ChatUtils.chat("Congratulations! Your computer's clock is now accurate.") + } + return + } + + ChatUtils.clickableLinkChat( + "Your computer's clock is off by ${offsetMillis.absoluteValue.format()}.\n" + + "§ePlease update your time settings. Many features may not function correctly until you do.\n" + + "§eClick here for instructions on how to fix your clock.", + offsetFixLinks ?: return, + prefixColor = "§c", + ) + } + + @SubscribeEvent + fun onDebugCollect(event: DebugDataCollectEvent) { + event.title("Time Offset") + val relevant = offsetMillis?.absoluteValue?.let { it < 100.milliseconds } ?: true + if (relevant) { + event.addData(offsetMillis.toString()) + } else { + event.addIrrelevant(offsetMillis.toString()) + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt index e209e0ce9d28..5b42c5dc640f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt @@ -7,6 +7,17 @@ import java.net.URI object OSUtils { + val isWindows: Boolean + val isMac: Boolean + val isLinux: Boolean + + init { + val os = System.getProperty("os.name") + isWindows = os.contains("win", ignoreCase = true) + isMac = os.contains("mac", ignoreCase = true) + isLinux = os.contains("linux", ignoreCase = true) + } + @JvmStatic fun openBrowser(url: String) { val desktopSupported = Desktop.isDesktopSupported() @@ -17,7 +28,7 @@ object OSUtils { } catch (e: IOException) { ErrorManager.logErrorWithData( e, "Error while opening website.", - "url" to url + "url" to url, ) } } else { From cc3ea04a7534b187673a05151f1f102ff869ce4c Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 2 Oct 2024 18:00:44 +0200 Subject: [PATCH 02/12] fixed typo in broodmother message --- .../hannibal2/skyhanni/features/combat/BroodmotherFeatures.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/BroodmotherFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/BroodmotherFeatures.kt index 4020e26d36d4..d122ba342fee 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/BroodmotherFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/BroodmotherFeatures.kt @@ -97,11 +97,9 @@ object BroodmotherFeatures { // this is so that two messages aren't immediately sent upon joining a server if (!(currentStage == StageEntry.ALIVE && isAliveMessageEnabled())) { val duration = currentStage?.duration - val minutes = duration?.inWholeMinutes?.toInt() ?: 0 - val pluralize = StringUtils.pluralize(minutes, "minute") var message = "The Broodmother's current stage in this server is ${currentStage.toString().replace("!", "")}§e." if (duration != 0.minutes) { - message += " It will spawn §bwithin $duration $pluralize§e." + message += " It will spawn §bwithin $duration§e." } ChatUtils.chat(message) return true From f8fd5fb7e2e449d9a49bf8982c8acc4549602d9a Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 2 Oct 2024 18:06:09 +0200 Subject: [PATCH 03/12] fixed errors when path is zero --- .../java/at/hannibal2/skyhanni/data/IslandGraphs.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt index 9829b4ec9e92..386fb8bbf489 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt @@ -265,6 +265,7 @@ object IslandGraphs { private fun onCurrentPath(): Boolean { val path = fastestPath ?: return false + if (path.isEmpty()) return false val closest = path.nodes.minBy { it.position.distanceSqToPlayer() } val distance = closest.position.distanceToPlayer() if (distance > 7) return false @@ -441,12 +442,14 @@ object IslandGraphs { if (label == "") return val path = fastestPath ?: return var distance = 0.0 - for ((a, b) in path.zipWithNext()) { - distance += a.position.distance(b.position) + if (path.isNotEmpty()) { + for ((a, b) in path.zipWithNext()) { + distance += a.position.distance(b.position) + } + val distanceToPlayer = path.first().position.distanceToPlayer() + distance += distanceToPlayer + distance = distance.roundTo(1) } - val distanceToPlayer = path.first().position.distanceToPlayer() - distance += distanceToPlayer - distance = distance.roundTo(1) if (distance == lastDistance) return lastDistance = distance From 2d24eb5a533b506e1b6119425edc7d117ec0f6a5 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 2 Oct 2024 18:36:01 +0200 Subject: [PATCH 04/12] Version 0.27 Beta 14 --- docs/CHANGELOG.md | 27 +++++++++++++++++++++++++++ docs/FEATURES.md | 4 ++++ root.gradle.kts | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 64e1288718f0..ce469091517f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -24,6 +24,10 @@ + Added Crafting Room Helper. - HiZe (https://github.com/hannibal002/SkyHanni/pull/2178) + Shows a holographic mob at the location where the mob is present in the real room inside the Mirrorverse in Rift. + Added Rift Time Real-Time Nametag Format. - Empa (https://github.com/hannibal002/SkyHanni/pull/2015) ++ Added a helper for tracking the Buttons Enigma Soul in the Rift. - MTOnline (https://github.com/hannibal002/SkyHanni/pull/2616) + + Using pathfinding to guide the player to the nearest spot with unpressed buttons and highlights them. ++ Added a route helper for Gunther's Rift Race in the West Village. - MTOnline (https://github.com/hannibal002/SkyHanni/pull/2616) ++ Added the ability to mute Wilted Berberis sounds when not farming. - MTOnline (https://github.com/hannibal002/SkyHanni/pull/2616) #### Dungeon Features @@ -178,6 +182,7 @@ + Added an option to hide all tooltips inside the Fossil Excavator. - Cuz_Im_Clicks (https://github.com/hannibal002/SkyHanni/pull/2579) + Added support for using the Pickobulus ability for the Mineshaft Pity Display. - Empa (https://github.com/hannibal002/SkyHanni/pull/2540) + Added Area Navigation support to Glacite Tunnels. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2544) ++ Updated wording in mineshaft pity breakdown ("efficient miner" -> "spread"). - luna (https://github.com/hannibal002/SkyHanni/pull/2633) #### Diana Improvements @@ -250,11 +255,13 @@ + Since the cactus knife now allows 500 max speed. + Made the waypoint to the middle of the plot for Pest Waypoint optional (off by default). - Luna (https://github.com/hannibal002/SkyHanni/pull/2469) + Reduced one click for supercrafting visitor materials by using `/viewrecipe` instead of `/recipe` when using the Shopping List button. - Miestiek (https://github.com/hannibal002/SkyHanni/pull/2505) ++ Added ignored crops for the Farming Lane feature. - martimavocado (https://github.com/hannibal002/SkyHanni/pull/2622) #### Rift Improvements + Updated the description of the config for Enigma Soul Waypoints to help find the Rift Guide in the game. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2433) + Added Path Finder to Enigma Soul waypoints in the Rift. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2515) ++ Added the option to choose the color of the Living Metal Helper highlight. - MTOnline (https://github.com/hannibal002/SkyHanni/pull/2616) #### Dungeon Improvements @@ -263,6 +270,7 @@ #### The Carnival Improvements + Updated the Zombie Shootout Diamond color to be a deeper blue. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2511) ++ Added a cooldown to the Carnival NPC Quickstart feature. - minhperry (https://github.com/hannibal002/SkyHanni/pull/2628) #### Misc Improvements @@ -276,6 +284,9 @@ + Improved pathfinding. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2597) + The line to the target no longer jumps around as much. + Progress to the target now shows up in chat, displaying blocks remaining and percentage completed. Clicking on the chat message cancels the pathfinding. ++ Added a warning in chat when the computer's time is inaccurate, along with a tutorial on how to fix it. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2623) ++ Improved the way pathfinding lines are rendered. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2634) ++ Automatically starts pathfinding after clicking on SkyHanni reminder chat messages about Carnival Reminder, Hoppity NPC, City Project, and account/profile upgrades. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2635) ### Fixes @@ -288,6 +299,7 @@ #### Bingo Fixes + Fixed "show bingo rank number" feature toggle not functioning. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2445) ++ Fixed Custom Scoreboard not showing Carnival Lines on Bingo. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2631) #### Inventory Fixes @@ -313,6 +325,10 @@ + Fixed `/shedittracker` support not functioning properly. + Fixed an issue where the item stack size on Diamond/Golden Heads and Master Skulls could be incorrect. - Fazfoxy (https://github.com/hannibal002/SkyHanni/pull/2611) + Fixed item category detection for recombobulated items. - minhperry (https://github.com/hannibal002/SkyHanni/pull/2608) ++ Fixed bugs in Superpair Data. - ILike2WatchMemes (https://github.com/hannibal002/SkyHanni/pull/2566) + + Fixed pair detection. + + Fixed enchanting XP detection. ++ Fixed Minister in Calendar Perk description sometimes not using the gray color. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2632) #### Mining Fixes @@ -338,6 +354,7 @@ + Fixed "Mining Commissions Block Color" causing OptiFine connected textures not to connect properly. - nopo (https://github.com/hannibal002/SkyHanni/pull/2577) + Fixed the Mineshaft Pity Counter not working in the Great Glacite Lake. - martimavocado (https://github.com/hannibal002/SkyHanni/pull/2565) + Fixed Powder Tracker inaccuracies. - Empa (https://github.com/hannibal002/SkyHanni/pull/2591) ++ Fixed Jasper gemstones not being addressed in the Powder Mining filter. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2618) #### Scoreboard Fixes @@ -371,6 +388,7 @@ + Fixed Hoppity Event stats resetting. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2489) + Fixed an issue where Fish the Rabbit and El Dorado did not have compacted chat messages. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2488) + Fixed inconsistencies in Hoppity Duplicate Number counts. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2595) ++ Fixed Fish the Rabbit and El Dorado incorrectly counting as unique rabbits during Hoppity's Hunt. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2627) #### Chat Fixes @@ -414,6 +432,10 @@ + Fixed error messages while using the Chum Bucket Hider feature. - nea89 (https://github.com/hannibal002/SkyHanni/pull/2587) +#### Rift Fixes + ++ Fixed the Rift Timer pausing while in Gunther's Rift Race. - MTOnline (https://github.com/hannibal002/SkyHanni/pull/2616) + #### Misc Fixes + Fixed Mayor Detection failing when Special Mayors are in office. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2389) @@ -434,6 +456,9 @@ + Fixed reforge display not working with new mining stats. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2555) + Fixed Totem of Corruption expiry warning not working in some cases. - Luna (https://github.com/hannibal002/SkyHanni/pull/2554) + Fixed a few typos in the config. - rdbt (https://github.com/hannibal002/SkyHanni/pull/2585) ++ Fixed Area Navigation distances to player being incorrect. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2634) ++ Fixed item trackers displaying removed item names incorrectly. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2620) ++ Fixed some messages from Pablo NPC not being detected. - Luna (https://github.com/hannibal002/SkyHanni/pull/2636) ### Technical Details @@ -503,6 +528,8 @@ + Added Blossom Gradle plugin for token replacement in code. - ThatGravyBoat (https://github.com/hannibal002/SkyHanni/pull/2558) + `@MOD_VERSION@` is now a token that will be replaced. + Added `detekt` runner to the build process. - Daveed & nea (https://github.com/hannibal002/SkyHanni/pull/2547) ++ Added Clock Offset Millis using an NTP server. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2623) ++ Added `EntityMovementData.onNextTeleport()` logic, which triggers a runnable after the world has changed or the player has teleported. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2635) ### Removed Features diff --git a/docs/FEATURES.md b/docs/FEATURES.md index d78a2114dfbf..a57725958d57 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -841,6 +841,10 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Added Crafting Room Helper. - HiZe (https://github.com/hannibal002/SkyHanni/pull/2178) + Shows a holographic mob at the location where the mob is present in the real room inside the Mirrorverse in Rift. + Added Rift Time Real-Time Nametag Format. - Empa (https://github.com/hannibal002/SkyHanni/pull/2015) ++ Added a helper for tracking the Buttons Enigma Soul in the Rift. - MTOnline (https://github.com/hannibal002/SkyHanni/pull/2616) + + Using pathfinding to guide the player to the nearest spot with unpressed buttons and highlights them. ++ Added a route helper for Gunther's Rift Race in the West Village. - MTOnline (https://github.com/hannibal002/SkyHanni/pull/2616) ++ Added the ability to mute Wilted Berberis sounds when not farming. - MTOnline (https://github.com/hannibal002/SkyHanni/pull/2616)
diff --git a/root.gradle.kts b/root.gradle.kts index 9eb7a0854868..9346a78f9f92 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -14,7 +14,7 @@ plugins { allprojects { group = "at.hannibal2.skyhanni" - version = "0.27.Beta.13" + version = "0.27.Beta.14" repositories { mavenCentral() mavenLocal() From b45002ecafb9fd212d3c956dcd7b2249d6607a8b Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:10:49 -0400 Subject: [PATCH 05/12] Improvement: Slight Touch up for Hoppity Event Summary (#2638) --- .../features/event/hoppity/HoppityEventSummary.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEventSummary.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEventSummary.kt index 0d4e09b9c518..b2f806c8000a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEventSummary.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEventSummary.kt @@ -231,12 +231,18 @@ object HoppityEventSummary { config.eventSummary.statDisplayList.forEach { summaryOperationList[it]?.invoke(statsBuilder, stats, eventYear) } + + // If no stats are found, display a message if (statsBuilder.toString().replace("\n", "").isEmpty()) { - statsBuilder.appendHeadedLine("§c§lNothing to show!\n§c§oGo find some eggs!") + statsBuilder.appendHeadedLine("§c§lNothing to show!") + statsBuilder.appendHeadedLine("§c§oGo find some eggs!") } + // Remove any consecutive empty lines in the stats + val statsBuilderString = statsBuilder.toString().replace(Regex("\n{4,}"), "\n".repeat(3)) + // Append stats - summaryBuilder.append(statsBuilder) + summaryBuilder.append(statsBuilderString) // Footer summaryBuilder.append("§d§l${"▬".repeat(64)}") From fdd5bb7acd10c2ab51b76a3ec47a9ac8405021e2 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 2 Oct 2024 20:00:31 +0200 Subject: [PATCH 06/12] code cleanup --- .../skyhanni/features/inventory/bazaar/BazaarApi.kt | 9 +++++---- .../inventory/bazaar/BazaarCancelledBuyOrderClipboard.kt | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt index afd5900f7c34..25ddb8dace8b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt @@ -66,13 +66,13 @@ object BazaarApi { searchForBazaarItem(internalName.itemNameWithoutColor, amount) } - fun searchForBazaarItem(displayName: String, amount: Int = -1) { + fun searchForBazaarItem(displayName: String, amount: Int? = null) { if (!LorenzUtils.inSkyBlock) return if (NEUItems.neuHasFocus()) return if (LorenzUtils.noTradeMode) return if (DungeonAPI.inDungeon() || LorenzUtils.inKuudraFight) return HypixelCommands.bazaar(displayName.removeColor()) - if (amount != -1) OSUtils.copyToClipboard(amount.toString()) + amount?.let { OSUtils.copyToClipboard(it.toString()) } currentSearchedItem = displayName.removeColor() } @@ -96,12 +96,12 @@ object BazaarApi { orderOptionProduct = internalName } else if (itemName.contains("BUY")) { // pickup items from bazaar order - OwnInventoryData.ignoreItem(1.seconds, { it == internalName }) + OwnInventoryData.ignoreItem(1.seconds) { it == internalName } } } if (InventoryUtils.openInventoryName() == "Order options" && itemName == "§cCancel Order") { // pickup items from own bazaar order - OwnInventoryData.ignoreItem(1.seconds, { it == orderOptionProduct }) + OwnInventoryData.ignoreItem(1.seconds) { it == orderOptionProduct } } } @@ -123,6 +123,7 @@ object BazaarApi { } } + // TODO cache @SubscribeEvent fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { if (!LorenzUtils.inSkyBlock) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarCancelledBuyOrderClipboard.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarCancelledBuyOrderClipboard.kt index a177d3fe6287..dfd7e38f9b85 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarCancelledBuyOrderClipboard.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarCancelledBuyOrderClipboard.kt @@ -103,7 +103,7 @@ object BazaarCancelledBuyOrderClipboard { event.blockedReason = "bazaar cancelled buy order clipboard" val lastClicked = lastClickedItem ?: error("last clicked bz item is null") - val message = "Bazaar buy order cancelled. Click to reorder. " + + val message = "Bazaar buy order cancelled. Click to re-order. " + "(§8${latestAmount.addSeparators()}x §r${lastClicked.itemName}§e)" ChatUtils.clickableChat( message, From b449c2bbfd8c7661693bde36c25ab3ae379c2304 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Wed, 2 Oct 2024 23:40:55 +0200 Subject: [PATCH 07/12] Fix: Highlight in Bazaar (#2640) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt index 25ddb8dace8b..8e8bbb595bb7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt @@ -15,7 +15,7 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.InventoryUtils -import at.hannibal2.skyhanni.utils.InventoryUtils.getAllItems +import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -135,7 +135,7 @@ object BazaarApi { val guiChest = event.gui val chest = guiChest.inventorySlots as ContainerChest - for ((slot, stack) in chest.getAllItems()) { + for ((slot, stack) in chest.getUpperItems()) { if (chest.inventorySlots.indexOf(slot) !in 9..44) { continue } From 8798f722c32736bcbe686728fafdde87f561e1a8 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Wed, 2 Oct 2024 23:49:44 +0200 Subject: [PATCH 08/12] Fix: Flare expire warning (#2643) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt index 5a67e1d3405f..c5804ea37c40 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt @@ -101,7 +101,7 @@ object FlareDisplay { } } } - if (remainingTime !in 5.seconds..0.seconds) continue + if (remainingTime !in 0.seconds..5.seconds) continue val message = "$name §eexpires in: §b${remainingTime.inWholeSeconds}s" when (config.alertType) { FlareConfig.AlertType.CHAT -> { From d3930a1f04371a76804ed2512da93b87e3c197db Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Thu, 3 Oct 2024 00:19:57 +0200 Subject: [PATCH 09/12] Fix: Ender node tracker (#2644) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../endernodetracker/EnderNodeTracker.kt | 82 ++++++++++++------- 1 file changed, 52 insertions(+), 30 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt index 51deea2b865d..0363543bffd0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt @@ -26,7 +26,9 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.renderables.Searchable +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker import at.hannibal2.skyhanni.utils.tracker.TrackerData import com.google.gson.annotations.Expose @@ -40,12 +42,30 @@ object EnderNodeTracker { private var miteGelInInventory = 0 - private val enderNodeRegex = Regex("""ENDER NODE!.+You found (\d+x )?§r(.+)§r§f!""") + private val patternGroup = RepoPattern.group("combat.endernodetracker.chat") + + /** + * REGEX-TEST: §5§lENDER NODE! §r§fYou found §r§8§r§aEnchanted Obsidian§r§f! + */ + private val patternOne by patternGroup.pattern( + "one", + "§5§lENDER NODE! §r§fYou found §r(?:§8§r)?(?.*)§r§f!", + ) + + /** + * REGEX-TEST: §5§lENDER NODE! §r§fYou found §r§85x §r§aEnchanted Ender Pearl§r§f! + */ + private val patternMulti by patternGroup.pattern( + "multi", + "§5§lENDER NODE! §r§fYou found §r§8(?\\d+)x §r(?.*)§r§f!", + ) + + // TODO add abstract logic with ohter pet drop chat messages private val endermanRegex = Regex("""(RARE|PET) DROP! §r(.+) §r§b\(""") private val tracker = SkyHanniTracker("Ender Node Tracker", { Data() }, { it.enderNodeTracker }) { formatDisplay( - drawDisplay(it) + drawDisplay(it), ) } @@ -77,14 +97,17 @@ object EnderNodeTracker { var item: String? = null var amount = 1 - // check whether the loot is from an ender node or an enderman - enderNodeRegex.find(message)?.let { - tracker.modify { storage -> - storage.totalNodesMined++ - } - amount = it.groups[1]?.value?.substringBefore("x")?.toIntOrNull() ?: 1 - item = it.groups[2]?.value - } ?: endermanRegex.find(message)?.let { + patternMulti.matchMatcher(message) { + item = group("name") + amount = group("amount").toInt() + addOneNodeMined() + } ?: patternOne.matchMatcher(message) { + item = group("name") + amount = 1 + addOneNodeMined() + } + + endermanRegex.find(message)?.let { amount = 1 item = it.groups[2]?.value } @@ -106,12 +129,18 @@ object EnderNodeTracker { } } + private fun addOneNodeMined() { + tracker.modify { storage -> + storage.totalNodesMined++ + } + } + @SubscribeEvent fun onIslandChange(event: IslandChangeEvent) { if (!isEnabled()) return - miteGelInInventory = Minecraft.getMinecraft().thePlayer.inventory.mainInventory - .filter { it?.getInternalNameOrNull() == EnderNode.MITE_GEL.internalName } - .sumOf { it.stackSize } + miteGelInInventory = Minecraft.getMinecraft().thePlayer.inventory.mainInventory.filter { + it?.getInternalNameOrNull() == EnderNode.MITE_GEL.internalName + }.sumOf { it.stackSize } } @SubscribeEvent @@ -119,9 +148,7 @@ object EnderNodeTracker { if (!isEnabled()) return if (!ProfileStorageData.loaded) return - val change = event.sackChanges - .firstOrNull { it.internalName == EnderNode.MITE_GEL.internalName && it.delta > 0 } - ?: return + val change = event.sackChanges.firstOrNull { it.internalName == EnderNode.MITE_GEL.internalName && it.delta > 0 } ?: return tracker.modify { storage -> storage.lootCount.addOrPut(EnderNode.MITE_GEL, change.delta) @@ -133,9 +160,9 @@ object EnderNodeTracker { if (!isEnabled()) return if (!ProfileStorageData.loaded) return - val newMiteGelInInventory = Minecraft.getMinecraft().thePlayer.inventory.mainInventory - .filter { it?.getInternalNameOrNull() == EnderNode.MITE_GEL.internalName } - .sumOf { it.stackSize } + val newMiteGelInInventory = Minecraft.getMinecraft().thePlayer.inventory.mainInventory.filter { + it?.getInternalNameOrNull() == EnderNode.MITE_GEL.internalName + }.sumOf { it.stackSize } val change = newMiteGelInInventory - miteGelInInventory if (change > 0) { tracker.modify { storage -> @@ -176,18 +203,16 @@ object EnderNodeTracker { val price = if (isEnderArmor(item)) { 10_000.0 } else { - (if (!LorenzUtils.noTradeMode) item.internalName.getPriceOrNull() else 0.0) - ?.coerceAtLeast(item.internalName.getNpcPriceOrNull() ?: 0.0) - ?.coerceAtLeast(georgePrice(item) ?: 0.0) - ?: 0.0 + (if (!LorenzUtils.noTradeMode) item.internalName.getPriceOrNull() else 0.0)?.coerceAtLeast( + item.internalName.getNpcPriceOrNull() ?: 0.0, + )?.coerceAtLeast(georgePrice(item) ?: 0.0) ?: 0.0 } newProfit[item] = price * amount } return newProfit } - private fun isEnabled() = IslandType.THE_END.isInIsland() && config.enabled && - (!config.onlyPickaxe || hasItemInHand()) + private fun isEnabled() = IslandType.THE_END.isInIsland() && config.enabled && (!config.onlyPickaxe || hasItemInHand()) private fun hasItemInHand() = ItemCategory.miningTools.containsItem(InventoryUtils.getItemInHand()) @@ -230,7 +255,7 @@ object EnderNodeTracker { val totalEnderArmor = calculateEnderArmor(data) addSearchString( - "§b${totalEnderArmor.addSeparators()} §5Ender Armor " + "§7(§6${(totalEnderArmor * 10_000).shortFormat()}§7)" + "§b${totalEnderArmor.addSeparators()} §5Ender Armor " + "§7(§6${(totalEnderArmor * 10_000).shortFormat()}§7)", ) for (item in EnderNode.entries.subList(11, 16)) { val count = (data.lootCount[item] ?: 0).addSeparators() @@ -243,10 +268,7 @@ object EnderNodeTracker { addSearchString("§f$c§7-§a$u§7-§9$r§7-§5$e§7-§6$l §fEnderman Pet §7(§6$profit§7)") } - private fun calculateEnderArmor(storage: Data) = - storage.lootCount.filter { isEnderArmor(it.key) } - .map { it.value } - .sum() + private fun calculateEnderArmor(storage: Data) = storage.lootCount.filter { isEnderArmor(it.key) }.map { it.value }.sum() private fun formatDisplay(map: List): List { if (!ProfileStorageData.loaded) return emptyList() From c33c011a3314ee533b998da78851e7777338c727 Mon Sep 17 00:00:00 2001 From: HiZe Date: Thu, 3 Oct 2024 00:27:23 +0200 Subject: [PATCH 10/12] Fix: Powder Tracker not tracking items (#2645) --- .../skyhanni/features/mining/powdertracker/PowderTracker.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt index 2749404bef59..c3d307a16f69 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt @@ -198,7 +198,7 @@ object PowderTracker { } for (reward in PowderChestReward.entries) { - if (reward == PowderChestReward.MITHRIL_POWDER || reward == PowderChestReward.GEMSTONE_POWDER) return + if (reward == PowderChestReward.MITHRIL_POWDER || reward == PowderChestReward.GEMSTONE_POWDER) continue reward.chatPattern.matchMatcher(msg) { tracker.modify { val count = it.rewards[reward] ?: 0 From e468384b34a5e1af56921149d1a05976e4eadd6a Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Thu, 3 Oct 2024 00:28:26 +0200 Subject: [PATCH 11/12] Fix: Preconditions to debug commands (#2641) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: CalMWolfs --- .../skyhanni/test/command/TrackParticlesCommand.kt | 7 +++++++ .../hannibal2/skyhanni/test/command/TrackSoundsCommand.kt | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt index 69c16daeb414..a48294bd8e64 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NumberUtil.roundTo import at.hannibal2.skyhanni.utils.OSUtils @@ -35,7 +36,13 @@ object TrackParticlesCommand { private var display: List = emptyList() private var worldParticles: Map> = emptyMap() + // TODO write abstract code for this and TrackSoundsCommand fun command(args: Array) { + if (!LorenzUtils.inSkyBlock) { + ChatUtils.userError("This command only works in SkyBlock!") + return + } + if (args.firstOrNull() == "end") { if (!isRecording) { ChatUtils.userError("Nothing to end") diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt index 1fadab62da24..18cfcf786bf8 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PlaySoundEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NumberUtil.roundTo import at.hannibal2.skyhanni.utils.OSUtils @@ -36,7 +37,13 @@ object TrackSoundsCommand { private var display: List = emptyList() private var worldSounds: Map> = emptyMap() + // TODO write abstract code for this and TrackParticlesCommand fun command(args: Array) { + if (!LorenzUtils.inSkyBlock) { + ChatUtils.userError("This command only works in SkyBlock!") + return + } + if (args.firstOrNull() == "end") { if (!isRecording) { ChatUtils.userError("Nothing to end") From c212cc7a3ee573b2eda614c29ced575936f4d4bb Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Thu, 3 Oct 2024 08:48:11 +0200 Subject: [PATCH 12/12] Fix: Dummies and Damage Indicator (#2646) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../combat/damageindicator/MobFinder.kt | 138 +++++++++--------- 1 file changed, 65 insertions(+), 73 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/MobFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/MobFinder.kt index 399040179934..44c7608c2b6b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/MobFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/MobFinder.kt @@ -71,8 +71,7 @@ class MobFinder { // F5 private var floor5lividEntity: EntityOtherPlayerMP? = null private var floor5lividEntitySpawnTime = 0L - private val correctLividPattern = - "§c\\[BOSS] (.*) Livid§r§f: Impossible! How did you figure out which one I was\\?!".toPattern() + private val correctLividPattern = "§c\\[BOSS] (.*) Livid§r§f: Impossible! How did you figure out which one I was\\?!".toPattern() // F6 private var floor6Giants = false @@ -86,29 +85,32 @@ class MobFinder { RiftAPI.inRift() -> tryAddRift(entity) GardenAPI.inGarden() -> tryAddGarden(entity) else -> { - when (entity) { - /* - * Note that the order does matter here. - * For example, if you put EntityZombie before EntityPigZombie, - * EntityPigZombie will never be reached because EntityPigZombie extends EntityZombie. - * Please take this into consideration if you are to modify this. - */ - is EntityOtherPlayerMP -> tryAddEntityOtherPlayerMP(entity) - is EntityIronGolem -> tryAddEntityIronGolem(entity) - is EntityPigZombie -> tryAddEntityPigZombie(entity) - is EntityMagmaCube -> tryAddEntityMagmaCube(entity) - is EntityEnderman -> tryAddEntityEnderman(entity) - is EntitySkeleton -> tryAddEntitySkeleton(entity) - is EntityGuardian -> tryAddEntityGuardian(entity) - is EntityZombie -> tryAddEntityZombie(entity) - is EntityWither -> tryAddEntityWither(entity) - is EntityDragon -> tryAddEntityDragon(entity) - is EntitySpider -> tryAddEntitySpider(entity) - is EntityHorse -> tryAddEntityHorse(entity) - is EntityBlaze -> tryAddEntityBlaze(entity) - is EntityWolf -> tryAddEntityWolf(entity) - is EntityLiving -> tryAddEntityLiving(entity) - else -> null + if (entity is EntityLiving && entity.hasNameTagWith(2, "Dummy §a10M§c❤")) { + EntityResult(bossType = BossType.DUMMY) + } else { + when (entity) { + /* + * Note that the order does matter here. + * For example, if you put EntityZombie before EntityPigZombie, + * EntityPigZombie will never be reached because EntityPigZombie extends EntityZombie. + * Please take this into consideration if you are to modify this. + */ + is EntityOtherPlayerMP -> tryAddEntityOtherPlayerMP(entity) + is EntityIronGolem -> tryAddEntityIronGolem(entity) + is EntityPigZombie -> tryAddEntityPigZombie(entity) + is EntityMagmaCube -> tryAddEntityMagmaCube(entity) + is EntityEnderman -> tryAddEntityEnderman(entity) + is EntitySkeleton -> tryAddEntitySkeleton(entity) + is EntityGuardian -> tryAddEntityGuardian(entity) + is EntityZombie -> tryAddEntityZombie(entity) + is EntityWither -> tryAddEntityWither(entity) + is EntityDragon -> tryAddEntityDragon(entity) + is EntitySpider -> tryAddEntitySpider(entity) + is EntityHorse -> tryAddEntityHorse(entity) + is EntityBlaze -> tryAddEntityBlaze(entity) + is EntityWolf -> tryAddEntityWolf(entity) + else -> null + } } } } @@ -124,8 +126,7 @@ class MobFinder { private fun tryAddGardenPest(entity: EntityLivingBase): EntityResult? { if (!GardenAPI.inGarden()) return null - return PestType.entries - .firstOrNull { entity.hasNameTagWith(3, it.displayName) } + return PestType.entries.firstOrNull { entity.hasNameTagWith(3, it.displayName) } ?.let { EntityResult(bossType = it.damageIndicatorBoss) } } @@ -170,7 +171,7 @@ class MobFinder { return EntityResult( floor2secondPhaseSpawnTime, finalDungeonBoss = true, - bossType = BossType.DUNGEON_F2_SCARF + bossType = BossType.DUNGEON_F2_SCARF, ) } } @@ -193,14 +194,14 @@ class MobFinder { return EntityResult( floor3ProfessorSpawnTime, floor3ProfessorSpawnTime + 1_000 > System.currentTimeMillis(), - bossType = BossType.DUNGEON_F3_PROFESSOR_1 + bossType = BossType.DUNGEON_F3_PROFESSOR_1, ) } if (floor3ProfessorGuardianPrepare && entity is EntityOtherPlayerMP && entity.name == "The Professor") { return EntityResult( floor3ProfessorGuardianPrepareSpawnTime, true, - bossType = BossType.DUNGEON_F3_PROFESSOR_2 + bossType = BossType.DUNGEON_F3_PROFESSOR_2, ) } @@ -215,7 +216,7 @@ class MobFinder { return EntityResult( bossType = BossType.DUNGEON_F4_THORN, ignoreBlocks = true, - finalDungeonBoss = true + finalDungeonBoss = true, ) } return null @@ -226,7 +227,7 @@ class MobFinder { return EntityResult( bossType = BossType.DUNGEON_F5, ignoreBlocks = true, - finalDungeonBoss = true + finalDungeonBoss = true, ) } return null @@ -239,7 +240,7 @@ class MobFinder { return EntityResult( floor6GiantsSpawnTime + extraDelay, floor6GiantsSpawnTime + extraDelay + 1_000 > System.currentTimeMillis(), - bossType = bossType + bossType = bossType, ) } @@ -274,8 +275,12 @@ class MobFinder { } private fun tryAddEntityBlaze(entity: EntityLivingBase) = when { - entity.name != "Dinnerbone" && entity.hasNameTagWith(2, "§e﴾ §8[§7Lv200§8] §l§8§lAshfang§r ") && - entity.hasMaxHealth(50_000_000, true) -> { + entity.name != "Dinnerbone" && + entity.hasNameTagWith(2, "§e﴾ §8[§7Lv200§8] §l§8§lAshfang§r ") && + entity.hasMaxHealth( + 50_000_000, + true, + ) -> { EntityResult(bossType = BossType.NETHER_ASHFANG) } @@ -312,8 +317,9 @@ class MobFinder { private fun tryAddEntityOtherPlayerMP(entity: EntityLivingBase) = when { entity.name == "Mage Outlaw" -> EntityResult(bossType = BossType.NETHER_MAGE_OUTLAW) - entity.name == "DukeBarb " && entity.getLorenzVec() - .distanceToPlayer() < 30 -> EntityResult(bossType = BossType.NETHER_BARBARIAN_DUKE) + entity.name == "DukeBarb " && + entity.getLorenzVec() + .distanceToPlayer() < 30 -> EntityResult(bossType = BossType.NETHER_BARBARIAN_DUKE) entity.name == "Minos Inquisitor" -> EntityResult(bossType = BossType.MINOS_INQUISITOR) entity.name == "Minos Champion" -> EntityResult(bossType = BossType.MINOS_CHAMPION) @@ -385,15 +391,8 @@ class MobFinder { else -> null } - private fun tryAddEntityLiving(entity: EntityLivingBase) = when { - entity.hasNameTagWith(2, "Dummy §a10M§c❤") -> EntityResult(bossType = BossType.DUMMY) - - else -> null - } - private fun tryAddEntityMagmaCube(entity: EntityLivingBase) = when { - entity.hasNameTagWith(15, "§e﴾ §8[§7Lv500§8] §l§4§lMagma Boss§r ") && - entity.hasMaxHealth(200_000_000, true) -> { + entity.hasNameTagWith(15, "§e﴾ §8[§7Lv500§8] §l§4§lMagma Boss§r ") && entity.hasMaxHealth(200_000_000, true) -> { EntityResult(bossType = BossType.NETHER_MAGMA_BOSS, ignoreBlocks = true) } @@ -401,24 +400,22 @@ class MobFinder { } private fun tryAddEntityHorse(entity: EntityLivingBase) = when { - entity.hasNameTagWith(15, "§8[§7Lv100§8] §c§6Headless Horseman§r ") && - entity.hasMaxHealth(3_000_000, true) -> { + entity.hasNameTagWith(15, "§8[§7Lv100§8] §c§6Headless Horseman§r ") && entity.hasMaxHealth(3_000_000, true) -> { EntityResult(bossType = BossType.HUB_HEADLESS_HORSEMAN) } else -> null } - private fun tryAddEntityPigZombie(entity: EntityLivingBase) = - if (entity.hasNameTagWith(2, "§c☠ §6ⓉⓎⓅⒽⓄⒺⓊⓈ ")) { - when { - entity.hasBossHealth(10_000_000) -> EntityResult(bossType = BossType.SLAYER_BLAZE_TYPHOEUS_4) - entity.hasBossHealth(5_000_000) -> EntityResult(bossType = BossType.SLAYER_BLAZE_TYPHOEUS_3) - entity.hasBossHealth(1_750_000) -> EntityResult(bossType = BossType.SLAYER_BLAZE_TYPHOEUS_2) - entity.hasBossHealth(500_000) -> EntityResult(bossType = BossType.SLAYER_BLAZE_TYPHOEUS_1) - else -> null - } - } else null + private fun tryAddEntityPigZombie(entity: EntityLivingBase) = if (entity.hasNameTagWith(2, "§c☠ §6ⓉⓎⓅⒽⓄⒺⓊⓈ ")) { + when { + entity.hasBossHealth(10_000_000) -> EntityResult(bossType = BossType.SLAYER_BLAZE_TYPHOEUS_4) + entity.hasBossHealth(5_000_000) -> EntityResult(bossType = BossType.SLAYER_BLAZE_TYPHOEUS_3) + entity.hasBossHealth(1_750_000) -> EntityResult(bossType = BossType.SLAYER_BLAZE_TYPHOEUS_2) + entity.hasBossHealth(500_000) -> EntityResult(bossType = BossType.SLAYER_BLAZE_TYPHOEUS_1) + else -> null + } + } else null private fun tryAddEntitySpider(entity: EntityLivingBase): EntityResult? { if (entity.hasNameTagWith(1, "§5☠ §4Tarantula Broodfather ")) { @@ -439,17 +436,13 @@ class MobFinder { } private fun checkArachne(entity: EntitySpider): EntityResult? { - if (entity.hasNameTagWith(1, "[§7Lv300§8] §cArachne") || - entity.hasNameTagWith(1, "[§7Lv300§8] §lArachne") - ) { + if (entity.hasNameTagWith(1, "[§7Lv300§8] §cArachne") || entity.hasNameTagWith(1, "[§7Lv300§8] §lArachne")) { val maxHealth = entity.baseMaxHealth // Ignore the minis if (maxHealth == 12 || maxHealth.derpy() == 4000) return null return EntityResult(bossType = BossType.ARACHNE_SMALL) } - if (entity.hasNameTagWith(1, "[§7Lv500§8] §cArachne") || - entity.hasNameTagWith(1, "[§7Lv500§8] §lArachne") - ) { + if (entity.hasNameTagWith(1, "[§7Lv500§8] §cArachne") || entity.hasNameTagWith(1, "[§7Lv500§8] §lArachne")) { val maxHealth = entity.baseMaxHealth if (maxHealth == 12 || maxHealth.derpy() == 20_000) return null return EntityResult(bossType = BossType.ARACHNE_BIG) @@ -458,16 +451,15 @@ class MobFinder { return null } - private fun tryAddEntityWolf(entity: EntityLivingBase) = - if (entity.hasNameTagWith(1, "§c☠ §fSven Packmaster ")) { - when { - entity.hasMaxHealth(2_000, true) -> EntityResult(bossType = BossType.SLAYER_WOLF_1) - entity.hasMaxHealth(40_000, true) -> EntityResult(bossType = BossType.SLAYER_WOLF_2) - entity.hasMaxHealth(750_000, true) -> EntityResult(bossType = BossType.SLAYER_WOLF_3) - entity.hasMaxHealth(2_000_000, true) -> EntityResult(bossType = BossType.SLAYER_WOLF_4) - else -> null - } - } else null + private fun tryAddEntityWolf(entity: EntityLivingBase) = if (entity.hasNameTagWith(1, "§c☠ §fSven Packmaster ")) { + when { + entity.hasMaxHealth(2_000, true) -> EntityResult(bossType = BossType.SLAYER_WOLF_1) + entity.hasMaxHealth(40_000, true) -> EntityResult(bossType = BossType.SLAYER_WOLF_2) + entity.hasMaxHealth(750_000, true) -> EntityResult(bossType = BossType.SLAYER_WOLF_3) + entity.hasMaxHealth(2_000_000, true) -> EntityResult(bossType = BossType.SLAYER_WOLF_4) + else -> null + } + } else null private fun tryAddEntityGuardian(entity: EntityLivingBase) = if (entity.hasMaxHealth(35_000_000)) { EntityResult(bossType = BossType.THUNDER)