diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
21 files changed, 423 insertions, 235 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt index 021e59b91..79202ffa2 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt @@ -104,9 +104,9 @@ class CropAccessoryData { val pagesLoaded get() = accessoryPage.size var cropAccessory: CropAccessory? - get() = GardenAPI.config?.savedCropAccessory + get() = GardenAPI.storage?.savedCropAccessory private set(accessory) { - GardenAPI.config?.savedCropAccessory = accessory + GardenAPI.storage?.savedCropAccessory = accessory } // Derived partially from NotEnoughUpdates/NotEnoughUpdates, ProfileViewer.Profile#getInventoryInfo diff --git a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt index bca06d18c..f6c9b4e56 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.data -import at.hannibal2.skyhanni.config.ConfigManager +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.events.HypixelJoinEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.test.command.ErrorManager @@ -11,56 +12,40 @@ import at.hannibal2.skyhanni.utils.jsonobjects.FriendsJson import at.hannibal2.skyhanni.utils.jsonobjects.FriendsJson.PlayerFriends.Friend import net.minecraft.util.ChatStyle import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.io.File -import java.io.FileReader import java.util.UUID -class FriendAPI { - private val file = File("config/skyhanni/friends.json") - +object FriendAPI { // TODO USE SH-REPO private val removedFriendPattern = ".*\n§r§eYou removed §r(?<name>.*)§e from your friends list!§r§9§m\n.*".toPattern() private val addedFriendPattern = "§aYou are now friends with (?<name>.*)".toPattern() private val noBestFriendPattern = ".*\n§r(?<name>.*)§e is no longer a best friend!§r§9§m\n.*".toPattern() private val bestFriendPattern = ".*\n(?<name>.*)§a is now a best friend!§r§9§m\n.*".toPattern() + private val readFriendListPattern = "/viewprofile (?<uuid>.*)".toPattern() - companion object { - - private var friendsJson: FriendsJson? = null - - private fun getFriends(): MutableMap<UUID, Friend> { - val friendsJson = friendsJson ?: error("savedFriends not loaded yet!") - return friendsJson.players.getOrPut(LorenzUtils.getRawPlayerUuid()) { - FriendsJson.PlayerFriends().also { it.friends = mutableMapOf() } - }.friends - } - - private val tempFriends = mutableListOf<Friend>() + private val tempFriends = mutableListOf<Friend>() - fun getAllFriends(): List<Friend> { - val list = mutableListOf<Friend>() - list.addAll(getFriends().values) - list.addAll(tempFriends) - return list - } - } + private fun getFriends() = SkyHanniMod.friendsData.players.getOrPut(LorenzUtils.getRawPlayerUuid()) { + FriendsJson.PlayerFriends().also { it.friends = mutableMapOf() } + }.friends @SubscribeEvent fun onHypixelJoin(event: HypixelJoinEvent) { - if (file.isFile) { - friendsJson = ConfigManager.gson.fromJson(FileReader(file), FriendsJson::class.java) - } - if (friendsJson == null) { - file.parentFile.mkdirs() - file.createNewFile() - friendsJson = FriendsJson().also { it.players = mutableMapOf() } + if (SkyHanniMod.friendsData.players == null) { + SkyHanniMod.friendsData.players = mutableMapOf() saveConfig() } } + fun getAllFriends(): List<Friend> { + val list = mutableListOf<Friend>() + list.addAll(getFriends().values) + list.addAll(tempFriends) + return list + } + fun saveConfig() { - file.writeText(ConfigManager.gson.toJson(friendsJson)) + SkyHanniMod.configManager.saveConfig(ConfigFileType.FRIENDS, "Save file") } @SubscribeEvent @@ -111,12 +96,19 @@ class FriendAPI { val value = chatStyle.chatClickEvent?.value ?: continue if (!value.startsWith("/viewprofile")) continue - val uuid = "/viewprofile (?<uuid>.*)".toPattern().matchMatcher(value) { + val uuid = readFriendListPattern.matchMatcher(value) { group("uuid")?.let { try { UUID.fromString(it) } catch (e: IllegalArgumentException) { - ErrorManager.logError(e, "Error reading friend list.") + ErrorManager.logErrorWithData( + e, "Error reading friend list.", + "raw uuid" to it, + "value" to value, + "chatStyle" to chatStyle, + "event.chatComponent" to event.chatComponent, + "event.message" to event.message, + ) return } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt index 14651f900..6b6d343aa 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.composter.ComposterAPI import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class GardenComposterUpgradesData { @@ -16,15 +17,12 @@ class GardenComposterUpgradesData { if (event.inventoryName != "Composter Upgrades") return for (item in event.inventoryItems.values) { val itemName = item.name ?: continue - val matcher = ComposterUpgrade.regex.matcher(itemName) - if (!matcher.matches()) continue - - if (matcher.groupCount() != 0) { - val name = matcher.group("name") - val level = matcher.group("level")?.romanToDecimalIfNeeded() ?: 0 + ComposterUpgrade.regex.matchMatcher(itemName) { + val name = group("name") + val level = group("level")?.romanToDecimalIfNeeded() ?: 0 val composterUpgrade = ComposterUpgrade.getByName(name)!! ComposterAPI.composterUpgrades?.put(composterUpgrade, level) } } } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt index ecbaee591..610393906 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.jsonobjects.GardenJson import net.minecraft.item.ItemStack @@ -14,7 +15,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object GardenCropMilestones { // TODO USE SH-REPO private val cropPattern = "§7Harvest §f(?<name>.*) §7on .*".toPattern() - private val totalPattern = "§7Total: §a(?<name>.*)".toPattern() + val totalPattern = "§7Total: §a(?<name>.*)".toPattern() fun getCropTypeByLore(itemStack: ItemStack): CropType? { for (line in itemStack.getLore()) { @@ -34,17 +35,18 @@ object GardenCropMilestones { val crop = getCropTypeByLore(stack) ?: continue for (line in stack.getLore()) { totalPattern.matchMatcher(line) { - val amount = group("name").replace(",", "").toLong() + val amount = group("name").formatNumber() crop.setCounter(amount) } } } CropMilestoneUpdateEvent().postAndCatch() + GardenCropMilestonesCommunityFix.openInventory(event.inventoryItems) } - private var cropMilestoneData: Map<CropType, List<Int>> = emptyMap() + var cropMilestoneData: Map<CropType, List<Int>> = emptyMap() - val cropCounter: MutableMap<CropType, Long>? get() = GardenAPI.config?.cropCounter + val cropCounter: MutableMap<CropType, Long>? get() = GardenAPI.storage?.cropCounter // TODO make nullable fun CropType.getCounter() = cropCounter?.get(this) ?: 0 @@ -54,6 +56,7 @@ object GardenCropMilestones { } fun CropType.isMaxed(): Boolean { + // TODO change 1b val maxValue = cropMilestoneData[this]?.sum() ?: 1_000_000_000 // 1 bil for now return getCounter() >= maxValue } diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt new file mode 100644 index 000000000..f9990685d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt @@ -0,0 +1,177 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigManager +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.features.garden.CropType +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.editCopy +import at.hannibal2.skyhanni.utils.LorenzUtils.nextAfter +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber +import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded +import at.hannibal2.skyhanni.utils.OSUtils +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.jsonobjects.GardenJson +import kotlinx.coroutines.launch +import net.minecraft.item.ItemStack +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object GardenCropMilestonesCommunityFix { + private val pattern = ".*§e(?<having>.*)§6/§e(?<max>.*)".toPattern() + private var showWrongData = false + private var showWhenAllCorrect = false + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + val data = event.getConstant<GardenJson>("Garden") + val map = data.crop_milestone_community_help ?: return + for ((key, value) in map) { + if (key == "show_wrong_data") { + showWrongData = value + } + if (key == "show_when_all_correct") { + showWhenAllCorrect = value + } + } + } + + fun openInventory(inventoryItems: Map<Int, ItemStack>) { + if (!showWrongData) return + if (!SkyHanniMod.feature.garden.copyMilestoneData) return + fixForWrongData(inventoryItems) + } + + private fun fixForWrongData(inventoryItems: Map<Int, ItemStack>) { + val data = mutableListOf<String>() + for ((_, stack) in inventoryItems) { + val crop = GardenCropMilestones.getCropTypeByLore(stack) ?: continue + checkForWrongData(stack, crop, data) + } + + if (data.isNotEmpty()) { + LorenzUtils.chat( + "Found §c${data.size} §ewrong crop milestone steps in the menu! " + + "Correct data got put into clipboard. " + + "Please share it on the §bSkyHanni Discord §ein the channel §b#share-data§e." + ) + OSUtils.copyToClipboard("```${data.joinToString("\n")}```") + } else { + if (showWhenAllCorrect) { + LorenzUtils.chat("No wrong crop milestone steps found!") + } + } + } + + private fun checkForWrongData( + stack: ItemStack, + crop: CropType, + wrongData: MutableList<String> + ) { + val name = stack.name ?: return + val rawNumber = name.removeColor().replace(crop.cropName, "").trim() + val realTier = if (rawNumber == "") 0 else rawNumber.romanToDecimalIfNeeded() + + val lore = stack.getLore() + val next = lore.nextAfter({ GardenCropMilestones.totalPattern.matches(it) }, 3) ?: return + val total = lore.nextAfter({ GardenCropMilestones.totalPattern.matches(it) }, 6) ?: return + +// debug(" ") +// debug("crop: $crop") +// debug("realTier: $realTier") + + val guessNextMax = GardenCropMilestones.getCropsForTier( + realTier + 1, + crop + ) - GardenCropMilestones.getCropsForTier(realTier, crop) +// debug("guessNextMax: ${guessNextMax.addSeparators()}") + val nextMax = pattern.matchMatcher(next) { + group("max").formatNumber() + } ?: return +// debug("nextMax real: ${nextMax.addSeparators()}") + if (nextMax != guessNextMax) { +// debug("wrong, add to list") + wrongData.add("$crop:$realTier:${nextMax.addSeparators()}") + } + + val guessTotalMax = GardenCropMilestones.getCropsForTier(46, crop) +// println("guessTotalMax: ${guessTotalMax.addSeparators()}") + val totalMax = pattern.matchMatcher(total) { + group("max").formatNumber() + } ?: return +// println("totalMax real: ${totalMax.addSeparators()}") + val totalOffBy = guessTotalMax - totalMax +// debug("$crop total offf by: ${totalOffBy.addSeparators()}") + } + +// fun debug(message: String) { +// if (SkyHanniMod.feature.dev.debug.enabled) { +// println(message) +// } +// } + + /** + * This helps to fix wrong crop milestone data + * This command reads the clipboard content, + * in the format of users sending crop milestone step data. + * + * The new data will be compared to the currently saved data, + * differences are getting replaced, and the result gets put into the clipboard. + * The clipboard context can be used to update the repo content. + */ + fun readDataFromClipboard() { + SkyHanniMod.coroutineScope.launch { + OSUtils.readFromClipboard()?.let { + handleInput(it) + } + } + } + + private var totalFixedValues = 0 + + private fun handleInput(input: String) { + println(" ") + var fixed = 0 + var alreadyCorrect = 0 + for (line in input.lines()) { + val split = line.replace("```", "").replace(".", ",").split(":") + if (split.size != 3) continue + val (rawCrop, tier, amount) = split + val crop = LorenzUtils.enumValueOf<CropType>(rawCrop) + + if (tryFix(crop, tier.toInt(), amount.formatNumber().toInt())) { + fixed++ + } else { + alreadyCorrect++ + } + } + totalFixedValues += fixed + LorenzUtils.chat("Fixed: $fixed/$alreadyCorrect, total fixes: $totalFixedValues") + val s = ConfigManager.gson.toJsonTree(GardenCropMilestones.cropMilestoneData).toString() + OSUtils.copyToClipboard("\"crop_milestones\":$s,") + } + + private fun tryFix(crop: CropType, tier: Int, amount: Int): Boolean { + val guessNextMax = GardenCropMilestones.getCropsForTier(tier + 1, crop) - GardenCropMilestones.getCropsForTier( + tier, + crop + ) + if (guessNextMax.toInt() == amount) { + return false + } + GardenCropMilestones.cropMilestoneData = GardenCropMilestones.cropMilestoneData.editCopy { + fix(crop, this, tier, amount) + } + return true + } + + private fun fix(crop: CropType, map: MutableMap<CropType, List<Int>>, tier: Int, amount: Int) { + map[crop] = map[crop]!!.editCopy { + this[tier] = amount + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt index 15a18ca26..1ea0871ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt @@ -39,7 +39,7 @@ class GardenCropUpgrades { } companion object { - private val cropUpgrades: MutableMap<CropType, Int>? get() = GardenAPI.config?.cropUpgrades + private val cropUpgrades: MutableMap<CropType, Int>? get() = GardenAPI.storage?.cropUpgrades fun CropType.getUpgradeLevel() = cropUpgrades?.get(this) diff --git a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt index 4f3110789..29a344b18 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt @@ -9,6 +9,8 @@ import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isRancherSign import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.client.gui.inventory.GuiEditSign @@ -17,8 +19,13 @@ import net.minecraft.client.renderer.GlStateManager import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.UUID +import kotlin.time.Duration.Companion.milliseconds +import kotlin.time.Duration.Companion.minutes class GuiEditManager { + + private var lastHotkeyPressed = SimpleTimeMark.farPast() + @SubscribeEvent fun onKeyClick(event: LorenzKeyPressEvent) { if (!LorenzUtils.inSkyBlock) return @@ -26,13 +33,15 @@ class GuiEditManager { if (isInGui()) return Minecraft.getMinecraft().currentScreen?.let { - if (it !is GuiInventory && it !is GuiChest && it !is GuiEditSign) return + if (it !is GuiInventory && it !is GuiChest && it !is GuiEditSign && it !is GuiProfileViewer) return if (it is GuiEditSign && !it.isRancherSign()) return } + if (lastHotkeyPressed.passedSince() < 500.milliseconds) return if (NEUItems.neuHasFocus()) return + lastHotkeyPressed = SimpleTimeMark.now() - openGuiPositionEditor() + openGuiPositionEditor(hotkeyReminder = false) } @SubscribeEvent(priority = EventPriority.LOWEST) @@ -59,9 +68,19 @@ class GuiEditManager { } } + private var lastHotkeyReminded = SimpleTimeMark.farPast() + @JvmStatic - fun openGuiPositionEditor() { + fun openGuiPositionEditor(hotkeyReminder: Boolean) { SkyHanniMod.screenToOpen = GuiPositionEditor(latestPositions.values.toList(), 2) + if (hotkeyReminder && lastHotkeyReminded.passedSince() > 30.minutes) { + lastHotkeyReminded = SimpleTimeMark.now() + LorenzUtils.chat( + "§eTo edit hidden GUI elements:\n" + + " §7- §e1. Set a key in /sh edit.\n" + + " §7- §e2. Click that key while the GUI element is visible." + ) + } } @JvmStatic @@ -95,4 +114,4 @@ class GuiEditManager { } } -class Vector2i(val x: Int, val y: Int)
\ No newline at end of file +class Vector2i(val x: Int, val y: Int) diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 31bb7c047..aa78bec09 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -7,24 +7,18 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent -import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData import net.minecraft.client.Minecraft -import net.minecraft.util.AxisAlignedBB import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.network.FMLNetworkEvent class HypixelData { // TODO USE SH-REPO private val tabListProfilePattern = "§e§lProfile: §r§a(?<profile>.*)".toPattern() - private val westVillageFarmArea = AxisAlignedBB(-54.0, 69.0, -115.0, -40.0, 75.0, -127.0) - private val howlingCaveArea = AxisAlignedBB(-401.0, 50.0, -104.0, -337.0, 90.0, 36.0) - private val fakeZealotBruiserHideoutArea = AxisAlignedBB(-520.0, 66.0, -332.0, -558.0, 85.0, -280.0) - private val realZealotBruiserHideoutArea = AxisAlignedBB(-552.0, 50.0, -245.0, -580.0, 72.0, -209.0) companion object { var hypixelLive = false @@ -85,15 +79,7 @@ class HypixelData { .firstOrNull { it.startsWith(" §7⏣ ") || it.startsWith(" §5ф ") } ?.substring(5)?.removeColor() ?: "?" - - skyBlockArea = when { - skyBlockIsland == IslandType.THE_RIFT && westVillageFarmArea.isPlayerInside() -> "Dreadfarm" - skyBlockIsland == IslandType.THE_PARK && howlingCaveArea.isPlayerInside() -> "Howling Cave" - skyBlockIsland == IslandType.THE_END && fakeZealotBruiserHideoutArea.isPlayerInside() -> "The End" - skyBlockIsland == IslandType.THE_END && realZealotBruiserHideoutArea.isPlayerInside() -> "Zealot Bruiser Hideout" - - else -> originalLocation - } + skyBlockArea = LocationFixData.fixLocation(skyBlockIsland) ?: originalLocation checkProfileName() } @@ -188,7 +174,7 @@ class HypixelData { } private fun getIslandType(newIsland: String, guesting: Boolean): IslandType { - val islandType = IslandType.getBySidebarName(newIsland) + val islandType = IslandType.getByNameOrUnknown(newIsland) if (guesting) { if (islandType == IslandType.PRIVATE_ISLAND) return IslandType.PRIVATE_ISLAND_GUEST if (islandType == IslandType.GARDEN) return IslandType.GARDEN_GUEST @@ -204,6 +190,6 @@ class HypixelData { val displayName = objective.displayName val scoreboardTitle = displayName.removeColor() return scoreboardTitle.contains("SKYBLOCK") || - scoreboardTitle.contains("SKIBLOCK") // April 1st jokes are so funny + scoreboardTitle.contains("SKIBLOCK") // April 1st jokes are so funny } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt index 15195dec4..3ab213025 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt @@ -28,8 +28,9 @@ enum class IslandType(val displayName: String, val apiName: String = "null") { ; companion object { - fun getBySidebarName(name: String): IslandType { - return entries.firstOrNull { it.displayName == name } ?: UNKNOWN - } + fun getByNameOrUnknown(name: String) = getByNameOrNull(name) ?: UNKNOWN + fun getByName(name: String) = getByNameOrNull(name) ?: error("IslandType not found: '$name'") + + fun getByNameOrNull(name: String) = entries.firstOrNull { it.displayName == name } } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt b/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt new file mode 100644 index 000000000..2bd6a9dcb --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt @@ -0,0 +1,33 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside +import at.hannibal2.skyhanni.utils.jsonobjects.LocationFixJson +import net.minecraft.util.AxisAlignedBB +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object LocationFixData { + private var locationFixes = mutableListOf<LocationFix>() + + class LocationFix(val island: IslandType, val area: AxisAlignedBB, val realLocation: String) + + // priority set to low so that IslandType can load their island names from repo earlier + @SubscribeEvent(priority = EventPriority.LOW) + fun onRepoReload(event: RepositoryReloadEvent) { + val data = event.getConstant<LocationFixJson>("LocationFix") + locationFixes.clear() + + for (fix in data.locationFixes.values) { + val island = IslandType.getByName(fix.island_name) + val area = fix.a.axisAlignedTo(fix.b) + val realLocation = fix.real_location + + locationFixes.add(LocationFix(island, area, realLocation)) + } + } + + fun fixLocation(skyBlockIsland: IslandType) = locationFixes + .firstOrNull { skyBlockIsland == it.island && it.area.isPlayerInside() } + ?.realLocation +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt index da9497d08..bfcc8df5f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt @@ -95,4 +95,4 @@ object MinecraftData { InventoryUtils.itemInHandId = NEUInternalName.NONE InventoryUtils.recentItemsInHand.clear() } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt index 7e2032077..4c6058b26 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt @@ -1,30 +1,40 @@ package at.hannibal2.skyhanni.data -import at.hannibal2.skyhanni.api.CollectionAPI import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.entity.ItemAddInInventoryEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi +import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy import at.hannibal2.skyhanni.utils.NEUItems import net.minecraft.item.ItemStack +import net.minecraft.network.play.server.S0DPacketCollectItem import net.minecraft.network.play.server.S2FPacketSetSlot import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class OwnInventoryData { +typealias SlotNumber = Int +typealias ItemName = String +typealias ItemData = Pair<ItemName, Int> - private var itemNames = mutableMapOf<Int, String>() - private var itemAmount = mutableMapOf<Int, Int>() +class OwnInventoryData { + private var items = mapOf<SlotNumber, ItemData>() + private var dirty = false @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) fun onChatPacket(event: PacketEvent.ReceiveEvent) { if (!LorenzUtils.inSkyBlock) return val packet = event.packet + if (packet is S2FPacketSetSlot || packet is S0DPacketCollectItem) { + dirty = true + } if (packet is S2FPacketSetSlot) { val windowId = packet.func_149175_c() if (windowId == 0) { @@ -32,29 +42,58 @@ class OwnInventoryData { OwnInventoryItemUpdateEvent(item).postAndCatch() } } - if (packet is S2FPacketSetSlot) { - val windowId = packet.func_149175_c() - val item = packet.func_149174_e() - val slot = packet.func_149173_d() - if (windowId != 0) return - val name = item?.name ?: "null" - - val oldItem = itemNames.getOrDefault(slot, "null") - val oldAmount = itemAmount.getOrDefault(slot, 0) - - val amount = item?.stackSize ?: 0 - if (name == oldItem) { - val diff = amount - oldAmount - if (amount > oldAmount) { - add(item, diff) - } - } else { - if (name != "null") { - add(item, amount) - } + } + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!LorenzUtils.inSkyBlock) return + if (items.isEmpty()) { + initInventory() + } + + if (!dirty) return + + dirty = false + for ((slot, itemStack) in InventoryUtils.getItemsInOwnInventoryWithNull().withIndex()) { + val old = items[slot] + val new = itemStack.itemToPair() + if (old != new) { + item(slot, new, itemStack) } - itemNames[slot] = name - itemAmount[slot] = amount + } + } + + private fun initInventory() { + items = items.editCopy { + for ((slot, itemStack) in InventoryUtils.getItemsInOwnInventoryWithNull().withIndex()) { + this[slot] = itemStack.itemToPair() + } + } + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + items = emptyMap() + } + + private fun ItemStack?.itemToPair(): ItemData = this?.let { (name ?: "null") to stackSize } ?: Pair("null", 0) + + private fun item(slot: SlotNumber, new: ItemData, itemStack: ItemStack?) { + val (oldItem, oldAmount) = items[slot] ?: Pair("null", 0) + val (name, amount) = new + + if (name == oldItem) { + val diff = amount - oldAmount + if (amount > oldAmount) { + add(itemStack, diff) + } + } else { + if (name != "null") { + add(itemStack!!, amount) + } + } + items = items.editCopy { + this[slot] = new } } @@ -66,9 +105,8 @@ class OwnInventoryData { private var lastClose = 0L - private fun add(item: ItemStack?, add: Int) { - if (item == null) return - + private fun add(item_: ItemStack?, add: Int) { + val item = item_ ?: return val diffClose = System.currentTimeMillis() - lastClose if (diffClose < 500) return @@ -92,10 +130,7 @@ class OwnInventoryData { val (_, amount) = NEUItems.getMultiplier(internalName) if (amount > 1) return - addMultiplier(internalName, add) + ItemAddInInventoryEvent(internalName, add).postAndCatch() } - private fun addMultiplier(internalName: NEUInternalName, amount: Int) { - CollectionAPI.addFromInventory(internalName, amount) - } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt index 08344c51b..90fe4783e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt @@ -8,7 +8,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.StringUtils.removeResets import at.hannibal2.skyhanni.utils.StringUtils.trimWhiteSpaceAndResets -import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.random.Random @@ -33,17 +32,17 @@ object PartyAPI { fun listMembers() { val size = partyMembers.size if (size == 0) { - LorenzUtils.chat("§e[SkyHanni] No tracked party members!") + LorenzUtils.chat("No tracked party members!") return } - LorenzUtils.chat("§a[SkyHanni] Tracked party members §7($size) §f:") + LorenzUtils.chat("Tracked party members §7($size) §f:", prefixColor = "§a") for (member in partyMembers) { - LorenzUtils.chat(" §a- §7$member") + LorenzUtils.chat(" §a- §7$member", false) } if (Random.nextDouble() < 0.1) { OSUtils.openBrowser("https://www.youtube.com/watch?v=iANP7ib7CPA") - LorenzUtils.hoverableChat("§7Are You Ready To Party?", listOf("§b~Spongebob")) + LorenzUtils.hoverableChat("§7Are You Ready To Party?", listOf("§b~Spongebob"), prefix = false) } } @@ -112,7 +111,7 @@ object PartyAPI { partyMemberListPattern.matchMatcher(message.removeColor()) { for (name in group("names").split(" ● ")) { val playerName = name.replace(" ●", "").cleanPlayerName() - if (playerName == Minecraft.getMinecraft().thePlayer.name) continue + if (playerName == LorenzUtils.getPlayerName()) continue if (!partyMembers.contains(playerName)) partyMembers.add(playerName) } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt new file mode 100644 index 000000000..9c5eac610 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt @@ -0,0 +1,11 @@ +package at.hannibal2.skyhanni.data + +object PetAPI { + + // Contains color code + name and for older SkyHanni users maybe also the pet level + var currentPet: String? + get() = ProfileStorageData.profileSpecific?.currentPet + set(value) { + ProfileStorageData.profileSpecific?.currentPet = value + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt index 63f77f2d2..8e6f9bb7d 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt @@ -12,7 +12,6 @@ import at.hannibal2.skyhanni.events.PreProfileSwitchEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -25,14 +24,15 @@ object ProfileStorageData { private var nextProfile: String? = null + // TODO USE SH-REPO + private val profileSwitchPattern = "§7Switching to profile (?<name>.*)\\.\\.\\.".toPattern() private var sackPlayers: SackData.PlayerSpecific? = null var sackProfiles: SackData.ProfileSpecific? = null @SubscribeEvent(priority = EventPriority.HIGHEST) fun onChat(event: LorenzChatEvent) { - // TODO USE SH-REPO - "§7Switching to profile (?<name>.*)\\.\\.\\.".toPattern().matchMatcher(event.message) { + profileSwitchPattern.matchMatcher(event.message) { nextProfile = group("name").lowercase() loaded = false PreProfileSwitchEvent().postAndCatch() @@ -54,7 +54,7 @@ object ProfileStorageData { LorenzUtils.error("sackPlayers after profile swap can not be set: sackPlayers is null!") return } - loadProfileSpecific(playerSpecific, sackPlayers, profileName, "profile swap (chat message)") + loadProfileSpecific(playerSpecific, sackPlayers, profileName) ConfigLoadEvent().postAndCatch() } @@ -73,7 +73,7 @@ object ProfileStorageData { if (profileSpecific == null) { val profileName = event.name - loadProfileSpecific(playerSpecific, sackPlayers, profileName, "first join (chat message)") + loadProfileSpecific(playerSpecific, sackPlayers, profileName) } } @@ -86,7 +86,7 @@ object ProfileStorageData { val pattern = "§e§lProfile: §r§a(?<name>.*)".toPattern() pattern.matchMatcher(line) { val profileName = group("name").lowercase() - loadProfileSpecific(playerSpecific, sackPlayers, profileName, "tab list") + loadProfileSpecific(playerSpecific, sackPlayers, profileName) nextProfile = null return } @@ -105,17 +105,20 @@ object ProfileStorageData { if (System.currentTimeMillis() > noTabListTime + 3_000) { noTabListTime = System.currentTimeMillis() LorenzUtils.chat( - "§c[SkyHanni] Extra Information from Tab list not found! " + - "Enable it: SkyBlock Menu ➜ Settings ➜ Personal ➜ User Interface ➜ Player List Info" + "Extra Information from Tab list not found! " + + "Enable it: SkyBlock Menu ➜ Settings ➜ Personal ➜ User Interface ➜ Player List Info" ) } } - private fun loadProfileSpecific(playerSpecific: Storage.PlayerSpecific, sackProfile: SackData.PlayerSpecific, profileName: String, reason: String) { + private fun loadProfileSpecific( + playerSpecific: Storage.PlayerSpecific, + sackProfile: SackData.PlayerSpecific, + profileName: String + ) { noTabListTime = -1 profileSpecific = playerSpecific.profiles.getOrPut(profileName) { Storage.ProfileSpecific() } sackProfiles = sackProfile.profiles.getOrPut(profileName) { SackData.ProfileSpecific() } - tryMigrateProfileSpecific() loaded = true ConfigLoadEvent().postAndCatch() } @@ -125,79 +128,6 @@ object ProfileStorageData { val playerUuid = LorenzUtils.getRawPlayerUuid() playerSpecific = SkyHanniMod.feature.storage.players.getOrPut(playerUuid) { Storage.PlayerSpecific() } sackPlayers = SkyHanniMod.sackData.players.getOrPut(playerUuid) { SackData.PlayerSpecific() } - migratePlayerSpecific() ConfigLoadEvent().postAndCatch() } - - private fun migratePlayerSpecific() { - val oldHidden = SkyHanniMod.feature.hidden - if (oldHidden.isMigrated) return - - SkyHanniMod.feature.storage?.let { - it.gardenJacobFarmingContestTimes = oldHidden.gardenJacobFarmingContestTimes - } - } - - private fun tryMigrateProfileSpecific() { - val oldHidden = SkyHanniMod.feature.hidden - if (oldHidden.isMigrated) return - - profileSpecific?.let { - it.currentPet = oldHidden.currentPet - - for ((rawLocation, minionName) in oldHidden.minionName) { - val lastClick = oldHidden.minionLastClick[rawLocation] ?: -1 - val location = LorenzVec.decodeFromString(rawLocation) - val minionConfig = Storage.ProfileSpecific.MinionConfig() - minionConfig.displayName = minionName - minionConfig.lastClicked = lastClick - it.minions[location] = minionConfig - } - } - - profileSpecific?.crimsonIsle?.let { - it.quests = oldHidden.crimsonIsleQuests - it.miniBossesDoneToday = oldHidden.crimsonIsleMiniBossesDoneToday - it.kuudraTiersDone = oldHidden.crimsonIsleKuudraTiersDone - } - - profileSpecific?.garden?.let { - it.experience = oldHidden.gardenExp.toLong() - it.cropCounter = oldHidden.gardenCropCounter - it.cropUpgrades = oldHidden.gardenCropUpgrades - - for ((crop, speed) in oldHidden.gardenCropsPerSecond) { - if (speed != -1) { - it.cropsPerSecond[crop] = speed - } - } - - it.latestBlocksPerSecond = oldHidden.gardenLatestBlocksPerSecond - it.latestTrueFarmingFortune = oldHidden.gardenLatestTrueFarmingFortune - it.savedCropAccessory = oldHidden.savedCropAccessory - it.dicerRngDrops = oldHidden.gardenDicerRngDrops - it.informedAboutLowMatter = oldHidden.informedAboutLowMatter - it.informedAboutLowFuel = oldHidden.informedAboutLowFuel - it.visitorInterval = oldHidden.visitorInterval - it.nextSixthVisitorArrival = oldHidden.nextSixthVisitorArrival - it.farmArmorDrops = oldHidden.gardenFarmingArmorDrops - it.composterUpgrades = oldHidden.gardenComposterUpgrades - it.toolWithBountiful = oldHidden.gardenToolHasBountiful - it.composterCurrentOrganicMatterItem = oldHidden.gardenComposterCurrentOrganicMatterItem - it.composterCurrentFuelItem = oldHidden.gardenComposterCurrentFuelItem - } - - profileSpecific?.garden?.visitorDrops?.let { - val old = oldHidden.visitorDrops - it.acceptedVisitors = old.acceptedVisitors - it.deniedVisitors = old.deniedVisitors - it.visitorRarities = old.visitorRarities - it.copper = old.copper - it.farmingExp = old.farmingExp - it.coinsSpent = old.coinsSpent - it.rewardsCount = old.rewardsCount - } - - oldHidden.isMigrated = true - } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt index cb3b21031..0deb53164 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PurseChangeCause import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber +import at.hannibal2.skyhanni.utils.NumberUtil.milion import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -41,12 +42,16 @@ class PurseAPI { if (diff == 1.0) { return PurseChangeCause.GAIN_TALISMAN_OF_COINS } + + if (diff == 15.milion || diff == 100.milion) { + return PurseChangeCause.GAIN_DICE_ROLL + } + if (Minecraft.getMinecraft().currentScreen == null) { val timeDiff = System.currentTimeMillis() - inventoryCloseTime if (timeDiff > 2_000) { return PurseChangeCause.GAIN_MOB_KILL } - } return PurseChangeCause.GAIN_UNKNOWN } else { @@ -55,7 +60,11 @@ class PurseAPI { return PurseChangeCause.LOSE_SLAYER_QUEST_STARTED } + if (diff == -6_666_666.0 || diff == -666_666.0) { + return PurseChangeCause.LOSE_DICE_ROLL_COST + } + return PurseChangeCause.LOSE_UNKNOWN } } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt b/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt index f109ea01b..9a57f87cc 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt @@ -48,4 +48,4 @@ class RenderData { if (!SkyHanniDebugsAndTests.globalRender) return LorenzRenderWorldEvent(event.partialTicks).postAndCatch() } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index 59d250b0a..7079ae6fd 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -21,6 +22,7 @@ import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor import com.google.gson.annotations.Expose import net.minecraft.item.ItemStack @@ -32,6 +34,7 @@ object SackAPI { private var lastOpenedInventory = "" var inSackInventory = false + // TODO USE SH-REPO private val sackPattern = "^(.* Sack|Enchanted .* Sack)$".toPattern() private val numPattern = @@ -66,7 +69,7 @@ object SackAPI { val inventoryName = event.inventoryName val isNewInventory = inventoryName != lastOpenedInventory lastOpenedInventory = inventoryName - val match = sackPattern.matcher(inventoryName).matches() + val match = sackPattern.matches(inventoryName) if (!match) return val stacks = event.inventoryItems isRuneSack = inventoryName == "Runes Sack" @@ -301,7 +304,7 @@ object SackAPI { private fun saveSackData() { ProfileStorageData.sackProfiles?.sackContents = sackData - SkyHanniMod.configManager.saveSackData("saving-data") + SkyHanniMod.configManager.saveConfig(ConfigFileType.SACKS, "saving-data") } data class SackGemstone( diff --git a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt index f3c23700d..2a6b99297 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt @@ -15,7 +15,6 @@ import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.RecalculatingValue -import at.hannibal2.skyhanni.utils.StringUtils.removeColor import com.google.common.cache.CacheBuilder import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.concurrent.TimeUnit @@ -29,6 +28,7 @@ object SlayerAPI { var questStartTime = 0L var isInCorrectArea = false + var isInAnyArea = false var latestSlayerCategory = "" private var latestProgressChangeTime = 0L var latestWrongAreaWarning = 0L @@ -40,22 +40,6 @@ object SlayerAPI { System.currentTimeMillis() } else latestProgressChangeTime - - // TODO use repo - fun ignoreSlayerDrop(name: String) = when (name.removeColor()) { - // maybe everywhere? - "Stone" -> true - "Head" -> true - - // Spider - "Cobweb" -> true - - // Blaze - "Water Bottle" -> true - - else -> false - } - fun getItemNameAndPrice(internalName: NEUInternalName, amount: Int): Pair<String, Double> { val key = internalName to amount nameCache.getIfPresent(key)?.let { @@ -139,9 +123,12 @@ object SlayerAPI { if (event.isMod(5)) { isInCorrectArea = if (LorenzUtils.isStrandedProfile) { + isInAnyArea = true true } else { - getSlayerTypeForCurrentArea() == getActiveSlayer() + val slayerTypeForCurrentArea = getSlayerTypeForCurrentArea() + isInAnyArea = slayerTypeForCurrentArea != null + slayerTypeForCurrentArea == getActiveSlayer() && slayerTypeForCurrentArea != null } } } @@ -178,4 +165,4 @@ object SlayerAPI { else -> null } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/ComposterUpgrade.kt b/src/main/java/at/hannibal2/skyhanni/data/model/ComposterUpgrade.kt index 4712689dc..627bfdef7 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/model/ComposterUpgrade.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/model/ComposterUpgrade.kt @@ -10,9 +10,10 @@ enum class ComposterUpgrade(val displayName: String, val slotNumber: Int) { companion object { private fun regexValues() = entries.joinToString("|") { it.displayName } + // TODO USE SH-REPO val regex = "§a(?<name>${regexValues()})(?: (?<level>.*))?".toPattern() fun getByName(name: String) = entries.firstOrNull { it.displayName == name } } -}
\ No newline at end of file +} 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 593d9a652..9dcba5e8f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt @@ -83,7 +83,7 @@ class RepoManager(private val configLocation: File) { if (unsuccessfulConstants.isEmpty()) { if (command) { - LorenzUtils.chat("§e[SkyHanni] §7The repo is already up to date!") + LorenzUtils.chat("§7The repo is already up to date!") atomicShouldManuallyReload.set(false) } return@supplyAsync false @@ -156,12 +156,13 @@ class RepoManager(private val configLocation: File) { } comp.complete(null) if (answerMessage.isNotEmpty() && !error) { - LorenzUtils.chat("§e[SkyHanni] §a$answerMessage") + LorenzUtils.chat("§a$answerMessage") } if (error) { LorenzUtils.clickableChat( - "§e[SkyHanni] Error with the repo detected, try /shupdaterepo to fix it!", - "shupdaterepo" + "Error with the repo detected, try /shupdaterepo to fix it!", + "shupdaterepo", + prefixColor = "§c" ) if (unsuccessfulConstants.isEmpty()) { unsuccessfulConstants.add("All Constants") @@ -174,9 +175,12 @@ class RepoManager(private val configLocation: File) { fun displayRepoStatus(joinEvent: Boolean) { if (joinEvent) { if (unsuccessfulConstants.isNotEmpty()) { - LorenzUtils.chat("§c[SkyHanni] §7Repo Issue! Some features may not work. Please report this error on the Discord!") - LorenzUtils.chat("§7Repo Auto Update Value: §c${SkyHanniMod.feature.dev.repoAutoUpdate}") - LorenzUtils.chat("§7If you have Repo Auto Update turned off, please try turning that on.\n§cUnsuccessful Constants §7(${unsuccessfulConstants.size}):") + LorenzUtils.error( + "§7Repo Issue! Some features may not work. Please report this error on the Discord!\n" + + "§7Repo Auto Update Value: §c${SkyHanniMod.feature.dev.repoAutoUpdate}\n" + + "§7If you have Repo Auto Update turned off, please try turning that on.\n" + + "§cUnsuccessful Constants §7(${unsuccessfulConstants.size}):" + ) for (constant in unsuccessfulConstants) { LorenzUtils.chat(" §e- §7$constant") } @@ -184,14 +188,14 @@ class RepoManager(private val configLocation: File) { return } if (unsuccessfulConstants.isEmpty() && successfulConstants.isNotEmpty()) { - LorenzUtils.chat("§a[SkyHanni] Repo working fine!") + LorenzUtils.chat("Repo working fine!", prefixColor = "§a") return } - if (successfulConstants.isNotEmpty()) LorenzUtils.chat("§a[SkyHanni] Successful Constants §7(${successfulConstants.size}):") + if (successfulConstants.isNotEmpty()) LorenzUtils.chat("Successful Constants §7(${successfulConstants.size}):", prefixColor = "§a") for (constant in successfulConstants) { LorenzUtils.chat(" §a- §7$constant") } - LorenzUtils.chat("§c[SkyHanni] Unsuccessful Constants §7(${unsuccessfulConstants.size}):") + LorenzUtils.chat("Unsuccessful Constants §7(${unsuccessfulConstants.size}):") for (constant in unsuccessfulConstants) { LorenzUtils.chat(" §e- §7$constant") } |