From 6d4f9a049cf530930fe502a3a716b8ba5cb59827 Mon Sep 17 00:00:00 2001 From: Appability Date: Tue, 15 Aug 2023 10:31:16 -0700 Subject: fix formatDuration and refactor with Timer class --- .../features/misc/NonGodPotEffectDisplay.kt | 78 ++++++++++++---------- src/main/java/at/hannibal2/skyhanni/utils/Timer.kt | 43 ++++++++++++ 2 files changed, 84 insertions(+), 37 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/Timer.kt diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt index 1a37cb8ee..c0c5e08bc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt @@ -12,14 +12,20 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.TimeUnit import at.hannibal2.skyhanni.utils.TimeUtils +import at.hannibal2.skyhanni.utils.Timer import net.minecraft.network.play.server.S47PacketPlayerListHeaderFooter import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration +import kotlin.time.Duration.Companion.hours +import kotlin.time.Duration.Companion.milliseconds +import kotlin.time.Duration.Companion.minutes +import kotlin.time.Duration.Companion.seconds class NonGodPotEffectDisplay { private val config get() = SkyHanniMod.feature.misc private var checkFooter = false - private val effectDuration = mutableMapOf() + private val effectDuration = mutableMapOf() private var display = emptyList() enum class NonGodPotEffect(val apiName: String, val displayName: String, val isMixin: Boolean = false) { @@ -52,26 +58,26 @@ class NonGodPotEffectDisplay { if (event.message == "§aYou ate a §r§aRe-heated Gummy Polar Bear§r§a!") { checkFooter = true - effectDuration[NonGodPotEffect.SMOLDERING] = System.currentTimeMillis() + 1000 * 60 * 60 + effectDuration[NonGodPotEffect.SMOLDERING] = Timer(1.hours) update() } if (event.message == "§a§lBUFF! §fYou have gained §r§2Mushed Glowy Tonic I§r§f! Press TAB or type /effects to view your active effects!") { checkFooter = true - effectDuration[NonGodPotEffect.GLOWY] = System.currentTimeMillis() + 1000 * 60 * 60 + effectDuration[NonGodPotEffect.GLOWY] = Timer(1.hours) update() } if (event.message == "§a§lBUFF! §fYou splashed yourself with §r§bWisp's Ice-Flavored Water I§r§f! Press TAB or type /effects to view your active effects!") { checkFooter = true - effectDuration[NonGodPotEffect.WISP] = System.currentTimeMillis() + 1000 * 60 * 5 + effectDuration[NonGodPotEffect.WISP] = Timer(5.minutes) update() } if (event.message == "§e[NPC] §6King Yolkar§f: §rThese eggs will help me stomach my pain.") { checkFooter = true - effectDuration[NonGodPotEffect.GOBLIN] = System.currentTimeMillis() + 1000 * 60 * 20 + effectDuration[NonGodPotEffect.GOBLIN] = Timer(20.minutes) update() } if (event.message == "§cThe Goblin King's §r§afoul stench §r§chas dissipated!") { @@ -83,7 +89,7 @@ class NonGodPotEffectDisplay { private fun update() { val now = System.currentTimeMillis() - if (effectDuration.values.removeIf { now > it }) { + if (effectDuration.values.removeIf { it.ended }) { //to fetch the real amount of active pots totalEffectsCount = 0 checkFooter = true @@ -95,13 +101,14 @@ class NonGodPotEffectDisplay { private fun drawDisplay(now: Long): MutableList { val newDisplay = mutableListOf() for ((effect, time) in effectDuration.sorted()) { + if (time.ended) continue if (effect == NonGodPotEffect.INVISIBILITY) continue if (effect.isMixin && !config.nonGodPotEffectShowMixins) continue - val seconds = time - now - val format = TimeUtils.formatDuration(seconds, TimeUnit.HOUR) - val color = colorForTime(seconds) + val remaining = time.remaining.coerceAtLeast(0.seconds) + val format = TimeUtils.formatDuration(remaining.inWholeMilliseconds, TimeUnit.HOUR) + val color = colorForTime(remaining) val displayName = effect.displayName newDisplay.add("$displayName $color$format") @@ -115,14 +122,11 @@ class NonGodPotEffectDisplay { return newDisplay } - private fun colorForTime(seconds: Long): String { - return if (seconds <= 60) { - "§c" - } else if (seconds <= 60 * 3) { - "§6" - } else if (seconds <= 60 * 10) { - "§e" - } else "§f" + private fun colorForTime(duration: Duration) = when (duration) { + in 0.seconds..60.seconds -> "§c" + in 60.seconds..3.minutes -> "§6" + in 3.minutes..10.minutes -> "§e" + else -> "§f" } @SubscribeEvent @@ -144,27 +148,27 @@ class NonGodPotEffectDisplay { if (!event.inventoryName.endsWith("Active Effects")) return for (stack in event.inventoryItems.values) { - val name = stack.name ?: continue - for (effect in NonGodPotEffect.entries) { - if (name != effect.displayName) continue - for (line in stack.getLore()) { - if (line.contains("Remaining") && - line != "§7Time Remaining: §aCompleted!" && - !line.contains("Remaining Uses") - ) { - val duration = try { - TimeUtils.getMillis(line.split("§f")[1]) - } catch (e: IndexOutOfBoundsException) { - CopyErrorCommand.logError( - Exception("'§f' not found in line '$line'", e), - "Error while reading Non God-Potion effects from tab list" - ) - continue - } - effectDuration[effect] = System.currentTimeMillis() + duration - update() + val name = stack.name ?: continue + for (effect in NonGodPotEffect.entries) { + if (name != effect.displayName) continue + for (line in stack.getLore()) { + if (line.contains("Remaining") && + line != "§7Time Remaining: §aCompleted!" && + !line.contains("Remaining Uses") + ) { + val duration = try { + TimeUtils.getMillis(line.split("§f")[1]) + } catch (e: IndexOutOfBoundsException) { + CopyErrorCommand.logError( + Exception("'§f' not found in line '$line'", e), + "Error while reading Non God-Potion effects from tab list" + ) + continue } + effectDuration[effect] = Timer(duration.milliseconds) + update() } + } } } } @@ -186,7 +190,7 @@ class NonGodPotEffectDisplay { if (line.startsWith(effect.displayName)) { try { val duration = TimeUtils.getMillis(line.split("§f")[1]) - effectDuration[effect] = System.currentTimeMillis() + duration + effectDuration[effect] = Timer(duration.milliseconds) update() } catch (e: IndexOutOfBoundsException) { LorenzUtils.debug("Error while reading non god pot effects from tab list! line: '$line'") diff --git a/src/main/java/at/hannibal2/skyhanni/utils/Timer.kt b/src/main/java/at/hannibal2/skyhanni/utils/Timer.kt new file mode 100644 index 000000000..55ea90b52 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/Timer.kt @@ -0,0 +1,43 @@ +package at.hannibal2.skyhanni.utils + +import com.google.gson.annotations.Expose +import kotlin.time.Duration + +class Timer( + @Expose + var duration: Duration, + + @Expose + private var started: SimpleTimeMark = SimpleTimeMark.now(), + + startPaused: Boolean = false +): Comparable { + + @Expose + private var paused: SimpleTimeMark? = null + + init { + if (startPaused) { + paused = started + } + } + + val ended get() = !remaining.isPositive() + val remaining get() = duration - elapsed + val elapsed get() = paused?.let { it - started } ?: started.passedSince() + + fun pause() { + paused = SimpleTimeMark.now() + } + + fun resume() { + paused?.let { + started = it + duration = it - started + paused = null + } + } + + override fun compareTo(other: Timer): Int = remaining.compareTo(other.remaining) + +} \ No newline at end of file -- cgit From 5d51537458f15aba4c2471de4749a67ca9cbe044 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 29 Aug 2023 02:02:04 +0200 Subject: Fixed ConcurrentModificationException in GardenCropSpeed --- .../features/garden/farming/GardenCropSpeed.kt | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt index c9868d4e3..c7817066e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt @@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy import com.google.gson.JsonObject import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.concurrent.fixedRateTimer @@ -28,7 +29,7 @@ object GardenCropSpeed { var averageBlocksPerSecond = 0.0 - private val blocksSpeedList = mutableListOf() + private var blocksSpeedList = listOf() private var blocksBroken = 0 private var secondsStopped = 0 @@ -81,20 +82,22 @@ object GardenCropSpeed { this.blocksBroken = 0 if (blocksBroken == 0) { - if (blocksSpeedList.size == 0) return + if (blocksSpeedList.isEmpty()) return secondsStopped++ } else { if (secondsStopped >= config.blocksBrokenResetTime) { resetSpeed() } - while (secondsStopped > 0) { - blocksSpeedList.add(0) - secondsStopped -= 1 - } - blocksSpeedList.add(blocksBroken) - if (blocksSpeedList.size == 2) { - blocksSpeedList.removeFirst() - blocksSpeedList.add(blocksBroken) + blocksSpeedList = blocksSpeedList.editCopy { + while (secondsStopped > 0) { + this.add(0) + secondsStopped -= 1 + } + this.add(blocksBroken) + if (this.size == 2) { + this.removeFirst() + this.add(blocksBroken) + } } averageBlocksPerSecond = if (blocksSpeedList.size > 1) { blocksSpeedList.dropLast(1).average() @@ -170,7 +173,7 @@ object GardenCropSpeed { private fun resetSpeed() { averageBlocksPerSecond = 0.0 - blocksSpeedList.clear() + blocksSpeedList = emptyList() secondsStopped = 0 } -- cgit From cc59cccadf38cb263d5c035ac4f0b74d9adfe1ca Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 29 Aug 2023 12:17:44 +0200 Subject: Added Winter Time --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 +- .../skyhanni/config/features/MiscConfig.java | 30 +++++++++----- .../hannibal2/skyhanni/features/misc/RealTime.kt | 24 ----------- .../skyhanni/features/misc/TimeFeatures.kt | 46 ++++++++++++++++++++++ .../at/hannibal2/skyhanni/utils/SimpleTimeMark.kt | 6 ++- 5 files changed, 72 insertions(+), 36 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/RealTime.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 3c6061087..80cb6f414 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -215,7 +215,7 @@ class SkyHanniMod { loadModule(AshfangHideDamageIndicator()) loadModule(ItemStars()) loadModule(MinionFeatures()) - loadModule(RealTime()) + loadModule(TimeFeatures()) loadModule(RngMeterInventory()) loadModule(WikiCommand()) loadModule(SendCoordinatedCommand()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java index 00a85b441..1f6745f6c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java @@ -46,19 +46,29 @@ public class MiscConfig { @Expose public Position petDisplayPos = new Position(-330, -15, false, true); + @ConfigOption(name = "Time Features", desc = "") + @Accordion @Expose - @ConfigOption(name = "Time", desc = "") - @ConfigEditorAccordion(id = 1) - public boolean time = false; + public TimeConfig time = new TimeConfig(); - @Expose - @ConfigOption(name = "Real Time", desc = "Display the current computer time, a handy feature when playing in full-screen mode.") - @ConfigEditorBoolean - @ConfigAccordionId(id = 1) - public boolean realTime = false; + public static class TimeConfig { - @Expose - public Position realTimePos = new Position(10, 10, false, true); + @Expose + @ConfigOption(name = "Real Time", desc = "Display the current computer time, a handy feature when playing in full-screen mode.") + @ConfigEditorBoolean + public boolean realTime = false; + + @Expose + public Position realTimePos = new Position(10, 10, false, true); + + @Expose + @ConfigOption(name = "Winter Time", desc = "While on the Winter Island, show a timer until Jerry's Workshop closes.") + @ConfigEditorBoolean + public boolean winterTime = true; + + @Expose + public Position winterTimePos = new Position(10, 10, false, true); + } @ConfigOption(name = "Hide Armor", desc = "") @Accordion diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/RealTime.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/RealTime.kt deleted file mode 100644 index c5bda78c8..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/RealTime.kt +++ /dev/null @@ -1,24 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RenderUtils.renderString -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.text.SimpleDateFormat - -class RealTime { - - private val format = SimpleDateFormat("HH:mm:ss") - - @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { - if (!isEnabled()) return - - SkyHanniMod.feature.misc.realTimePos.renderString(format.format(System.currentTimeMillis()), posLabel = "Real Time") - } - - private fun isEnabled(): Boolean { - return LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.realTime - } -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt new file mode 100644 index 000000000..e956791bf --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt @@ -0,0 +1,46 @@ +package at.hannibal2.skyhanni.features.misc + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.RecalculatingValue +import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark +import at.hannibal2.skyhanni.utils.TimeUtils.format +import io.github.moulberry.notenoughupdates.util.SkyBlockTime +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.text.SimpleDateFormat +import kotlin.time.Duration.Companion.days +import kotlin.time.Duration.Companion.seconds + +class TimeFeatures { + private val config get() = SkyHanniMod.feature.misc.time + + private val format = SimpleDateFormat("HH:mm:ss") + + private val startOfNextYear = RecalculatingValue(1.seconds) { + SkyBlockTime(year = SkyBlockTime.now().year + 1).asTimeMark() + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + if (!LorenzUtils.inSkyBlock) return + + if (config.realTime) { + config.realTimePos.renderString(format.format(System.currentTimeMillis()), posLabel = "Real Time") + } + + if (config.winterTime && IslandType.WINTER.isInIsland()) { + val timeTillNextYear = startOfNextYear.getValue().timeUntil() + val alreadyInNextYear = timeTillNextYear > 5.days + val text = if (alreadyInNextYear) { + "§fJerry's Workshop §cis closing!" + } else { + "§fJerry's Workshop §ecloses in §b${timeTillNextYear.format()}" + } + config.winterTimePos.renderString(text, posLabel = "Winter Time") + } + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt b/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt index 581585c9a..e79599cae 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.utils +import io.github.moulberry.notenoughupdates.util.SkyBlockTime import java.time.Instant import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds @@ -14,7 +15,9 @@ value class SimpleTimeMark(private val millis: Long) { fun passedSince() = if (millis == 0L) Duration.INFINITE else now() - this - fun isInPast() = !passedSince().isNegative() + fun timeUntil() = -passedSince() + + fun isInPast() = timeUntil().isNegative() override fun toString(): String { if (millis == 0L) return "The Far Past" @@ -28,5 +31,6 @@ value class SimpleTimeMark(private val millis: Long) { fun farPast() = SimpleTimeMark(0) fun Long.asTimeMark() = SimpleTimeMark(this) + fun SkyBlockTime.asTimeMark() = SimpleTimeMark(toMillis()) } } \ No newline at end of file -- cgit From 957c42dfbc17c9d812a14036cf532237578ff848 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:53:39 +0200 Subject: Added Raindrake support to Damage Indicator. --- .../skyhanni/config/features/DamageIndicatorConfig.java | 5 +++-- .../at/hannibal2/skyhanni/features/damageindicator/BossType.kt | 9 ++++++++- .../at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt | 8 +++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java index d1f522a9e..a6b8e7db0 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java @@ -56,11 +56,12 @@ public class DamageIndicatorConfig { "Dummy", "§bArachne", "§bThe Rift Bosses", - "§bRiftstalker Bloodfiend" + "§bRiftstalker Bloodfiend", + "§6Raindrake" } ) //TODO only show currently working and tested features - public List bossesToShow = new ArrayList<>(Arrays.asList(0, 1, 2, 5, 6, 7, 8, 9, 18, 19, 21, 22, 23)); + public List bossesToShow = new ArrayList<>(Arrays.asList(0, 1, 2, 5, 6, 7, 8, 9, 18, 19, 21, 22, 23, 24)); @Expose @ConfigOption(name = "Hide Damage Splash", desc = "Hiding damage splashes near the damage indicator.") diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt index 4755d7dd1..c51dfb412 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt @@ -1,6 +1,11 @@ package at.hannibal2.skyhanni.features.damageindicator -enum class BossType(val fullName: String, val bossTypeToggle: Int, val shortName: String = fullName, val showDeathTime: Boolean = false) { +enum class BossType( + val fullName: String, + val bossTypeToggle: Int, + val shortName: String = fullName, + val showDeathTime: Boolean = false +) { GENERIC_DUNGEON_BOSS("Generic Dungeon boss", 0),//TODO split into different bosses //Nether Mini Bosses @@ -83,6 +88,8 @@ enum class BossType(val fullName: String, val bossTypeToggle: Int, val shortName LEECH_SUPREME("§cLeech Supreme", 22), BACTE("§aBacte", 22), + WINTER_REINDRAKE("Raindrake", 24),//TODO fix totally + //TODO arachne //TODO corelone diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt index 4194c015e..5e660510e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.damageindicator +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.features.dungeon.DungeonData import at.hannibal2.skyhanni.features.dungeon.DungeonLividFinder import at.hannibal2.skyhanni.features.rift.RiftAPI @@ -11,6 +12,7 @@ import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth import at.hannibal2.skyhanni.utils.LorenzUtils.derpy +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.StringUtils.matchRegex import at.hannibal2.skyhanni.utils.getLorenzVec @@ -258,7 +260,11 @@ class MobFinder { } if (entity is EntityDragon) { //TODO testing and use sidebar data - return EntityResult(bossType = BossType.END_ENDER_DRAGON) + if (IslandType.THE_END.isInIsland()) { + return EntityResult(bossType = BossType.END_ENDER_DRAGON) + } else if (IslandType.WINTER.isInIsland()) { + return EntityResult(bossType = BossType.WINTER_REINDRAKE) + } } if (entity is EntityIronGolem) { if (entity.hasNameTagWith(3, "§e﴾ §8[§7Lv100§8] §lEndstone Protector§r ")) { -- cgit From d4ff1320053e16472956eb0b338c6b2feeef2639 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:58:30 +0200 Subject: reindrake not raindrake --- .../at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java | 2 +- .../java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java index a6b8e7db0..af72333b9 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java @@ -57,7 +57,7 @@ public class DamageIndicatorConfig { "§bArachne", "§bThe Rift Bosses", "§bRiftstalker Bloodfiend", - "§6Raindrake" + "§6Reindrake" } ) //TODO only show currently working and tested features diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt index c51dfb412..264c8700a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt @@ -88,7 +88,7 @@ enum class BossType( LEECH_SUPREME("§cLeech Supreme", 22), BACTE("§aBacte", 22), - WINTER_REINDRAKE("Raindrake", 24),//TODO fix totally + WINTER_REINDRAKE("Reindrake", 24),//TODO fix totally //TODO arachne -- cgit From 294aa4be9dbafe7e8f82efb2f406661c860a992a Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 29 Aug 2023 15:15:50 +0200 Subject: Fixing IllegalStateException at ToolTooltipTweaks --- .../java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt index 759f9f0ec..e0931cd4c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt @@ -104,9 +104,7 @@ class ToolTooltipTweaks { if (removingFarmhandDescription) { iterator.remove() removingFarmhandDescription = line != "§5§o" - } - - if (removingCounterDescription && !line.startsWith("§5§o§7You have")) { + } else if (removingCounterDescription && !line.startsWith("§5§o§7You have")) { iterator.remove() } else { removingCounterDescription = false -- cgit From ac7893950e3fa3b177bab421ccbcd37de2e5e73f Mon Sep 17 00:00:00 2001 From: Vixid <52578495+VixidDev@users.noreply.github.com> Date: Tue, 29 Aug 2023 15:44:08 +0100 Subject: Add Garden Plot border feature (#401) Add Garden Plot border feature #401 --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 1 + .../skyhanni/config/features/GardenConfig.java | 5 ++ .../skyhanni/features/garden/GardenPlotBorders.kt | 98 ++++++++++++++++++++++ .../at/hannibal2/skyhanni/utils/RenderUtils.kt | 1 - 4 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 80cb6f414..ee3244d4d 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -382,6 +382,7 @@ class SkyHanniMod { loadModule(AccountUpgradeReminder()) loadModule(PetExpTooltip()) loadModule(Translator()) + loadModule(GardenPlotBorders()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java index 9aeb8d1a8..403aed763 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java @@ -1398,4 +1398,9 @@ public class GardenConfig { @Expose public Position cropSpeedMeterPos = new Position(278, -236, false, true); + + @Expose + @ConfigOption(name = "Enable Plot Borders", desc = "Enable the use of F3 + G hotkey to show Garden plot borders. Similar to how later minecraft version render chunk borders.") + @ConfigEditorBoolean + public boolean plotBorders = true; } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt new file mode 100644 index 000000000..e97fb59e2 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt @@ -0,0 +1,98 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine +import net.minecraft.client.Minecraft +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import org.lwjgl.input.Keyboard +import kotlin.math.floor + +class GardenPlotBorders { + + private val config get() = SkyHanniMod.feature.garden.plotBorders + private var showBorders = false + private val LINE_COLOR = LorenzColor.YELLOW.toColor() + + private fun LorenzVec.addX(x: Int) = add(x, 0, 0) + private fun LorenzVec.addZ(z: Int) = add(0, 0, z) + private fun LorenzVec.addXZ(x: Int, z: Int) = add(x, 0, z) + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!isEnabled()) return + + val keyPressed = if (Keyboard.getEventKey() == 0) Keyboard.getEventCharacter() else Keyboard.getEventKey() + + if (keyPressed == Keyboard.KEY_G && Keyboard.isKeyDown(Keyboard.KEY_F3)) { + showBorders = !showBorders + } + } + + @SubscribeEvent + fun render(event: RenderWorldLastEvent) { + if (!showBorders) return + + val entity = Minecraft.getMinecraft().renderViewEntity + + // Lowest point in garden + val minHeight = 66 + val maxHeight = 256 + + // These don't refer to Minecraft chunks but rather garden plots, but I use + // the word chunk as the logic closely represents how chunk borders are rendered in latter mc versions + val chunkX = floor((entity.posX + 48) / 96).toInt() + val chunkZ = floor((entity.posZ + 48) / 96).toInt() + val chunkMinX = (chunkX * 96) - 48 + val chunkMinZ = (chunkZ * 96) - 48 + + // Render 4 vertical corners + for (i in 0..96 step 96) { + for (j in 0..96 step 96) { + val start = LorenzVec(chunkMinX + i, minHeight, chunkMinZ + j) + val end = LorenzVec(chunkMinX + i, maxHeight, chunkMinZ + j) + event.draw3DLine(start, end, LorenzColor.DARK_BLUE.toColor(), 2, true) + } + } + + // Render vertical on X-Axis + for (x in 4..<96 step 4) { + val start = LorenzVec(chunkMinX + x, minHeight, chunkMinZ) + val end = LorenzVec(chunkMinX + x, maxHeight, chunkMinZ) + // Front lines + event.draw3DLine(start, end, LINE_COLOR, 1, true) + // Back lines + event.draw3DLine(start.addZ(96), end.addZ(96), LINE_COLOR, 1, true) + } + + // Render vertical on Z-Axis + for (z in 4..<96 step 4) { + val start = LorenzVec(chunkMinX, minHeight, chunkMinZ + z) + val end = LorenzVec(chunkMinX, maxHeight, chunkMinZ + z) + // Left lines + event.draw3DLine(start, end, LINE_COLOR, 1, true) + // Right lines + event.draw3DLine(start.addX(96), end.addX(96), LINE_COLOR, 1, true) + } + + // Render horizontal + for (y in minHeight..maxHeight step 4) { + val start = LorenzVec(chunkMinX, y, chunkMinZ) + // (minX, minZ) -> (minX, minZ + 96) + event.draw3DLine(start, start.addZ(96), LINE_COLOR, 1, true) + // (minX, minZ + 96) -> (minX + 96, minZ + 96) + event.draw3DLine(start.addZ(96), start.addXZ(96, 96), LINE_COLOR, 1, true) + // (minX + 96, minZ + 96) -> (minX + 96, minZ) + event.draw3DLine(start.addXZ(96, 96), start.addX(96), LINE_COLOR, 1, true) + // (minX + 96, minZ) -> (minX, minZ) + event.draw3DLine(start.addX(96), start, LINE_COLOR, 1, true) + } + } + + fun isEnabled() = GardenAPI.inGarden() && config +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 0150e7311..64e68bec1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -670,7 +670,6 @@ object RenderUtils { } fun RenderWorldLastEvent.draw3DLine(p1: LorenzVec, p2: LorenzVec, color: Color, lineWidth: Int, depth: Boolean) { - GlStateManager.disableDepth() GlStateManager.disableCull() val render = Minecraft.getMinecraft().renderViewEntity -- cgit From a2167bc4e6a428b45f1ca7859b7690853012ef0e Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 29 Aug 2023 16:51:03 +0200 Subject: Hide plot chunk grid outside the garden area and hiding outside garden island --- .../skyhanni/features/garden/GardenPlotBorders.kt | 46 ++++++++++++++++------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt index e97fb59e2..00d3461e3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt @@ -3,13 +3,13 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.LorenzColor -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine import net.minecraft.client.Minecraft import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.input.Keyboard +import java.awt.Color import kotlin.math.floor class GardenPlotBorders { @@ -24,7 +24,6 @@ class GardenPlotBorders { @SubscribeEvent fun onTick(event: LorenzTickEvent) { - if (!LorenzUtils.inSkyBlock) return if (!isEnabled()) return val keyPressed = if (Keyboard.getEventKey() == 0) Keyboard.getEventCharacter() else Keyboard.getEventKey() @@ -36,6 +35,7 @@ class GardenPlotBorders { @SubscribeEvent fun render(event: RenderWorldLastEvent) { + if (!isEnabled()) return if (!showBorders) return val entity = Minecraft.getMinecraft().renderViewEntity @@ -56,7 +56,7 @@ class GardenPlotBorders { for (j in 0..96 step 96) { val start = LorenzVec(chunkMinX + i, minHeight, chunkMinZ + j) val end = LorenzVec(chunkMinX + i, maxHeight, chunkMinZ + j) - event.draw3DLine(start, end, LorenzColor.DARK_BLUE.toColor(), 2, true) + event.tryDraw3DLine(start, end, LorenzColor.DARK_BLUE.toColor(), 2, true) } } @@ -65,9 +65,9 @@ class GardenPlotBorders { val start = LorenzVec(chunkMinX + x, minHeight, chunkMinZ) val end = LorenzVec(chunkMinX + x, maxHeight, chunkMinZ) // Front lines - event.draw3DLine(start, end, LINE_COLOR, 1, true) + event.tryDraw3DLine(start, end, LINE_COLOR, 1, true) // Back lines - event.draw3DLine(start.addZ(96), end.addZ(96), LINE_COLOR, 1, true) + event.tryDraw3DLine(start.addZ(96), end.addZ(96), LINE_COLOR, 1, true) } // Render vertical on Z-Axis @@ -75,24 +75,46 @@ class GardenPlotBorders { val start = LorenzVec(chunkMinX, minHeight, chunkMinZ + z) val end = LorenzVec(chunkMinX, maxHeight, chunkMinZ + z) // Left lines - event.draw3DLine(start, end, LINE_COLOR, 1, true) + event.tryDraw3DLine(start, end, LINE_COLOR, 1, true) // Right lines - event.draw3DLine(start.addX(96), end.addX(96), LINE_COLOR, 1, true) + event.tryDraw3DLine(start.addX(96), end.addX(96), LINE_COLOR, 1, true) } // Render horizontal for (y in minHeight..maxHeight step 4) { val start = LorenzVec(chunkMinX, y, chunkMinZ) // (minX, minZ) -> (minX, minZ + 96) - event.draw3DLine(start, start.addZ(96), LINE_COLOR, 1, true) + event.tryDraw3DLine(start, start.addZ(96), LINE_COLOR, 1, true) // (minX, minZ + 96) -> (minX + 96, minZ + 96) - event.draw3DLine(start.addZ(96), start.addXZ(96, 96), LINE_COLOR, 1, true) + event.tryDraw3DLine(start.addZ(96), start.addXZ(96, 96), LINE_COLOR, 1, true) // (minX + 96, minZ + 96) -> (minX + 96, minZ) - event.draw3DLine(start.addXZ(96, 96), start.addX(96), LINE_COLOR, 1, true) + event.tryDraw3DLine(start.addXZ(96, 96), start.addX(96), LINE_COLOR, 1, true) // (minX + 96, minZ) -> (minX, minZ) - event.draw3DLine(start.addX(96), start, LINE_COLOR, 1, true) + event.tryDraw3DLine(start.addX(96), start, LINE_COLOR, 1, true) } } + private fun RenderWorldLastEvent.tryDraw3DLine( + p1: LorenzVec, + p2: LorenzVec, + color: Color, + lineWidth: Int, + depth: Boolean + ) { + if (isOutOfBorders(p1)) return + if (isOutOfBorders(p2)) return + draw3DLine(p1, p2, color, lineWidth, depth) + } + + + private fun isOutOfBorders(location: LorenzVec) = when { + location.x > 240 -> true + location.x < -240 -> true + location.z > 240 -> true + location.z < -240 -> true + + else -> false + } + fun isEnabled() = GardenAPI.inGarden() && config -} \ No newline at end of file +} -- cgit From e34960c5ef84807d7f610641e4ff6b9a58f4d714 Mon Sep 17 00:00:00 2001 From: Eric W <42985687+ericpretzel@users.noreply.github.com> Date: Tue, 29 Aug 2023 08:07:46 -0700 Subject: Sack change event (#403) Create SackChangeEvent #403 --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 1 + .../java/at/hannibal2/skyhanni/data/SackAPI.kt | 49 ++++++++++++++++++++++ .../hannibal2/skyhanni/events/SackChangeEvent.kt | 7 ++++ 3 files changed, 57 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/events/SackChangeEvent.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index ee3244d4d..2c58985e8 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -179,6 +179,7 @@ class SkyHanniMod { loadModule(SlayerAPI) loadModule(PurseAPI()) loadModule(RiftAPI) + loadModule(SackAPI()) // features loadModule(BazaarOrderHelper()) diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt new file mode 100644 index 000000000..4efb30727 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -0,0 +1,49 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.SackChangeEvent +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + + +class SackAPI { + + data class SackChange(val delta: Int, val internalName: NEUInternalName, val sacks: List) + + private val sackChangeRegex = Regex("""([+-][\d,]+) (.+) \((.+)\)""") + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!event.message.removeColor().startsWith("[Sacks]")) return + + val sackChanges = ArrayList() + + val sackAddText = event.chatComponent.siblings.firstNotNullOfOrNull { sibling -> + sibling.chatStyle?.chatHoverEvent?.value?.formattedText?.removeColor()?.takeIf { + it.startsWith("Added") + } + } ?: "" + val sackRemoveText = event.chatComponent.siblings.firstNotNullOfOrNull { sibling -> + sibling.chatStyle?.chatHoverEvent?.value?.formattedText?.removeColor()?.takeIf { + it.startsWith("Removed") + } + } ?: "" + + val sackChangeText = sackAddText + sackRemoveText + if (sackChangeText.isEmpty()) return + + val otherItemsAdded = sackAddText.contains("other items") + val otherItemsRemoved = sackRemoveText.contains("other items") + + for (match in sackChangeRegex.findAll(sackChangeText)) { + val delta = match.groups[1]!!.value.replace(",", "").toInt() + val item = match.groups[2]!!.value + val sacks = match.groups[3]!!.value.split(", ") + + val internalName = NEUInternalName.fromItemName(item) + sackChanges.add(SackChange(delta, internalName, sacks)) + } + SackChangeEvent(sackChanges, otherItemsAdded, otherItemsRemoved).postAndCatch() + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/SackChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/SackChangeEvent.kt new file mode 100644 index 000000000..797605e80 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/SackChangeEvent.kt @@ -0,0 +1,7 @@ +package at.hannibal2.skyhanni.events + +import at.hannibal2.skyhanni.data.SackAPI + +class SackChangeEvent(val sackChanges: List, + val otherItemsAdded: Boolean, + val otherItemsRemoved: Boolean) : LorenzEvent() -- cgit From 238085dd49de8bca06ed816bc7a8d369390cdf30 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 29 Aug 2023 17:08:20 +0200 Subject: code cleanup --- src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt | 3 +-- src/main/java/at/hannibal2/skyhanni/events/SackChangeEvent.kt | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index 4efb30727..3990e13d6 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -17,8 +17,6 @@ class SackAPI { fun onChat(event: LorenzChatEvent) { if (!event.message.removeColor().startsWith("[Sacks]")) return - val sackChanges = ArrayList() - val sackAddText = event.chatComponent.siblings.firstNotNullOfOrNull { sibling -> sibling.chatStyle?.chatHoverEvent?.value?.formattedText?.removeColor()?.takeIf { it.startsWith("Added") @@ -36,6 +34,7 @@ class SackAPI { val otherItemsAdded = sackAddText.contains("other items") val otherItemsRemoved = sackRemoveText.contains("other items") + val sackChanges = ArrayList() for (match in sackChangeRegex.findAll(sackChangeText)) { val delta = match.groups[1]!!.value.replace(",", "").toInt() val item = match.groups[2]!!.value diff --git a/src/main/java/at/hannibal2/skyhanni/events/SackChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/SackChangeEvent.kt index 797605e80..b2006bc0d 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/SackChangeEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/SackChangeEvent.kt @@ -2,6 +2,8 @@ package at.hannibal2.skyhanni.events import at.hannibal2.skyhanni.data.SackAPI -class SackChangeEvent(val sackChanges: List, - val otherItemsAdded: Boolean, - val otherItemsRemoved: Boolean) : LorenzEvent() +class SackChangeEvent( + val sackChanged: List, + val otherItemsAdded: Boolean, + val otherItemsRemoved: Boolean +) : LorenzEvent() -- cgit From 71a6b08b376be7d742107df982905cac0d7ecf70 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Tue, 29 Aug 2023 20:25:01 +0200 Subject: Add default option selector #400 * Allow for update only options * Clean/Split up mass configuration options * Merge remote-tracking branch 'origin/beta' into feat/defaultoptions * Fix merge errors --- build.gradle.kts | 7 +- gradle/libs.versions.toml | 7 + src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../at/hannibal2/skyhanni/config/FeatureToggle.kt | 15 ++ .../java/at/hannibal2/skyhanni/config/Storage.java | 6 + .../hannibal2/skyhanni/config/commands/Commands.kt | 26 ++- .../skyhanni/config/commands/SimpleCommand.java | 4 +- .../skyhanni/config/features/AshfangConfig.java | 9 + .../skyhanni/config/features/BazaarConfig.java | 5 + .../skyhanni/config/features/BingoConfig.java | 6 + .../skyhanni/config/features/ChatConfig.java | 27 +++ .../skyhanni/config/features/CommandsConfig.java | 4 + .../config/features/DamageIndicatorConfig.java | 2 + .../skyhanni/config/features/DianaConfig.java | 5 + .../skyhanni/config/features/DungeonConfig.java | 20 +++ .../skyhanni/config/features/FishingConfig.java | 2 + .../massconfiguration/DefaultConfigFeatures.kt | 112 ++++++++++++ .../massconfiguration/DefaultConfigOptionGui.kt | 193 +++++++++++++++++++++ .../massconfiguration/FeatureToggleProcessor.kt | 70 ++++++++ 19 files changed, 515 insertions(+), 7 deletions(-) create mode 100644 gradle/libs.versions.toml create mode 100644 src/main/java/at/hannibal2/skyhanni/config/FeatureToggle.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigOptionGui.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/FeatureToggleProcessor.kt diff --git a/build.gradle.kts b/build.gradle.kts index b98a63bf1..4b8f8f4c7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,6 +34,7 @@ repositories { } } maven("https://repo.nea.moe/releases") + maven("https://maven.notenoughupdates.org/releases") } val shadowImpl by configurations.creating { @@ -87,10 +88,10 @@ dependencies { isTransitive = false } - shadowModImpl("com.github.NotEnoughUpdates:MoulConfig:1.1.5") - devenvMod("com.github.NotEnoughUpdates:MoulConfig:1.1.5:test") + shadowModImpl(libs.moulconfig) + devenvMod(variantOf(libs.moulconfig) { classifier("test") }) - shadowImpl("moe.nea:libautoupdate:1.0.3") + shadowImpl(libs.libautoupdate) shadowImpl("org.jetbrains.kotlin:kotlin-reflect:1.9.0") // testImplementation(kotlin("test")) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..376f286e7 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,7 @@ +[versions] +libautoupdate = "1.0.3" +moulconfig = "1.2.0" + +[libraries] +moulconfig = { module = "org.notenoughupdates.moulconfig:MoulConfig", version.ref = "moulconfig" } +libautoupdate = { module = "moe.nea:libautoupdate", version.ref = "libautoupdate" } diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 2c58985e8..6d60ebca7 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.config.commands.Commands.init import at.hannibal2.skyhanni.data.* import at.hannibal2.skyhanni.data.repo.RepoManager import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.features.misc.massconfiguration.DefaultConfigFeatures import at.hannibal2.skyhanni.features.anvil.AnvilCombineHelper import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.features.bazaar.BazaarBestSellMethod @@ -168,6 +169,7 @@ class SkyHanniMod { loadModule(ProfileStorageData) loadModule(TitleData()) loadModule(BlockData()) + loadModule(DefaultConfigFeatures) // APIs loadModule(BazaarApi()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/FeatureToggle.kt b/src/main/java/at/hannibal2/skyhanni/config/FeatureToggle.kt new file mode 100644 index 000000000..bf9db0553 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/FeatureToggle.kt @@ -0,0 +1,15 @@ +package at.hannibal2.skyhanni.config + +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean + +/** + * Annotate a [ConfigEditorBoolean] to indicate that it is a feature toggle. + */ +@Retention(AnnotationRetention.RUNTIME) +@Target(AnnotationTarget.FIELD) +annotation class FeatureToggle( + /** + * Indicate that this field being true means the corresponding feature is enabled. + */ + val trueIsEnabled: Boolean = true, +) diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index a2af0ed79..f32c66220 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -20,6 +20,12 @@ import java.util.*; public class Storage { + @Expose + public boolean hasPlayedBefore = false; + + @Expose + public Map> knownFeatureToggles = new HashMap<>(); + @Expose public Map> gardenJacobFarmingContestTimes = new HashMap<>(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index b87961a2c..73b6cb46d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -27,6 +27,7 @@ import at.hannibal2.skyhanni.features.misc.CollectionTracker import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil +import at.hannibal2.skyhanni.features.misc.massconfiguration.DefaultConfigFeatures import at.hannibal2.skyhanni.features.slayer.SlayerItemProfitTracker import at.hannibal2.skyhanni.test.PacketTest import at.hannibal2.skyhanni.test.SkyHanniConfigSearchResetCommand @@ -105,6 +106,11 @@ object Commands { registerCommand("skyhanni", "Opens the main SkyHanni config", openMainMenu) registerCommand("ff", "Opens the Farming Fortune Guide") { openFortuneGuide() } registerCommand("shcommands", "Shows this list") { commandHelp(it) } + registerCommand0("shdefaultoptions", "Select default options", { + DefaultConfigFeatures.onCommand( + it.getOrNull(0) ?: "null", it.getOrNull(1) ?: "null" + ) + }, DefaultConfigFeatures::onComplete) } private fun usersNormal() { @@ -308,8 +314,24 @@ object Commands { config.outdatedItems.clear() } - private fun registerCommand(name: String, description: String, function: (Array) -> Unit) { - ClientCommandHandler.instance.registerCommand(SimpleCommand(name, createCommand(function))) + private fun registerCommand( + name: String, + description: String, + function: (Array) -> Unit + ) = registerCommand0(name, description, function) + + private fun registerCommand0( + name: String, + description: String, + function: (Array) -> Unit, + autoComplete: ((Array) -> List) = { listOf() } + ) { + ClientCommandHandler.instance.registerCommand( + SimpleCommand( + name, + createCommand(function), + { a, b, c -> autoComplete(b) }) + ) commands.add(CommandInfo(name, description, currentCategory)) } diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.java b/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.java index fa2c310de..9ff8ade64 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.java +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.java @@ -32,9 +32,9 @@ public class SimpleCommand extends CommandBase { public abstract void processCommand(ICommandSender sender, String[] args); } - public abstract static class TabCompleteRunnable { + public interface TabCompleteRunnable { - public abstract List tabComplete(ICommandSender sender, String[] args, BlockPos pos); + List tabComplete(ICommandSender sender, String[] args, BlockPos pos); } public boolean canCommandSenderUseCommand(ICommandSender sender) { diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/AshfangConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/AshfangConfig.java index 3515b9280..575a1987d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/AshfangConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/AshfangConfig.java @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.config.features; +import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; @@ -11,6 +12,7 @@ public class AshfangConfig { @Expose @ConfigOption(name = "Freeze", desc = "Show the cooldown for how long Ashfang blocks your abilities.") @ConfigEditorBoolean + @FeatureToggle public boolean freezeCooldown = false; @Expose @@ -19,6 +21,7 @@ public class AshfangConfig { @Expose @ConfigOption(name = "Reset Time", desc = "Show the cooldown until Ashfang pulls his underlings back.") @ConfigEditorBoolean + @FeatureToggle public boolean nextResetCooldown = false; @Expose @@ -27,6 +30,7 @@ public class AshfangConfig { @Expose @ConfigOption(name = "Gravity Orbs", desc = "Shows the Gravity Orbs more clearly.") @ConfigEditorBoolean + @FeatureToggle public boolean gravityOrbs = false; @Expose @@ -37,6 +41,7 @@ public class AshfangConfig { @Expose @ConfigOption(name = "Blazing Souls", desc = "Shows the Blazing Souls more clearly.") @ConfigEditorBoolean + @FeatureToggle public boolean blazingSouls = false; @Expose @@ -47,20 +52,24 @@ public class AshfangConfig { @Expose @ConfigOption(name = "Highlight Blazes", desc = "Highlight the different blazes in their respective colors.") @ConfigEditorBoolean + @FeatureToggle public boolean highlightBlazes = false; @Expose @ConfigOption(name = "Hide Particles", desc = "Hide particles around the Ashfang boss.") @ConfigEditorBoolean + @FeatureToggle public boolean hideParticles = false; @Expose @ConfigOption(name = "Hide Names", desc = "Hide the names of full health blazes around Ashfang (only useful when highlight blazes is enabled)") @ConfigEditorBoolean + @FeatureToggle public boolean hideNames = false; @Expose @ConfigOption(name = "Hide Damage", desc = "Hide damage splashes around Ashfang.") @ConfigEditorBoolean + @FeatureToggle public boolean hideDamageSplash = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/BazaarConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/BazaarConfig.java index 8f12ba667..8d3565765 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/BazaarConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/BazaarConfig.java @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.config.features; +import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; @@ -10,16 +11,19 @@ public class BazaarConfig { @Expose @ConfigOption(name = "Purchase Helper", desc = "Highlights the item you are trying to buy in the Bazaar.") @ConfigEditorBoolean + @FeatureToggle public boolean purchaseHelper = true; @Expose @ConfigOption(name = "Order Helper", desc = "Show visual hints inside the Bazaar Manage Order view when items are ready to pickup or outbid.") @ConfigEditorBoolean + @FeatureToggle public boolean orderHelper = false; @Expose @ConfigOption(name = "Best Sell Method", desc = "Show the price difference between sell instantly and sell offer.") @ConfigEditorBoolean + @FeatureToggle public boolean bestSellMethod = false; @Expose @@ -28,5 +32,6 @@ public class BazaarConfig { @Expose @ConfigOption(name = "Cancelled Buy Order Clipboard", desc = "Saves missing items from cancelled buy orders to clipboard for faster re-entry.") @ConfigEditorBoolean + @FeatureToggle public boolean cancelledBuyOrderClipboard = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/BingoConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/BingoConfig.java index e083fbcbe..4be6eeb41 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/BingoConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/BingoConfig.java @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.config.features; +import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.Accordion; @@ -18,6 +19,7 @@ public class BingoConfig { @Expose @ConfigOption(name = "Enable", desc = "Displays the bingo card.") @ConfigEditorBoolean + @FeatureToggle public boolean enabled = true; @Expose @ConfigOption(name = "Quick Toggle", desc = "Quickly toggle the bingo card or the step helper by sneaking with SkyBlock menu in hand.") @@ -42,6 +44,7 @@ public class BingoConfig { "§eData from Bingo Splash Community§7, made by §cMayxo" ) @ConfigEditorBoolean + @FeatureToggle public boolean bingoSplashGuide = true; @Expose @@ -59,11 +62,13 @@ public class BingoConfig { @ConfigOption(name = "Enable", desc = "Shortens chat messages about skill level ups, collection gains, " + "new area discoveries and skyblock level up messages while on bingo.") @ConfigEditorBoolean + @FeatureToggle public boolean enabled = true; @Expose @ConfigOption(name = "Hide Border", desc = "Hide the border messages before and after the compact level up messages.") @ConfigEditorBoolean + @FeatureToggle public boolean hideBorder = true; @Expose @@ -75,6 +80,7 @@ public class BingoConfig { @Expose @ConfigOption(name = "Minion Craft Helper", desc = "Show how many more items you need to upgrade the minion in your inventory. Especially useful for bingo.") @ConfigEditorBoolean + @FeatureToggle public boolean minionCraftHelperEnabled = true; @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java index ee46054f6..425cd9d07 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.config.features; +import at.hannibal2.skyhanni.config.FeatureToggle; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.*; import org.lwjgl.input.Keyboard; @@ -21,36 +22,49 @@ public class ChatConfig { @ConfigOption(name = "Hypixel Hub", desc = "Block messages outside SkyBlock in the Hypixel lobby: player joins, loot boxes, prototype lobby messages, radiating generosity and Hypixel tournaments.") @ConfigEditorBoolean @ConfigAccordionId(id = 0) + @FeatureToggle public boolean hypixelHub = true; @Expose @ConfigOption(name = "Empty", desc = "Hide all the empty messages from the chat.") @ConfigEditorBoolean @ConfigAccordionId(id = 0) + @FeatureToggle public boolean empty = true; @Expose @ConfigOption(name = "Warping", desc = "Block 'sending request to join...' and 'warping...' messages.") @ConfigEditorBoolean @ConfigAccordionId(id = 0) + @FeatureToggle public boolean warping = true; @Expose @ConfigOption(name = "Welcome", desc = "Hide the 'welcome to SkyBlock' message.") @ConfigEditorBoolean @ConfigAccordionId(id = 0) + @FeatureToggle public boolean welcome = true; @Expose @ConfigOption(name = "Guild Exp", desc = "Hide guild exp messages.") @ConfigEditorBoolean @ConfigAccordionId(id = 0) + @FeatureToggle public boolean guildExp = true; + @Expose + @ConfigOption(name = "Friend Join Left", desc = "Hide friend join/left messages.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + @FeatureToggle + public boolean friendJoinLeft = false; + @Expose @ConfigOption(name = "Winter Gifts", desc = "Hide useless winter gift messages.") @ConfigEditorBoolean @ConfigAccordionId(id = 0) + @FeatureToggle public boolean winterGift = false; @Expose @@ -58,24 +72,28 @@ public class ChatConfig { "(Except powder numbers over 1k, Prehistoric Egg and Automaton Parts)") @ConfigEditorBoolean @ConfigAccordionId(id = 0) + @FeatureToggle public boolean powderMining = true; @Expose @ConfigOption(name = "Kill Combo", desc = "Hide messages about the current kill combo from the Grandma Wolf Pet.") @ConfigEditorBoolean @ConfigAccordionId(id = 0) + @FeatureToggle public boolean killCombo = false; @Expose @ConfigOption(name = "Watchdog", desc = "Hide the message where Hypixel is flexing how many players they have banned over the last week.") @ConfigEditorBoolean @ConfigAccordionId(id = 0) + @FeatureToggle public boolean watchDog = true; @Expose @ConfigOption(name = "Profile Join", desc = "Hide 'You are playing on profile' and 'Profile ID' chat messages") @ConfigEditorBoolean @ConfigAccordionId(id = 0) + @FeatureToggle public boolean profileJoin = true; //TODO remove @@ -83,6 +101,7