diff options
author | Lorenz <lo.scherf@gmail.com> | 2022-08-23 13:40:31 +0200 |
---|---|---|
committer | Lorenz <lo.scherf@gmail.com> | 2022-08-23 13:40:31 +0200 |
commit | a40b447b792d5e09b2afab754a87cc50d5e2ee47 (patch) | |
tree | 5b7b1734d04e4eb06ee0b419793ee2e79d28b081 /src/main/java/at/hannibal2 | |
parent | d060394ccd00fbe3a86481db939032e13ca458b2 (diff) | |
download | skyhanni-a40b447b792d5e09b2afab754a87cc50d5e2ee47.tar.gz skyhanni-a40b447b792d5e09b2afab754a87cc50d5e2ee47.tar.bz2 skyhanni-a40b447b792d5e09b2afab754a87cc50d5e2ee47.zip |
added minion removal support
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/minion/MinionHelper.kt | 43 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | 12 |
2 files changed, 38 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionHelper.kt index 4e67ebeae..06d428cbb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionHelper.kt @@ -24,6 +24,7 @@ class MinionHelper { var minionInventoryOpen = false var lastCoinsRecived = 0L + var lastMinionPickedUp = 0L val minions = mutableMapOf<LorenzVec, Long>() @SubscribeEvent @@ -37,6 +38,7 @@ class MinionHelper { @SubscribeEvent fun onClick(event: InputEvent.MouseInputEvent) { if (!LorenzUtils.inSkyblock) return + if (LorenzUtils.skyBlockIsland != "Private Island") return val minecraft = Minecraft.getMinecraft() val buttonState = Mouse.getEventButtonState() @@ -53,8 +55,9 @@ class MinionHelper { } @SubscribeEvent - fun onRenderWorld(event: RenderWorldLastEvent) { + fun onRenderLastClickedMinion(event: RenderWorldLastEvent) { if (!LorenzUtils.inSkyblock) return + if (LorenzUtils.skyBlockIsland != "Private Island") return if (!SkyHanniMod.feature.minions.lastOpenedMinionDisplay) return val special = SkyHanniMod.feature.minions.lastOpenedMinionColor @@ -71,6 +74,8 @@ class MinionHelper { @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { + if (LorenzUtils.skyBlockIsland != "Private Island") return + if (InventoryUtils.currentlyOpenInventory().contains("Minion")) { if (lastClickedEntity != null) { lastMinion = lastClickedEntity @@ -83,18 +88,33 @@ class MinionHelper { minionInventoryOpen = false lastMinionOpened = System.currentTimeMillis() - val duration = System.currentTimeMillis() - lastCoinsRecived - if (duration < 2_000) { - val loc = lastMinion - if (loc != null) { - minions[loc] = System.currentTimeMillis() - SkyHanniMod.feature.hidden.minions[loc.encodeToString()] = System.currentTimeMillis() + val location = lastMinion + if (location != null) { + + if (System.currentTimeMillis() - lastCoinsRecived < 2_000) { + minions[location] = System.currentTimeMillis() + saveConfig() + } + + if (System.currentTimeMillis() - lastMinionPickedUp < 2_000) { + minions.remove(location) + saveConfig() } } } } } + private fun saveConfig() { + val minionConfig = SkyHanniMod.feature.hidden.minions + + minionConfig.clear() + for (minion in minions) { + minionConfig[minion.key.encodeToString()] = minion.value + } + + } + @SubscribeEvent fun onWorldChange(event: WorldEvent.Load) { lastClickedEntity = null @@ -106,14 +126,19 @@ class MinionHelper { @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { if (!LorenzUtils.inSkyblock) return + if (LorenzUtils.skyBlockIsland != "Private Island") return if (event.message.matchRegex("§aYou received §r§6(.*) coins§r§a!")) { lastCoinsRecived = System.currentTimeMillis() } + if (event.message.startsWith("§aYou picked up a minion!")) { + println("pick up minion message") + lastMinionPickedUp = System.currentTimeMillis() + } } @SubscribeEvent - fun onWorldRender(event: RenderWorldLastEvent) { + fun onRenderLastEmptied(event: RenderWorldLastEvent) { if (!LorenzUtils.inSkyblock) return if (!SkyHanniMod.feature.minions.emptiedTimeDisplay) return if (LorenzUtils.skyBlockIsland != "Private Island") return @@ -125,7 +150,7 @@ class MinionHelper { val duration = System.currentTimeMillis() - minion.value val format = StringUtils.formatDuration(duration / 1000) - val text = "§eLast emptied: $format" + val text = "§eHopper Emptied: $format" event.drawString(location.add(0.0, 2.0, 0.0), text, true) } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index ea88f8eb8..55c87c3a8 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -52,20 +52,16 @@ object StringUtils { val formatSeconds = durationFormat.format(sec) if (days > 0) { - return "" + days + "d " + formatHours + ":" + formatMinutes + ":" + formatSeconds + return "${days}d $formatHours:$formatMinutes:$formatSeconds ago" } if (hours > 0) { - return "$formatHours:$formatMinutes:$formatSeconds" + return "$formatHours:$formatMinutes:$formatSeconds ago" } if (minutes > 0) { - return "$formatMinutes:$formatSeconds" + return "$formatMinutes:$formatSeconds ago" } if (sec > 0) { - return if (sec == 1L) { - "$formatSeconds second" - } else { - "$formatSeconds seconds" - } + return "${sec}s ago" } return "Now" |