From 93fd9ece889b68349bb3b2bdfc6943e5c356424d Mon Sep 17 00:00:00 2001 From: NetheriteMiner <88792142+NetheriteMiner@users.noreply.github.com> Date: Mon, 19 Jun 2023 15:20:02 -0400 Subject: Fix coins displaying null in RPC (#246) --- .../at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt index 20f203bb7..d114913bb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt @@ -108,7 +108,7 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier?) } if (coins == "1") { lastKnownDisplayStrings[PURSE] = "1 Coin" - } else if (coins != "") { + } else if (coins != "" && coins != null) { lastKnownDisplayStrings[PURSE] = "$coins Coins" } lastKnownDisplayStrings[PURSE] ?: "" -- cgit From 9594c23b95f795b25adc8be415ed38f1f46634fb Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 19 Jun 2023 21:20:18 +0200 Subject: addSeparators --- .../hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt index c04d662e2..9faa3511b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt @@ -196,7 +196,7 @@ object SlayerItemProfitTracker { val renderable = if (inventoryOpen) Renderable.clickAndHover( text, listOf( - "§7Dropped §e$timesDropped §7times.", + "§7Dropped §e${timesDropped.addSeparators()} §7times.", "§7Your drop rate: §c$perBoss", "", "§eClick to " + (if (hidden) "show" else "hide") + "!", @@ -250,8 +250,8 @@ object SlayerItemProfitTracker { val slayerCompletedCount = itemLog.slayerCompletedCount addAsSingletonList( Renderable.hoverTips( - "§7Bosses killed: §e$slayerCompletedCount", - listOf("§7You killed the $itemLogCategory boss", "§e$slayerCompletedCount §7times.") + "§7Bosses killed: §e${slayerCompletedCount.addSeparators()}", + listOf("§7You killed the $itemLogCategory boss", "§e${slayerCompletedCount.addSeparators()} §7times.") ) ) -- cgit From 5b4611388c69fd9b2425334578ef51220a994dce Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 19 Jun 2023 22:28:48 +0200 Subject: Version 0.18 --- CHANGELOG.md | 2 +- build.gradle.kts | 2 +- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/main') diff --git a/CHANGELOG.md b/CHANGELOG.md index fd07d3685..7549bc4f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # SkyHanni - Change Log -## Version 0.18.BETA +## Version 0.18 (2023-06-19) ### New Features + Added **Visitor Drop Counter** (Contributed by CalMWolfs) diff --git a/build.gradle.kts b/build.gradle.kts index 36ac1ea6f..19b85e44d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ plugins { } group = "at.hannibal2.skyhanni" -version = "0.18.Beta.21" +version = "0.18" // Toolchains: java { diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 51d695899..73d136618 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -94,7 +94,7 @@ import org.apache.logging.log4j.Logger clientSideOnly = true, useMetadata = true, guiFactory = "at.hannibal2.skyhanni.config.ConfigGuiForgeInterop", - version = "0.18.Beta.21", + version = "0.18", ) class SkyHanniMod { @Mod.EventHandler -- cgit From 49914e950130c69c655f2506f8f070b93b0dc599 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 19 Jun 2023 23:12:18 +0200 Subject: Give specific credits to Mayxo --- src/main/java/at/hannibal2/skyhanni/config/features/Bingo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Bingo.java b/src/main/java/at/hannibal2/skyhanni/config/features/Bingo.java index 53ebf93e1..b9270b03c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Bingo.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Bingo.java @@ -35,7 +35,7 @@ public class Bingo { @ConfigOption( name = "Show Guide", desc = "Show tips and difficulty for bingo goals inside the bingo card inventory.\n" + - "§7(§eData from Bingo Splash Community§7)" + "§eData from Bingo Splash Community§7, made by §cMayxo" ) @ConfigEditorBoolean public boolean bingoSplashGuide = true; -- cgit From 3e7aa9855489888283b6c53ce14002fe38d04dbe Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 22 Jun 2023 13:00:47 +0200 Subject: better error handling --- .../hannibal2/skyhanni/config/commands/Commands.kt | 8 +-- .../skyhanni/config/commands/SimpleCommand.java | 9 ++- .../hannibal2/skyhanni/data/EntityMovementData.kt | 2 - .../at/hannibal2/skyhanni/data/MayorElection.kt | 9 +-- .../at/hannibal2/skyhanni/data/repo/RepoManager.kt | 5 +- .../at/hannibal2/skyhanni/data/repo/RepoUtils.kt | 18 +++--- .../skyhanni/events/RepositoryReloadEvent.kt | 7 ++- .../skyhanni/test/command/CopyErrorCommand.kt | 73 +++++++++++++++++++--- 8 files changed, 94 insertions(+), 37 deletions(-) (limited to 'src/main') 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 ebcb72d28..59b850784 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -125,9 +125,9 @@ object Commands { } private fun createCommand(function: (Array) -> Unit) = - object : ProcessCommandRunnable() { - override fun processCommand(sender: ICommandSender?, args: Array) { - function(args.asList().toTypedArray()) - } + object : ProcessCommandRunnable() { + override fun processCommand(sender: ICommandSender?, args: Array) { + function(args.asList().toTypedArray()) } + } } \ No newline at end of file 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 25e3ba97b..fa2c310de 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.java +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.java @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.config.commands; +import at.hannibal2.skyhanni.test.command.CopyErrorCommand; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; import net.minecraft.util.BlockPos; @@ -7,7 +8,7 @@ import net.minecraft.util.BlockPos; import java.util.List; /** - @author Moulberry + * @author Moulberry **/ public class SimpleCommand extends CommandBase { @@ -50,7 +51,11 @@ public class SimpleCommand extends CommandBase { @Override public void processCommand(ICommandSender sender, String[] args) { - runnable.processCommand(sender, args); + try { + runnable.processCommand(sender, args); + } catch (Throwable e) { + CopyErrorCommand.INSTANCE.logError(e, "Error while running command /" + commandName); + } } @Override diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt index 30f88f48e..b5a2d2b92 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt @@ -21,8 +21,6 @@ class EntityMovementData { } } - var tick = 0 - @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { if (!LorenzUtils.inSkyBlock) return diff --git a/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt b/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt index ddd208db1..7c4cfd7c1 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt @@ -1,11 +1,10 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.utils.APIUtil import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.jsonobjects.MayorJson -import com.google.gson.GsonBuilder -import io.github.moulberry.moulconfig.observer.PropertyTypeAdapterFactory import io.github.moulberry.notenoughupdates.util.SkyBlockTime import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -17,10 +16,6 @@ class MayorElection { private var tick = 0 private var lastUpdate = 0L - private val gson = GsonBuilder().setPrettyPrinting() - .registerTypeAdapterFactory(PropertyTypeAdapterFactory()) - .create() - companion object { var rawMayorData: MayorJson? = null var candidates = mapOf() @@ -52,7 +47,7 @@ class MayorElection { SkyHanniMod.coroutineScope.launch { val url = "https://api.hypixel.net/resources/skyblock/election" val jsonObject = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) } - rawMayorData = gson.fromJson(jsonObject, MayorJson::class.java) + rawMayorData = ConfigManager.gson.fromJson(jsonObject, MayorJson::class.java) val data = rawMayorData ?: return@launch val map = mutableMapOf() map put data.mayor.election.getPairs() diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt index 2dc65f358..e1d6aa933 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt @@ -1,10 +1,9 @@ package at.hannibal2.skyhanni.data.repo import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.utils.LorenzUtils -import com.google.gson.Gson -import com.google.gson.GsonBuilder import com.google.gson.JsonObject import net.minecraft.client.Minecraft import org.apache.commons.io.FileUtils @@ -15,7 +14,7 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.atomic.AtomicBoolean class RepoManager(private val configLocation: File) { - val gson: Gson = GsonBuilder().setPrettyPrinting().create() + private val gson get() = ConfigManager.gson private var latestRepoCommit: String? = null private val repoLocation: File = File(configLocation, "repo") diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt index 3e67adcac..9719c70ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt @@ -79,17 +79,13 @@ object RepoUtils { fun getConstant(repo: File, constant: String, gson: Gson, clazz: Class?): T? { if (repo.exists()) { val jsonFile = File(repo, "constants/$constant.json") - try { - BufferedReader( - InputStreamReader( - FileInputStream(jsonFile), - StandardCharsets.UTF_8 - ) - ).use { reader -> - return gson.fromJson(reader, clazz) - } - } catch (e: Exception) { - return null + BufferedReader( + InputStreamReader( + FileInputStream(jsonFile), + StandardCharsets.UTF_8 + ) + ).use { reader -> + return gson.fromJson(reader, clazz) } } return null diff --git a/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt index 5cfd59aa1..39d187326 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.events import at.hannibal2.skyhanni.data.repo.RepoUtils +import at.hannibal2.skyhanni.test.command.CopyErrorCommand import com.google.gson.Gson import com.google.gson.JsonObject import java.io.File @@ -8,6 +9,10 @@ import java.io.File class RepositoryReloadEvent(val repoLocation: File, val gson: Gson): LorenzEvent() { fun getConstant(constant: String) = getConstant(constant) - inline fun getConstant(constant: String) = + inline fun getConstant(constant: String) = try { RepoUtils.getConstant(repoLocation, constant, gson, T::class.java) + } catch (e: Exception) { + CopyErrorCommand.logError(Exception("Repo parsing error while trying to read constant '$constant'", e), "Error reading repo data") + null + } } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt index a8c6660f3..575a2e4fe 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt @@ -4,12 +4,14 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.OSUtils import com.google.common.cache.CacheBuilder +import net.minecraft.client.Minecraft import java.util.* import java.util.concurrent.TimeUnit object CopyErrorCommand { // random id -> error message private val errorMessages = mutableMapOf() + private val fullErrorMessages = mutableMapOf() private var cache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build, Unit>() @@ -20,22 +22,34 @@ object CopyErrorCommand { return } - LorenzUtils.chat(errorMessages[array[0]]?.let { + val id = array[0] + val fullErrorMessage = LorenzUtils.isControlKeyDown() + val errorMessage = if (fullErrorMessage) { + fullErrorMessages[id] + } else { + errorMessages[id] + } + val name = if (fullErrorMessage) "Ful error" else "Error" + LorenzUtils.chat(errorMessage?.let { OSUtils.copyToClipboard(it) - "§e[SkyHanni] Error copied into the clipboard, please report it on the SkyHanni discord!" + "§e[SkyHanni] $name copied into the clipboard, please report it on the SkyHanni discord!" } ?: "§c[SkyHanni] Error id not found!") } fun logError(error: Throwable, message: String) { + Minecraft.getMinecraft().thePlayer ?: throw Error(message, error) + val pair = error.stackTrace[0].let { it.fileName to it.lineNumber } - if (cache.getIfPresent(pair) != null) return +// if (cache.getIfPresent(pair) != null) return cache.put(pair, Unit) - val stackTrace = error.stackTraceToString().removeSpam() + val fullStackTrace = error.getExactStackTrace(true).joinToString("\n") + val stackTrace = error.getExactStackTrace(false).joinToString("\n").removeSpam() val randomId = UUID.randomUUID().toString() - errorMessages[randomId] = - "```\nSkyHanni ${SkyHanniMod.version}: $message\n \n$stackTrace```" + errorMessages[randomId] = "```\nSkyHanni ${SkyHanniMod.version}: $message\n \n$stackTrace\n```" + fullErrorMessages[randomId] = + "```\nSkyHanni ${SkyHanniMod.version}: $message\n(full stack trace)\n \n$fullStackTrace\n```" LorenzUtils.clickableChat( "§c[SkyHanni ${SkyHanniMod.version}]: $message. Click here to copy the error into the clipboard.", @@ -44,12 +58,57 @@ object CopyErrorCommand { } } +private fun Throwable.getExactStackTrace(full: Boolean, parent: List = emptyList()): List = buildList { + add("Caused by " + javaClass.name + ": $message") + + val breakAfter = listOf( + "at net.minecraftforge.client.ClientCommandHandler.executeCommand(", + ) + val replace = mapOf( + "io.mouberry,notenoughupdates" to "NEU", + "at.hannibal2.skyhanni" to "SH", + ) + + for (traceElement in stackTrace) { + var text = "\tat $traceElement" + if (!full) { + if (text in parent) { + println("broke at: $text") + break + } + } + if (!full) { + for ((from, to) in replace) { + text = text.replace(from, to) + } + } + add(text) + if (!full) { + if (breakAfter.any { text.contains(it) }) { + println("breakAfter: $text") + break + } + } + } + + cause?.let { + addAll(it.getExactStackTrace(full, this)) + } +} + private fun String.removeSpam(): String { val ignored = listOf( "at io.netty.", "at net.minecraft.network.", "at net.minecraftforge.fml.common.network.handshake.", "at java.lang.Thread.run", + "at com.google.gson.internal.", + "at net.minecraftforge.fml.common.eventhandler.", + "at java.util.concurrent.", + "at sun.reflect.", + "at net.minecraft.client.Minecraft.addScheduledTask(", + "at java.lang.reflect.", + "at at.hannibal2.skyhanni.config.commands.Commands\$", ) - return split("\r\n\t").filter { line -> !ignored.any { line.startsWith(it) } }.joinToString("\n") + return split("\n").filter { line -> !ignored.any { line.contains(it) } }.joinToString("\n") } -- cgit From 13c636ff4ad49403c078b208dabd0b87972b0440 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 22 Jun 2023 14:23:26 +0200 Subject: Added rift timer --- CHANGELOG.md | 6 ++ FEATURES.md | 4 + src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../at/hannibal2/skyhanni/config/Features.java | 4 + .../skyhanni/config/features/RiftConfig.java | 37 ++++++++ .../java/at/hannibal2/skyhanni/data/IslandType.kt | 1 + .../hannibal2/skyhanni/features/rift/RiftTimer.kt | 99 ++++++++++++++++++++++ .../at/hannibal2/skyhanni/utils/LorenzUtils.kt | 9 ++ 8 files changed, 162 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt (limited to 'src/main') diff --git a/CHANGELOG.md b/CHANGELOG.md index 7549bc4f4..9c884a6f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # SkyHanni - Change Log +## Version 0.19 (unreleased) + +### New Features ++ Added **Rift Timer** + + Show the remaining rift time, max time, percentage, and extra time changes. + ## Version 0.18 (2023-06-19) ### New Features diff --git a/FEATURES.md b/FEATURES.md index 917f1c057..6d71d09e0 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -270,6 +270,10 @@ + Show a warning when finding a **visitor with a rare reward** + Show message in chat, over the visitor and prevents refusing +## The Rift ++ **Rift Timer** + + Show the remaining rift time, max time, percentage, and extra time changes. + ## Commands + **/wiki ** - using hypixel-skyblock.fandom.com instead of Hypixel wiki. + **/shmarkplayer ** - marking a player with yellow color. diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 73d136618..cf099e987 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -59,6 +59,7 @@ import at.hannibal2.skyhanni.features.mobs.AshfangMinisNametagHider import at.hannibal2.skyhanni.features.mobs.MobHighlight import at.hannibal2.skyhanni.features.nether.ashfang.* import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper +import at.hannibal2.skyhanni.features.rift.RiftTimer import at.hannibal2.skyhanni.features.slayer.* import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerClearView import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerDaggerHelper @@ -300,6 +301,7 @@ class SkyHanniMod { loadModule(ShowItemUuid()) loadModule(SlayerRngMeterDisplay()) loadModule(GhostCounter) + loadModule(RiftTimer()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index d80195e71..a5a42b48c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -119,6 +119,10 @@ public class Features extends Config { @Category(name = "Ghost Counter", desc = "Ghost Counter settings.") public GhostCounter ghostCounter = new GhostCounter(); + @Expose + @Category(name = "The Rift", desc = "Features for The Rift dimension.") + public RiftConfig rift = new RiftConfig(); + @Expose @Category(name = "Misc", desc = "Settings without a category.") public Misc misc = new Misc(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java new file mode 100644 index 000000000..581413ec0 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java @@ -0,0 +1,37 @@ +package at.hannibal2.skyhanni.config.features; + +import at.hannibal2.skyhanni.config.core.config.Position; +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.Accordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigOption; + +public class RiftConfig { + + @ConfigOption(name = "Rift Timer", desc = "") + @Accordion + @Expose + public TimerConfig timer = new TimerConfig(); + + public static class TimerConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Show the remaining rift time, max time, percentage, and extra time changes.") + @ConfigEditorBoolean + public boolean enabled = true; + + @Expose + @ConfigOption(name = "Max time", desc = "Show max time.") + @ConfigEditorBoolean + public boolean maxTime = true; + + @Expose + @ConfigOption(name = "Percentage", desc = "Show percentage.") + @ConfigEditorBoolean + public boolean percentage = true; + + @Expose + public Position timerPosition = new Position(10, 10, false, true); + + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt index 8b9c4dc3e..d3357e880 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt @@ -18,6 +18,7 @@ enum class IslandType(val displayName: String, val apiName: String = "null") { GARDEN("Garden"), GARDEN_GUEST("Garden Guest"), SPIDER_DEN("Spider's Den"), + THE_RIFT("The Rift"), NONE(""), UNKNOWN("???"), diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt new file mode 100644 index 000000000..d1fcc758d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt @@ -0,0 +1,99 @@ +package at.hannibal2.skyhanni.features.rift + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzActionBarEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.TimeUtils +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class RiftTimer { + private val config get() = SkyHanniMod.feature.rift.timer + private var display = listOf() + private var maxTime = 0L + private var latestTime = 0L + private val changes = mutableMapOf() + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + display = emptyList() + } + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + if (!isEnabled()) return + + val message = event.message + " §r§7You have §r§a(?