From 4f116e2c8b5e5f28054a73e2e89dbb6746f4f597 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 17 Nov 2023 23:48:45 +0100 Subject: code cleanup --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 4 ++-- src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt | 11 +++++------ .../java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index c6cc6ef71..bb9855949 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -250,7 +250,6 @@ import at.hannibal2.skyhanni.features.nether.ashfang.AshfangHideParticles import at.hannibal2.skyhanni.features.nether.ashfang.AshfangNextResetCooldown import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper import at.hannibal2.skyhanni.features.rift.RiftAPI -import at.hannibal2.skyhanni.features.rift.area.wyldwoods.RiftLarva import at.hannibal2.skyhanni.features.rift.area.colosseum.BlobbercystsHighlight import at.hannibal2.skyhanni.features.rift.area.dreadfarm.RiftAgaricusCap import at.hannibal2.skyhanni.features.rift.area.dreadfarm.RiftWiltedBerberisHelper @@ -264,6 +263,7 @@ import at.hannibal2.skyhanni.features.rift.area.mirrorverse.RiftUpsideDownParkou import at.hannibal2.skyhanni.features.rift.area.mirrorverse.TubulatorParkour import at.hannibal2.skyhanni.features.rift.area.stillgorechateau.RiftBloodEffigies import at.hannibal2.skyhanni.features.rift.area.westvillage.KloonHacking +import at.hannibal2.skyhanni.features.rift.area.wyldwoods.RiftLarva import at.hannibal2.skyhanni.features.rift.area.wyldwoods.RiftOdonata import at.hannibal2.skyhanni.features.rift.area.wyldwoods.ShyCruxWarnings import at.hannibal2.skyhanni.features.rift.everywhere.CruxTalismanDisplay @@ -705,7 +705,7 @@ class SkyHanniMod { } val modules: MutableList = ArrayList() - val globalJob: Job = Job(null) + private val globalJob: Job = Job(null) val coroutineScope = CoroutineScope( CoroutineName("SkyHanni") + SupervisorJob(globalJob) ) diff --git a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt index 224522c06..0f44a9107 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt @@ -21,14 +21,13 @@ object FriendAPI { private val addedFriendPattern = "§aYou are now friends with (?.*)".toPattern() private val noBestFriendPattern = ".*\n§r(?.*)§e is no longer a best friend!§r§9§m\n.*".toPattern() private val bestFriendPattern = ".*\n(?.*)§a is now a best friend!§r§9§m\n.*".toPattern() + private val readFriendListPattern = "/viewprofile (?.*)".toPattern() private val tempFriends = mutableListOf() - private fun getFriends(): MutableMap { - return SkyHanniMod.friendsData.players.getOrPut(LorenzUtils.getRawPlayerUuid()) { - FriendsJson.PlayerFriends().also { it.friends = mutableMapOf() } - }.friends - } + private fun getFriends() = SkyHanniMod.friendsData.players.getOrPut(LorenzUtils.getRawPlayerUuid()) { + FriendsJson.PlayerFriends().also { it.friends = mutableMapOf() } + }.friends @SubscribeEvent fun onHypixelJoin(event: HypixelJoinEvent) { @@ -97,7 +96,7 @@ object FriendAPI { val value = chatStyle.chatClickEvent?.value ?: continue if (!value.startsWith("/viewprofile")) continue - val uuid = "/viewprofile (?.*)".toPattern().matchMatcher(value) { + val uuid = readFriendListPattern.matchMatcher(value) { group("uuid")?.let { try { UUID.fromString(it) diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt index d88f9b67a..c7461dc24 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -149,7 +149,7 @@ class SkyHanniDebugsAndTests { // saving old config state SkyHanniMod.configManager.saveConfig(ConfigFileType.FEATURES, "reload config manager") - SkyHanniMod.configManager.saveConfig(ConfigFileType.SACKS,"reload config manager") + SkyHanniMod.configManager.saveConfig(ConfigFileType.SACKS, "reload config manager") Thread { Thread.sleep(500) SkyHanniMod.configManager.disableSaving() -- cgit