diff options
author | alexia <me@alexia.lol> | 2023-12-02 18:34:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-02 18:34:19 +0100 |
commit | ba52a1ef37d734419191789b1953deae7dfff247 (patch) | |
tree | e723bc95b555d6f7463efd9bf9d56c3c506ab6d5 /src/main/java/at/hannibal2/skyhanni | |
parent | f97ed6e1c08f86b6616f6708a2db0fbe3ad743d8 (diff) | |
download | skyhanni-ba52a1ef37d734419191789b1953deae7dfff247.tar.gz skyhanni-ba52a1ef37d734419191789b1953deae7dfff247.tar.bz2 skyhanni-ba52a1ef37d734419191789b1953deae7dfff247.zip |
Highlight boosted crop in Jacob's Contests (#752)
Highlight boosted crop contest in all Jacob's Contests displays. #752
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt | 10 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt | 28 |
2 files changed, 30 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index aafd3fd7c..6ef4800dc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -34,6 +34,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getCultivatingCounter import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getHoeCounter import net.minecraft.client.Minecraft +import net.minecraft.enchantment.Enchantment import net.minecraft.item.ItemStack import net.minecraft.network.play.client.C09PacketHeldItemChange import net.minecraft.util.AxisAlignedBB @@ -142,9 +143,14 @@ object GardenAPI { fun readCounter(itemStack: ItemStack): Long = itemStack.getHoeCounter() ?: itemStack.getCultivatingCounter() ?: -1L - fun MutableList<Any>.addCropIcon(crop: CropType) { + fun MutableList<Any>.addCropIcon(crop: CropType, highlight: Boolean = false) { try { - add(crop.icon) + var icon = crop.icon.copy() + if (highlight) { + // Hack to add enchant glint, like Hypixel does it + icon.addEnchantment(Enchantment.protection, 0) + } + add(icon) } catch (e: NullPointerException) { e.printStackTrace() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt index 6291b253e..937299d22 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -19,6 +19,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.TabListData import at.hannibal2.skyhanni.utils.TimeUtils import com.google.gson.Gson import io.github.moulberry.notenoughupdates.util.SkyBlockTime @@ -291,17 +292,31 @@ object GardenNextJacobContest { nextContest: FarmingContest, list: MutableList<Any>, ): MutableList<Any> { + var boostedCrop: CropType? = null + outer@ for (line in TabListData.getTabList()) { + val lineStripped = line.removeColor().trim() + if (lineStripped.startsWith("☘ ")) { + for (crop in nextContest.crops) { + if (line.removeColor().trim() == "☘ ${crop.cropName}") { + boostedCrop = crop + break@outer + } + } + break + } + } + var duration = nextContest.endTime - System.currentTimeMillis() if (duration < contestDuration) { list.add("§aActive: ") } else { list.add("§eNext: ") duration -= contestDuration - warn(duration, nextContest.crops) + warn(duration, nextContest.crops, boostedCrop) } for (crop in nextContest.crops) { list.add(" ") - list.addCropIcon(crop) + list.addCropIcon(crop, highlight = (crop == boostedCrop)) nextContestCrops.add(crop) } val format = TimeUtils.formatDuration(duration) @@ -310,23 +325,24 @@ object GardenNextJacobContest { return list } - private fun warn(timeInMillis: Long, crops: List<CropType>) { + private fun warn(timeInMillis: Long, crops: List<CropType>, boostedCrop: CropType?) { if (!config.warn) return if (config.warnTime <= timeInMillis / 1000) return if (System.currentTimeMillis() < lastWarningTime) return lastWarningTime = System.currentTimeMillis() + 60_000 * 40 - val cropText = crops.joinToString("§7, ") { "§a${it.cropName}" } + val cropText = crops.joinToString("§7, ") { (if (it == boostedCrop) "§6" else "§a") + it.cropName } LorenzUtils.chat("Next farming contest: $cropText") LorenzUtils.sendTitle("§eFarming Contest!", 5.seconds) SoundUtils.playBeepSound() + val cropTextNoColor = crops.joinToString(", ") { if (it == boostedCrop) "<b>${it.cropName}</b>" else it.cropName } if (config.warnPopup && !Display.isActive()) { SkyHanniMod.coroutineScope.launch { openPopupWindow( - "Farming Contest soon!\n" + - "Crops: ${cropText.removeColor()}" + "<html>Farming Contest soon!<br />" + + "Crops: ${cropTextNoColor}</html>" ) } } |