diff options
| author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-02-10 00:24:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-10 00:24:52 +0100 |
| commit | 4559e5ff05e19817a21ae49f1c0d8a97d273f6a1 (patch) | |
| tree | e72dac91d07fc84bea80548c89e13276caa68b81 /src/main/java/at/hannibal2/skyhanni/features/misc | |
| parent | d3a7cc4ab970b457b7950489da781539e45e0dce (diff) | |
| download | skyhanni-4559e5ff05e19817a21ae49f1c0d8a97d273f6a1.tar.gz skyhanni-4559e5ff05e19817a21ae49f1c0d8a97d273f6a1.tar.bz2 skyhanni-4559e5ff05e19817a21ae49f1c0d8a97d273f6a1.zip | |
Splitting many utils functions from LorenzUtils up into other classes: ChatUtils, CollectionUtils, ConditionalUtils. And code cleanup #978
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
51 files changed, 161 insertions, 105 deletions
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<String>) { if (args.isEmpty()) { if (internalName == null) { - LorenzUtils.userError("/shtrackcollection <item name>") + ChatUtils.userError("/shtrackcollection <item name>") 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<String>() @@ -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 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FandomWikiFromMenus.kt 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<Int, ItemStack>() 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<EntityArmorStand>() + private val hiddenEntities = CollectionUtils.weakReferenceList<EntityArmorStand>() 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 locke |
