aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-04-18 20:49:25 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-04-18 20:49:25 +0200
commit55e2b4f3527c887bdee4bf8fc338b8404ecee4ce (patch)
tree928bb57a28eb30c03d9a89c38de7dc83f6cf1f8b /src/main/java/at/hannibal2/skyhanni
parent602940752c3a74473c8092b3d646926686b38522 (diff)
downloadskyhanni-55e2b4f3527c887bdee4bf8fc338b8404ecee4ce.tar.gz
skyhanni-55e2b4f3527c887bdee4bf8fc338b8404ecee4ce.tar.bz2
skyhanni-55e2b4f3527c887bdee4bf8fc338b8404ecee4ce.zip
extracting getPetDisplay and getCropMilestoneDisplay in DiscordStatus
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt58
1 files changed, 27 insertions, 31 deletions
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 d6debfa4a..b217aded1 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
@@ -28,7 +28,6 @@ import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay.getCurre
import io.github.moulberry.notenoughupdates.util.SkyBlockTime
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
-import java.util.function.Supplier
import java.util.regex.Pattern
import kotlin.time.Duration.Companion.minutes
@@ -53,9 +52,31 @@ private fun getVisitingName(): String {
var beenAfkFor = SimpleTimeMark.now()
-enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) {
+fun getPetDisplay(): String = PetAPI.currentPet?.let {
+ val colorCode = it.substring(1..2).first()
+ val petName = it.substring(2)
+ val petLevel = getCurrentPet()?.petLevel?.currentLevel ?: "?"
- NONE(null),
+ "[Lvl $petLevel] ${colorCodeToRarity(colorCode)} $petName"
+} ?: "No pet equipped"
+
+private fun getCropMilestoneDisplay(): String {
+ val crop = InventoryUtils.getItemInHand()?.getCropType()
+ val cropCounter = crop?.getCounter()
+ val tier = cropCounter?.let { getTierForCropCount(it, crop) }
+
+ val progress = tier?.let {
+ LorenzUtils.formatPercentage(crop.progressToNextLevel())
+ } ?: 100 // percentage to next milestone
+
+ return if (tier != null) {
+ "${crop.cropName}: ${if (!crop.isMaxed()) "Milestone $tier ($progress)" else "MAXED (${cropCounter.addSeparators()} crops collected)"}"
+ } else AutoStatus.CROP_MILESTONES.placeholderText
+}
+
+enum class DiscordStatus(private val displayMessageSupplier: (() -> String?)) {
+
+ NONE({ null }),
LOCATION({
var location = LorenzUtils.skyBlockArea?.removeColor() ?: "invalid"
@@ -231,29 +252,9 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?)
autoReturn
}),
- CROP_MILESTONES({
- val crop = InventoryUtils.getItemInHand()?.getCropType()
- val cropCounter = crop?.getCounter()
- val tier = cropCounter?.let { getTierForCropCount(it, crop) }
+ CROP_MILESTONES({ getCropMilestoneDisplay() }),
- val progress = tier?.let {
- LorenzUtils.formatPercentage(crop.progressToNextLevel())
- } ?: 100 // percentage to next milestone
-
- if (tier != null) {
- "${crop.cropName}: ${if (!crop.isMaxed()) "Milestone $tier ($progress)" else "MAXED (${cropCounter.addSeparators()} crops collected)"}"
- } else AutoStatus.CROP_MILESTONES.placeholderText
- }),
-
- PETS({
- PetAPI.currentPet?.let {
- val colorCode = it.substring(1..2).first()
- val petName = it.substring(2)
- val petLevel = getCurrentPet()?.petLevel?.currentLevel ?: "?"
-
- "[Lvl $petLevel] ${colorCodeToRarity(colorCode)} $petName"
- } ?: "No pet equipped"
- }),
+ PETS({ getPetDisplay() }),
// Dynamic-only
STACKING({
@@ -333,12 +334,7 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?)
})
;
- fun getDisplayString(): String {
- if (displayMessageSupplier != null) {
- return displayMessageSupplier.get()
- }
- return ""
- }
+ fun getDisplayString(): String = displayMessageSupplier() ?: ""
}
enum class AutoStatus(val placeholderText: String, val correspondingDiscordStatus: DiscordStatus) {