From 4559e5ff05e19817a21ae49f1c0d8a97d273f6a1 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Sat, 10 Feb 2024 00:24:52 +0100 Subject: Splitting many utils functions from LorenzUtils up into other classes: ChatUtils, CollectionUtils, ConditionalUtils. And code cleanup #978 --- .../skyhanni/features/misc/BetterSignEditing.kt | 1 + .../skyhanni/features/misc/ButtonOnPause.kt | 3 ++- .../skyhanni/features/misc/CollectionTracker.kt | 17 ++++++------- .../skyhanni/features/misc/CurrentPetDisplay.kt | 1 + .../skyhanni/features/misc/CustomTextBox.kt | 5 ++-- .../skyhanni/features/misc/FandomWikiFromMenus.kt | 0 .../skyhanni/features/misc/FixNEUHeavyPearls.kt | 5 ++-- .../hannibal2/skyhanni/features/misc/HideArmor.kt | 1 + .../skyhanni/features/misc/InGameDateDisplay.kt | 5 ++-- .../skyhanni/features/misc/JoinCrystalHollows.kt | 9 +++---- .../skyhanni/features/misc/LesserOrbHider.kt | 4 +++- .../skyhanni/features/misc/LimboTimeTracker.kt | 14 ++++++----- .../skyhanni/features/misc/LockMouseLook.kt | 9 +++---- .../skyhanni/features/misc/MarkedPlayerManager.kt | 12 +++++----- .../skyhanni/features/misc/MovementSpeedDisplay.kt | 1 + .../features/misc/NonGodPotEffectDisplay.kt | 11 +++++---- .../skyhanni/features/misc/ParticleHider.kt | 4 +--- .../skyhanni/features/misc/PartyMemberOutlines.kt | 3 ++- .../skyhanni/features/misc/PetExpTooltip.kt | 3 ++- .../skyhanni/features/misc/PlayerChatSymbols.kt | 1 + .../skyhanni/features/misc/QuickModMenuSwitch.kt | 12 ++++++---- .../skyhanni/features/misc/ServerRestartTitle.kt | 1 + .../skyhanni/features/misc/SkyBlockKickDuration.kt | 1 + .../features/misc/SuperpairsClicksAlert.kt | 5 ++-- .../skyhanni/features/misc/TimeFeatures.kt | 1 + .../hannibal2/skyhanni/features/misc/TpsCounter.kt | 2 ++ .../misc/compacttablist/AdvancedPlayerList.kt | 6 +++-- .../features/misc/compacttablist/TabColumn.kt | 4 ++-- .../features/misc/compacttablist/TabListReader.kt | 1 + .../misc/compacttablist/TabListRenderer.kt | 4 ++-- .../features/misc/compacttablist/TabSection.kt | 3 ++- .../features/misc/compacttablist/TabStringType.kt | 3 ++- .../features/misc/discordrpc/DiscordRPCManager.kt | 28 +++++++++++++++------- .../features/misc/discordrpc/DiscordStatus.kt | 1 - .../misc/items/AuctionHouseCopyUnderbidPrice.kt | 4 +++- .../features/misc/items/EstimatedItemValue.kt | 12 ++++++---- .../misc/items/EstimatedItemValueCalculator.kt | 8 +++---- .../features/misc/items/EstimatedWardrobePrice.kt | 1 + .../massconfiguration/DefaultConfigFeatures.kt | 19 ++++++++------- .../massconfiguration/DefaultConfigOptionGui.kt | 6 ++--- .../massconfiguration/FeatureToggleableOption.kt | 4 ++-- .../misc/teleportpad/TeleportPadCompactName.kt | 3 ++- .../misc/teleportpad/TeleportPadInventoryNumber.kt | 1 + .../features/misc/trevor/TrevorFeatures.kt | 1 + .../skyhanni/features/misc/trevor/TrevorSolver.kt | 1 + .../skyhanni/features/misc/trevor/TrevorTracker.kt | 5 ++-- .../misc/update/GuiOptionEditorUpdateCheck.kt | 1 + .../skyhanni/features/misc/update/UpdateManager.kt | 8 +++---- .../features/misc/visualwords/ModifyVisualWords.kt | 1 + .../features/misc/visualwords/VisualWord.kt | 5 ++-- .../features/misc/visualwords/VisualWordGui.kt | 5 ++-- 51 files changed, 161 insertions(+), 105 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/FandomWikiFromMenus.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/BetterSignEditing.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/BetterSignEditing.kt index 1fffb43eb..eb482e0c2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/BetterSignEditing.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/BetterSignEditing.kt @@ -16,6 +16,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.input.Keyboard class BetterSignEditing { + private var pasteLastClicked = false private var copyLastClicked = false private var deleteWordLastClicked = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt index 0547a4537..536c6d520 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt @@ -10,6 +10,7 @@ import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class ButtonOnPause { + private val config get() = SkyHanniMod.feature.gui private val buttonId = System.nanoTime().toInt() @@ -50,4 +51,4 @@ class ButtonOnPause { fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(2, "misc.configButtonOnPause", "gui.configButtonOnPause") } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt index e05571b6a..6e8f746f2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.CollectionAPI import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -39,32 +40,32 @@ class CollectionTracker { fun command(args: Array) { if (args.isEmpty()) { if (internalName == null) { - LorenzUtils.userError("/shtrackcollection ") + ChatUtils.userError("/shtrackcollection ") return } - LorenzUtils.chat("Stopped collection tracker.") + ChatUtils.chat("Stopped collection tracker.") resetData() return } val rawName = fixTypo(args.joinToString(" ").lowercase().replace("_", " ")) if (rawName == "gemstone") { - LorenzUtils.userError("Gemstone collection is not supported!") + ChatUtils.userError("Gemstone collection is not supported!") return } else if (rawName == "mushroom") { - LorenzUtils.userError("Mushroom collection is not supported!") + ChatUtils.userError("Mushroom collection is not supported!") return } val foundInternalName = NEUItems.getInternalNameOrNullIgnoreCase(rawName) if (foundInternalName == null) { - LorenzUtils.error("Item '$rawName' does not exist!") + ChatUtils.error("Item '$rawName' does not exist!") return } val stack = foundInternalName.getItemStackOrNull() if (stack == null) { - LorenzUtils.error("Item '$rawName' does not exist!") + ChatUtils.error("Item '$rawName' does not exist!") return } setNewCollection(foundInternalName, stack.name!!.removeColor()) @@ -97,7 +98,7 @@ class CollectionTracker { private fun setNewCollection(internalName: NEUInternalName, name: String) { val foundAmount = CollectionAPI.getCollectionCounter(internalName) if (foundAmount == null) { - LorenzUtils.userError("$name collection not found. Try to open the collection inventory!") + ChatUtils.userError("$name collection not found. Try to open the collection inventory!") return } this.internalName = internalName @@ -106,7 +107,7 @@ class CollectionTracker { lastAmountInInventory = countCurrentlyInInventory() updateDisplay() - LorenzUtils.chat("Started tracking $itemName §ecollection.") + ChatUtils.chat("Started tracking $itemName §ecollection.") } private fun resetData() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt index ebff243f9..866242368 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt @@ -15,6 +15,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.matches import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class CurrentPetDisplay { + private val config get() = SkyHanniMod.feature.misc.pets // TODO USE SH-REPO diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt index 40b6abed1..ffe6a79ae 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt @@ -4,12 +4,13 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.utils.ConditionalUtils.afterChange import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.afterChange import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class CustomTextBox { + private val config get() = SkyHanniMod.feature.gui.customTextBox private var display = listOf() @@ -36,4 +37,4 @@ class CustomTextBox { fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(2, "misc.textBox", "gui.customTextBox") } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FandomWikiFromMenus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FandomWikiFromMenus.kt new file mode 100644 index 000000000..e69de29bb diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FixNEUHeavyPearls.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FixNEUHeavyPearls.kt index b5ce08ba7..da2d89243 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FixNEUHeavyPearls.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FixNEUHeavyPearls.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.ItemAddEvent +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import io.github.moulberry.notenoughupdates.NotEnoughUpdates @@ -9,6 +10,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.hours class FixNEUHeavyPearls { + private val config get() = SkyHanniMod.feature.misc private val heavyPearl = "HEAVY_PEARL".asInternalName() @@ -19,12 +21,11 @@ class FixNEUHeavyPearls { if (event.internalName == heavyPearl && event.amount == 3) { val specific = NotEnoughUpdates.INSTANCE.config.getProfileSpecific() if (System.currentTimeMillis() > specific.dailyHeavyPearlCompleted + 1.hours.inWholeMilliseconds) { - LorenzUtils.chat("Mark NEU Heavy Pearls as done.") + ChatUtils.chat("Mark NEU Heavy Pearls as done.") specific.dailyHeavyPearlCompleted = System.currentTimeMillis() } } } fun isEnabled() = LorenzUtils.inSkyBlock && config.fixNeuHeavyPearls - } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt index c4a5be8ed..d8409416b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt @@ -17,6 +17,7 @@ import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class HideArmor { + private val config get() = SkyHanniMod.feature.misc.hideArmor2 private var armor = mapOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt index 0d87bb767..ff4f4facf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ScoreboardData +import at.hannibal2.skyhanni.data.jsonobjects.repo.TabListJson import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent @@ -10,11 +11,11 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TimeUtils.formatted -import at.hannibal2.skyhanni.data.jsonobjects.repo.TabListJson import io.github.moulberry.notenoughupdates.util.SkyBlockTime import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class InGameDateDisplay { + private val config get() = SkyHanniMod.feature.gui.inGameDate private val monthAndDatePattern = ".*((Early|Late) )?(Winter|Spring|Summer|Autumn) [0-9]{1,2}(nd|rd|th|st)?.*".toPattern() @@ -41,7 +42,7 @@ class InGameDateDisplay { val date = SkyBlockTime.now() var theBaseString: String if (config.useScoreboard) { - val list = ScoreboardData.sidebarLinesFormatted //we need this to grab the moon/sun symbol + val list = ScoreboardData.sidebarLinesFormatted // we need this to grab the moon/sun symbol val year = "Year ${date.year}" var monthAndDate = (list.find { monthAndDatePattern.matches(it) } ?: "??").trim() if (monthAndDate.last().isDigit()) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt index 4064ed341..4ee986dbf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec @@ -24,13 +25,13 @@ class JoinCrystalHollows { if (message == "§cYou do not have an active Crystal Hollows pass!") { lastWrongPassTime = System.currentTimeMillis() if (LorenzUtils.skyBlockIsland != IslandType.DWARVEN_MINES) { - LorenzUtils.clickableChat("Click here to warp to Dwarven Mines!", "warp mines") + ChatUtils.clickableChat("Click here to warp to Dwarven Mines!", "warp mines") } else { - LorenzUtils.chat("Buy a §2Crystal Hollows Pass §efrom §5Gwendolyn") + ChatUtils.chat("Buy a §2Crystal Hollows Pass §efrom §5Gwendolyn") } } if (message == "§e[NPC] §5Gwendolyn§f: §rGreat! Now hop on into the Minecart and I'll get you on your way!" && inTime()) { - LorenzUtils.clickableChat("Click here to warp to Crystal Hollows!", "warp ch") + ChatUtils.clickableChat("Click here to warp to Crystal Hollows!", "warp ch") } } @@ -39,7 +40,7 @@ class JoinCrystalHollows { if (!isEnabled()) return if (event.newIsland == IslandType.DWARVEN_MINES && inTime()) { - LorenzUtils.chat("Buy a §2Crystal Hollows Pass §efrom §5Gwendolyn§e!") + ChatUtils.chat("Buy a §2Crystal Hollows Pass §efrom §5Gwendolyn§e!") } if (event.newIsland == IslandType.CRYSTAL_HOLLOWS) { lastWrongPassTime = 0 diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt index 000587afd..fb0eb95db 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.EntityEquipmentChangeEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.utils.CollectionUtils import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo import at.hannibal2.skyhanni.utils.LorenzUtils @@ -12,8 +13,9 @@ import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class LesserOrbHider { + private val config get() = SkyHanniMod.feature.misc - private val hiddenEntities = LorenzUtils.weakReferenceList() + private val hiddenEntities = CollectionUtils.weakReferenceList() private val lesserTexture = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjgzMjM2NjM5NjA3MDM2YzFiYTM5MWMyYjQ2YTljN2IwZWZkNzYwYzhiZmEyOTk2YTYwNTU1ODJiNGRhNSJ9fX0=" diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/LimboTimeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/LimboTimeTracker.kt index 4e733fa24..fbddd5fb0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/LimboTimeTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/LimboTimeTracker.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.RenderUtils.renderString @@ -16,6 +17,7 @@ import kotlin.time.Duration.Companion.seconds import kotlin.time.DurationUnit class LimboTimeTracker { + private val config get() = SkyHanniMod.feature.misc private var limboJoinTime = SimpleTimeMark.farPast() @@ -36,8 +38,8 @@ class LimboTimeTracker { if (inLimbo && !shownPB && limboJoinTime.passedSince() >= config.limboTimePB.seconds && config.limboTimePB != 0) { shownPB = true oldPB = config.limboTimePB.seconds - LorenzUtils.chat("§d§lPERSONAL BEST§f! You've surpassed your previous record of §e$oldPB§f!") - LorenzUtils.chat("§fKeep it up!") + ChatUtils.chat("§d§lPERSONAL BEST§f! You've surpassed your previous record of §e$oldPB§f!") + ChatUtils.chat("§fKeep it up!") } } @@ -71,11 +73,11 @@ class LimboTimeTracker { if (passedSince > currentPB) { oldPB = currentPB config.limboTimePB = passedSince.toInt(DurationUnit.SECONDS) - LorenzUtils.chat("§fYou were AFK in Limbo for §e$duration§f! §d§lPERSONAL BEST§r§f!") - LorenzUtils.chat("§fYour previous Personal Best was §e$oldPB.") + ChatUtils.chat("§fYou were AFK in Limbo for §e$duration§f! §d§lPERSONAL BEST§r§f!") + ChatUtils.chat("§fYour previous Personal Best was §e$oldPB.") val userLuck = config.limboTimePB * userLuckMultiplier - LorenzUtils.chat("§fYour §aPersonal Bests§f perk is now granting you §a+${userLuck.round(2)}✴ SkyHanni User Luck§f!") - } else LorenzUtils.chat("§fYou were AFK in Limbo for §e$duration§f.") + ChatUtils.chat("§fYour §aPersonal Bests§f perk is now granting you §a+${userLuck.round(2)}✴ SkyHanni User Luck§f!") + } else ChatUtils.chat("§fYou were AFK in Limbo for §e$duration§f.") shownPB = false } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt index be4bb05f3..d0c30af92 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt @@ -3,12 +3,13 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object LockMouseLook { + private val config get() = SkyHanniMod.feature.misc private var lockedMouse = false private const val lockedPosition = -1F / 3F @@ -19,7 +20,7 @@ object LockMouseLook { val gameSettings = Minecraft.getMinecraft().gameSettings if (gameSettings.mouseSensitivity == lockedPosition) { gameSettings.mouseSensitivity = SkyHanniMod.feature.storage.savedMouselockedSensitivity - LorenzUtils.chat("§bMouse rotation is now unlocked because you left it locked.") + ChatUtils.chat("§bMouse rotation is now unlocked because you left it locked.") } } @@ -31,12 +32,12 @@ object LockMouseLook { SkyHanniMod.feature.storage.savedMouselockedSensitivity = gameSettings.mouseSensitivity gameSettings.mouseSensitivity = lockedPosition if (config.lockMouseLookChatMessage) { - LorenzUtils.chat("§bMouse rotation is now locked. Type /shmouselock to unlock your rotation") + ChatUtils.chat("§bMouse rotation is now locked. Type /shmouselock to unlock your rotation") } } else { gameSettings.mouseSensitivity = SkyHanniMod.feature.storage.savedMouselockedSensitivity if (config.lockMouseLookChatMessage) { - LorenzUtils.chat("§bMouse rotation is now unlocked.") + ChatUtils.chat("§bMouse rotation is now unlocked.") } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt index 0ce1a8fd8..ee8f2c37c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.RenderMobColoredEvent import at.hannibal2.skyhanni.events.ResetEntityHurtEvent import at.hannibal2.skyhanni.events.withAlpha +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.client.Minecraft @@ -18,12 +19,13 @@ class MarkedPlayerManager { private val config get() = SkyHanniMod.feature.markedPlayers companion object { + val playerNamesToMark = mutableListOf() private val markedPlayers = mutableMapOf() fun command(args: Array) { if (args.size != 1) { - LorenzUtils.userError("Usage: /shmarkplayer ") + ChatUtils.userError("Usage: /shmarkplayer ") return } @@ -32,18 +34,18 @@ class MarkedPlayerManager { if (name == LorenzUtils.getPlayerName().lowercase()) { - LorenzUtils.userError("You can't add or remove yourself this way! Go to the settings and toggle 'Mark your own name'.") + ChatUtils.userError("You can't add or remove yourself this way! Go to the settings and toggle 'Mark your own name'.") return } if (name !in playerNamesToMark) { playerNamesToMark.add(name) findPlayers() - LorenzUtils.chat("§aMarked §eplayer §b$displayName§e!") + ChatUtils.chat("§aMarked §eplayer §b$displayName§e!") } else { playerNamesToMark.remove(name) markedPlayers.remove(name) - LorenzUtils.chat("§cUnmarked §eplayer §b$displayName§e!") + ChatUtils.chat("§cUnmarked §eplayer §b$displayName§e!") } } @@ -59,10 +61,8 @@ class MarkedPlayerManager { } fun isMarkedPlayer(player: String): Boolean = player.lowercase() in playerNamesToMark - } - @SubscribeEvent fun onConfigLoad(event: ConfigLoadEvent) { config.markOwnName.whenChanged { _, new -> diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt index cf50b53f4..dbf76a3dc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt @@ -11,6 +11,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.concurrent.fixedRateTimer class MovementSpeedDisplay { + private val config get() = SkyHanniMod.feature.misc private var display = "" 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 befa84037..5ee6103a2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt @@ -12,10 +12,11 @@ import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.PreProfileSwitchEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.CollectionUtils.sorted import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.sorted import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.TimeUnit @@ -31,6 +32,7 @@ import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds class NonGodPotEffectDisplay { + private val config get() = SkyHanniMod.feature.misc.potionEffect private var checkFooter = false private val effectDuration = mutableMapOf() @@ -40,8 +42,9 @@ class NonGodPotEffectDisplay { enum class NonGodPotEffect( val tabListName: String, val isMixin: Boolean = false, - val inventoryItemName: String = tabListName + val inventoryItemName: String = tabListName, ) { + SMOLDERING("§aSmoldering Polarization I"), GLOWY("§2Mushed Glowy Tonic I"), WISP("§bWisp's Ice-Flavored Water I"), @@ -131,7 +134,7 @@ class NonGodPotEffectDisplay { private fun update() { if (effectDuration.values.removeIf { it.ended }) { - //to fetch the real amount of active pots + // to fetch the real amount of active pots totalEffectsCount = 0 checkFooter = true } @@ -230,7 +233,7 @@ class NonGodPotEffectDisplay { effectDuration[effect] = Timer(duration.milliseconds) update() } catch (e: IndexOutOfBoundsException) { - LorenzUtils.debug("Error while reading non god pot effects from tab list! line: '$line'") + ChatUtils.debug("Error while reading non god pot effects from tab list! line: '$line'") } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt index aebfbdac3..43bd181dd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt @@ -49,7 +49,5 @@ class ParticleHider { event.move(3, "misc.hideCloseRedstoneparticles", "misc.particleHiders.hideCloseRedstoneParticles") event.move(3, "misc.hideFireBlockParticles", "misc.particleHiders.hideFireBlockParticles") event.move(3, "misc.hideSmokeParticles", "misc.particleHiders.hideSmokeParticles") - } - -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PartyMemberOutlines.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PartyMemberOutlines.kt index c2ac7490b..6de5b8cf7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PartyMemberOutlines.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PartyMemberOutlines.kt @@ -10,6 +10,7 @@ import net.minecraft.entity.Entity import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class PartyMemberOutlines { + private val config get() = SkyHanniMod.feature.misc.highlightPartyMembers @SubscribeEvent @@ -26,4 +27,4 @@ class PartyMemberOutlines { return SpecialColour.specialToChromaRGB(config.outlineColor) } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt index cfb679c30..e5611fb90 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt @@ -9,10 +9,10 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.KeyboardManager import at.hannibal2.skyhanni.utils.LorenzRarity import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.makeAccessible import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.ReflectionUtils.makeAccessible import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetExp import at.hannibal2.skyhanni.utils.StringUtils import io.github.moulberry.notenoughupdates.NotEnoughUpdates @@ -21,6 +21,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class PetExpTooltip { + private val config get() = SkyHanniMod.feature.misc.pets.petExperienceToolTip private val level100Common = 5_624_785 private val level100Legendary = 25_353_230 diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PlayerChatSymbols.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PlayerChatSymbols.kt index 231eeb3c3..79cc77234 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PlayerChatSymbols.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PlayerChatSymbols.kt @@ -19,6 +19,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent // code inspired by SBA but heavily modified to be more functional and actually work class PlayerChatSymbols { + private val config get() = SkyHanniMod.feature.chat.chatSymbols private val nameSymbols = mutableMapOf() private val symbolsPattern = "^(?(?:(?:§\\w)+\\S)+) ".toPattern() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt index fceb8563e..f1fb205e5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt @@ -2,13 +2,14 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.data.jsonobjects.repo.ModGuiSwitcherJson import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.makeAccessible +import at.hannibal2.skyhanni.utils.ReflectionUtils.makeAccessible import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems -import at.hannibal2.skyhanni.data.jsonobjects.repo.ModGuiSwitcherJson import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraft.client.Minecraft import net.minecraft.client.renderer.GlStateManager @@ -17,6 +18,7 @@ import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object QuickModMenuSwitch { + private val config get() = SkyHanniMod.feature.misc.quickModMenuSwitch private var display = emptyList>() private var latestGuiPath = "" @@ -64,7 +66,7 @@ object QuickModMenuSwitch { latestGuiPath = openGui if (SkyHanniMod.feature.dev.debug.modMenuLog) { - LorenzUtils.debug("Open GUI: $latestGuiPath") + ChatUtils.debug("Open GUI: $latestGuiPath") } } val mods = mods ?: return @@ -152,7 +154,7 @@ object QuickModMenuSwitch { } catch (_: Exception) { } } - LorenzUtils.error("Error trying to open the gui for mod " + mod.name + "!") + ChatUtils.error("Error trying to open the gui for mod " + mod.name + "!") } "hytil" -> { @@ -168,7 +170,7 @@ object QuickModMenuSwitch { } catch (_: Exception) { } } - LorenzUtils.chat("Error trying to open the gui for mod " + mod.name + "!") + ChatUtils.chat("Error trying to open the gui for mod " + mod.name + "!") } else -> { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt index 950ed60f3..fb228418e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt @@ -10,6 +10,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds class ServerRestartTitle { + private val config get() = SkyHanniMod.feature.misc // TODO USE SH-REPO diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt index 72c1009e9..9eca3a159 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt @@ -14,6 +14,7 @@ import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds class SkyBlockKickDuration { + private val config get() = SkyHanniMod.feature.misc.kickDuration private var kickMessage = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/SuperpairsClicksAlert.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/SuperpairsClicksAlert.kt index e2519fd72..231bbaf3d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/SuperpairsClicksAlert.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/SuperpairsClicksAlert.kt @@ -3,13 +3,14 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.InventoryUpdatedEvent +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class SuperpairsClicksAlert { + private val config get() = SkyHanniMod.feature.misc private var roundsNeeded = -1 @@ -54,7 +55,7 @@ class SuperpairsClicksAlert { .any { it.value.stackSize > roundsNeeded }) ) { SoundUtils.playBeepSound() - LorenzUtils.chat("You have reached the maximum possible clicks!") + ChatUtils.chat("You have reached the maximum possible clicks!") roundsNeeded = -1 } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt index 797ae5c93..9c71d3153 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt @@ -18,6 +18,7 @@ import kotlin.time.Duration.Companion.days import kotlin.time.Duration.Companion.seconds class TimeFeatures { + private val config get() = SkyHanniMod.feature.gui private val winterConfig get() = SkyHanniMod.feature.event.winter diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt index 8cf4f8044..7e70c1c06 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt @@ -13,9 +13,11 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.concurrent.fixedRateTimer class TpsCounter { + private val config get() = SkyHanniMod.feature.gui companion object { + private const val minDataAmount = 5 private const val waitAfterWorldSwitch = 6 } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt index b5684265f..b28f74e52 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.bingo.BingoAPI import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils @@ -24,6 +25,7 @@ import kotlin.random.Random import kotlin.time.Duration.Companion.minutes object AdvancedPlayerList { + private val config get() = SkyHanniMod.feature.misc.compactTabList.advancedPlayerList // TODO USE SH-REPO @@ -97,10 +99,9 @@ object AdvancedPlayerList { } else { playerData.nameSuffix = "" } - } catch (e: NumberFormatException) { val message = "Special user (youtube or admin?): '$line'" - LorenzUtils.debug(message) + ChatUtils.debug(message) println(message) } } @@ -231,6 +232,7 @@ object AdvancedPlayerList { } class PlayerData(val sbLevel: Int) { + var name: String = "?" var coloredName: String = "?" var nameSuffix: String = "?" diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabColumn.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabColumn.kt index d1e930a09..17a35ae7d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabColumn.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabColumn.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.features.misc.compacttablist - class TabColumn(val columnTitle: String) { + val lines = mutableListOf() val sections = mutableListOf() @@ -14,4 +14,4 @@ class TabColumn(val columnTitle: String) { } fun size() = lines.size + 1 -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt index a81205ce7..cb0d3c6c8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt @@ -12,6 +12,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent // heavily inspired by SBA code object TabListReader { + private val config get() = SkyHanniMod.feature.misc.compactTabList // TODO USE SH-REPO diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt index b42378e08..76200f835 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt @@ -3,8 +3,8 @@ package at.hannibal2.skyhanni.features.misc.compacttablist import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.SkipTabListLineEvent import at.hannibal2.skyhanni.mixins.transformers.AccessorGuiPlayerTabOverlay +import at.hannibal2.skyhanni.utils.CollectionUtils.filterToMutable import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.filterToMutable import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.Minecraft @@ -16,6 +16,7 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object TabListRenderer { + private val config get() = SkyHanniMod.feature.misc.compactTabList const val maxLines = 22 @@ -182,5 +183,4 @@ object TabListRenderer { event.cancel() } } - } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabSection.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabSection.kt index 9754235fb..c0f36dfc9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabSection.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabSection.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.misc.compacttablist class TabSection(val columnValue: TabColumn) { + val lines = mutableListOf() fun addLine(line: String) { @@ -8,4 +9,4 @@ class TabSection(val columnValue: TabColumn) { } fun size() = lines.size -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabStringType.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabStringType.kt index 74eea4ff3..159214b0e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabStringType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabStringType.kt @@ -9,6 +9,7 @@ enum class TabStringType { PLAYER; companion object { + // TODO USE SH-REPO private val usernamePattern = "^\\[(?\\d+)] (?:\\[\\w+] )?(?\\w+)".toPattern() @@ -29,4 +30,4 @@ enum class TabStringType { return if (usernameMatcher.find()) usernameMatcher.group("username") else input } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt index deba594e7..5110c3752 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt @@ -13,9 +13,10 @@ import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.onToggle import at.hannibal2.skyhanni.utils.SimpleTimeMark import com.google.gson.JsonObject import com.jagrosh.discordipc.IPCClient @@ -31,6 +32,7 @@ import java.util.concurrent.ScheduledExecutorService import java.util.concurrent.TimeUnit object DiscordRPCManager : IPCListener { + private const val applicationID = 1093298182735282176L private const val updatePeriod = 4200L @@ -63,13 +65,18 @@ object DiscordRPCManager : IPCListener { try { client?.connect() - if (fromCommand) LorenzUtils.chat("Successfully started Rich Presence!", prefixColor = "§a") // confirm that /shrpcstart worked + if (fromCommand) ChatUtils.chat( + "Successfully started Rich Presence!", + prefixColor = "§a" + ) // confirm that /shrpcstart worked } catch (ex: Exception) { consoleLog("Warn: Failed to connect to RPC!") consoleLog(ex.toString()) - LorenzUtils.clickableChat("Discord Rich Presence was unable to start! " + + ChatUtils.clickableChat( + "Discord Rich Presence was unable to start! " + "This usually happens when you join SkyBlock when Discord is not started. " + - "Please run /shrpcstart to retry once you have launched Discord.", "shrpcstart") + "Please run /shrpcstart to retry once you have launched Discord.", "shrpcstart" + ) } } catch (ex: Throwable) { consoleLog("Warn: Discord RPC has thrown an unexpected error while trying to start...") @@ -92,9 +99,11 @@ object DiscordRPCManager : IPCListener { @SubscribeEvent fun onConfigLoad(event: ConfigLoadEvent) { - onToggle(config.firstLine, + ConditionalUtils.onToggle( + config.firstLine, config.secondLine, - config.customText) { + config.customText + ) { if (isActive()) { updatePresence() } @@ -107,6 +116,7 @@ object DiscordRPCManager : IPCListener { } } } + fun updatePresence() { val location = DiscordStatus.LOCATION.getDisplayString() val discordIconKey = DiscordLocationKey.getDiscordIconKey(location) @@ -188,16 +198,16 @@ object DiscordRPCManager : IPCListener { fun startCommand() { if (!config.enabled.get()) { - LorenzUtils.userError("Discord Rich Presence is disabled. Enable it in the config §e/sh discord") + ChatUtils.userError("Discord Rich Presence is disabled. Enable it in the config §e/sh discord") return } if (isActive()) { - LorenzUtils.userError("Discord Rich Presence is already active!") + ChatUtils.userError("Discord Rich Presence is already active!") return } - LorenzUtils.chat("Attempting to start Discord Rich Presence...") + ChatUtils.chat("Attempting to start Discord Rich Presence...") try { start(true) } catch (e: Exception) { 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 4c972750d..af307e32f 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 @@ -385,7 +385,6 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier?) } return "" } - } enum class AutoStatus(val placeholderText: String, val correspondingDiscordStatus: DiscordStatus) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt index 23e5d4754..6ebcf08c0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc.items import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.InventoryUpdatedEvent +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName @@ -11,6 +12,7 @@ import at.hannibal2.skyhanni.utils.OSUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class AuctionHouseCopyUnderbidPrice { + private val config get() = SkyHanniMod.feature.inventory @SubscribeEvent @@ -30,7 +32,7 @@ class AuctionHouseCopyUnderbidPrice { } val newPrice = price * item.stackSize - 1 OSUtils.copyToClipboard("$newPrice") - LorenzUtils.chat("Set §e${newPrice.addSeparators()} §eto clipboard. (Copy Underbid Price)") + ChatUtils.chat("Set §e${newPrice.addSeparators()} §eto clipboard. (Copy Underbid Price)") } fun isEnabled() = LorenzUtils.inSkyBlock && config.copyUnderbidPrice diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt index 527dfe4fe..aef1f392b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt @@ -8,6 +8,9 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.RenderItemTooltipEvent +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -15,8 +18,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.isRune import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList -import at.hannibal2.skyhanni.utils.LorenzUtils.onToggle import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull import at.hannibal2.skyhanni.utils.NEUItems.manager @@ -34,6 +35,7 @@ import java.io.File import kotlin.math.roundToLong object EstimatedItemValue { + private val config get() = SkyHanniMod.feature.misc.estimatedItemValues private var display = emptyList>() private val cache = mutableMapOf>>() @@ -55,7 +57,7 @@ object EstimatedItemValue { object : TypeToken>>>() {}.type ) else - LorenzUtils.error("Gemstone Slot Unlock Costs failed to load!") + ChatUtils.error("Gemstone Slot Unlock Costs failed to load!") } @SubscribeEvent @@ -151,7 +153,7 @@ object EstimatedItemValue { val newDisplay = try { draw(item) } catch (e: Exception) { - LorenzUtils.debug("Estimated Item Value error: ${e.message}") + ChatUtils.debug("Estimated Item Value error: ${e.message}") e.printStackTrace() listOf() } @@ -189,7 +191,7 @@ object EstimatedItemValue { if (internalName.getItemStackOrNull() == null) { - LorenzUtils.debug("Estimated Item Value is null for: '$internalName'") + ChatUtils.debug("Estimated Item Value is null for: '$internalName'") return listOf() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt index df915988d..d0c0d74f2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc.items import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getItemName import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull @@ -10,7 +11,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.isRune import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment import at.hannibal2.skyhanni.utils.LorenzRarity -import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems @@ -55,6 +55,7 @@ import net.minecraft.item.ItemStack import java.util.Locale object EstimatedItemValueCalculator { + private val config get() = SkyHanniMod.feature.misc.estimatedItemValues private val additionalCostFunctions = listOf( ::addAttributeCost, @@ -190,7 +191,7 @@ object EstimatedItemValueCalculator { private fun getReforgeStoneApplyCost( stack: ItemStack, reforgeCosts: JsonObject, - reforgeStone: NEUInternalName + reforgeStone: NEUInternalName, ): Int? { var itemRarity = stack.getItemRarityOrNull() ?: return null @@ -448,7 +449,7 @@ object EstimatedItemValueCalculator { internalName: NEUInternalName, list: MutableList, label: String, - shouldIgnorePrice: Boolean + shouldIgnorePrice: Boolean, ): Double { val price = internalName.getPrice() val name = internalName.getNameOrRepoError() @@ -573,7 +574,6 @@ object EstimatedItemValueCalculator { 5 -> multiplier = 16 } level = 1 - } if (internalName.startsWith("ENCHANTED_BOOK_BUNDLE_")) { multiplier = 5 diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt index 3969372ff..3076ba439 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt @@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class EstimatedWardrobePrice { + private val config get() = SkyHanniMod.feature.misc.estimatedItemValues var data = mutableMapOf>() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt index 1f153ed69..0d504e459 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt @@ -3,13 +3,14 @@ package at.hannibal2.skyhanni.features.misc.massconfiguration import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.ChatUtils import io.github.moulberry.moulconfig.processor.ConfigProcessorDriver import net.minecraft.client.Minecraft import net.minecraft.command.CommandBase import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object DefaultConfigFeatures { + private var didNotifyOnce = false @SubscribeEvent @@ -32,7 +33,7 @@ object DefaultConfigFeatures { SkyHanniMod.configManager.saveConfig(ConfigFileType.KNOWN_FEATURES, "Updated known feature flags") if (!SkyHanniMod.feature.storage.hasPlayedBefore) { SkyHanniMod.feature.storage.hasPlayedBefore = true - LorenzUtils.clickableChat( + ChatUtils.clickableChat( "Looks like this is the first time you are using SkyHanni. " + "Click here to configure default options, or run /shdefaultoptions.", "shdefaultoptions" @@ -40,9 +41,9 @@ object DefaultConfigFeatures { } else if (updated) { val lastVersion = knownToggles.keys.last { it != SkyHanniMod.version } val command = "/shdefaultoptions $lastVersion ${SkyHanniMod.version}" - LorenzUtils.clickableChat( + ChatUtils.clickableChat( "Looks like you updated SkyHanni. " + - "Click here to configure the newly introduced options, or run $command.", + "Click here to configure the newly introduced options, or run $command.", command ) } @@ -55,24 +56,24 @@ object DefaultConfigFeatures { val knownToggles = SkyHanniMod.knownFeaturesData.knownFeatures val togglesInNewVersion = knownToggles[new] if (new != "null" && togglesInNewVersion == null) { - LorenzUtils.chat("Unknown version $new") + ChatUtils.chat("Unknown version $new") return } val togglesInOldVersion = knownToggles[old] if (old != "null" && togglesInOldVersion == null) { - LorenzUtils.chat("Unknown version $old") + ChatUtils.chat("Unknown version $old") return } optionList = optionList .mapValues { it -> it.value.filter { (togglesInNewVersion == null || it.path in togglesInNewVersion) && - (togglesInOldVersion == null || it.path !in togglesInOldVersion) + (togglesInOldVersion == null || it.path !in togglesInOldVersion) } } .filter { (_, filteredOptions) -> filteredOptions.isNotEmpty() } if (optionList.isEmpty()) { - LorenzUtils.chat("There are no new options to configure between $old and $new") + ChatUtils.chat("There are no new options to configure between $old and $new") return } SkyHanniMod.screenToOpen = DefaultConfigOptionGui(optionList, old, new) @@ -80,7 +81,7 @@ object DefaultConfigFeatures { fun applyCategorySelections( resetSuggestionState: MutableMap, - orderedOptions: Map> + orderedOptions: Map>, ) { orderedOptions.forEach { (cat, options) -> for (option in options) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigOptionGui.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigOptionGui.kt index ac1a497fe..d878d9665 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigOptionGui.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigOptionGui.kt @@ -14,9 +14,10 @@ import kotlin.math.min class DefaultConfigOptionGui( private val orderedOptions: Map>, old: String, - new: String + new: String, ) : GuiScreen() { + val title = if (old == "null") { if (new == "null") "§5SkyHanni Default Options" @@ -181,7 +182,6 @@ class DefaultConfigOptionGui( if (hoveringTextToDraw != null) { Utils.drawHoveringText(hoveringTextToDraw, mouseX, mouseY, width, height, 100, mc.fontRendererObj) } - } private fun scroll(s: Int) { @@ -194,4 +194,4 @@ class DefaultConfigOptionGui( if (Mouse.getEventDWheel() != 0) scroll(currentScrollOffset - Mouse.getEventDWheel()) } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/FeatureToggleableOption.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/FeatureToggleableOption.kt index 88b9f1a8e..b9d4b96f9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/FeatureToggleableOption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/FeatureToggleableOption.kt @@ -5,5 +5,5 @@ data class FeatureToggleableOption( val isTrueEnabled: Boolean, val category: Category, val setter: (Boolean) -> Unit, val path: String, - var toggleOverride: ResetSuggestionState? = null -) \ No newline at end of file + var toggleOverride: ResetSuggestionState? = null, +) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt index 73c2e3398..777244d6e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt @@ -11,6 +11,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class TeleportPadCompactName { + // TODO USE SH-REPO private val patternName = "§.✦ §aWarp To (?.*)".toPattern() private val patternNoName = "§.✦ §cNo Destination".toPattern() @@ -32,4 +33,4 @@ class TeleportPadCompactName { entity.customNameTag = group("name") } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadInventoryNumber.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadInventoryNumber.kt index 7916fe6cb..4530f0406 100644 --- a/src/main/java/at/hannibal