aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Misc.java64
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt43
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt14
5 files changed, 109 insertions, 22 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
index aa6123a61..f3dd78b37 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
@@ -246,32 +246,38 @@ public class Misc {
@Expose
@ConfigOption(name = "First Line", desc = "Decide what to show in the first line.")
@ConfigEditorDropdown(values = {
- "Nothing",
- "Location",
- "Purse",
- "Bits",
- "Stats",
- "Held Item",
- "Skyblock Date",
- "Profile (Fruit)",
- "Slayer",
- "Custom"
+ "Nothing",
+ "Location",
+ "Purse",
+ "Bits",
+ "Stats",
+ "Held Item",
+ "Skyblock Date",
+ "Profile (Fruit)",
+ "Slayer",
+ "Custom",
+ "Dynamic",
+ "Crop Milestone",
+ "Current Pet"
})
public Property<Integer> firstLine = Property.of(0);
@Expose
@ConfigOption(name = "Second Line", desc = "Decide what to show in the second line.")
@ConfigEditorDropdown(values = {
- "Nothing",
- "Location",
- "Purse",
- "Bits",
- "Stats",
- "Held Item",
- "Skyblock Date",
- "Profile (Fruit)",
- "Slayer",
- "Custom"
+ "Nothing",
+ "Location",
+ "Purse",
+ "Bits",
+ "Stats",
+ "Held Item",
+ "Skyblock Date",
+ "Profile (Fruit)",
+ "Slayer",
+ "Custom",
+ "Dynamic",
+ "Crop Milestone",
+ "Current Pet"
})
public Property<Integer> secondLine = Property.of(0);
@@ -279,6 +285,24 @@ public class Misc {
@ConfigOption(name = "Custom", desc = "What should be displayed if you select \"Custom\" above.")
@ConfigEditorText
public Property<String> customText = Property.of("");
+
+ @Expose
+ @ConfigOption(name = "Dynamic", desc = "\"Dynamic\" above shows your Crop Milestone or Slayer progress while doing those, but this if you're doing neither.")
+ @ConfigEditorDropdown(values = {
+ "Nothing",
+ "Location",
+ "Purse",
+ "Bits",
+ "Stats",
+ "Held Item",
+ "Skyblock Date",
+ "Profile (Fruit)",
+ "Slayer",
+ "Custom",
+ "Crop Milestone",
+ "Current Pet"
+ })
+ public Property<Integer> auto = Property.of(0);
}
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt
index d07172609..da7f0b05b 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt
@@ -93,6 +93,14 @@ class GardenCropMilestones {
return 0
}
+ fun CropType.progressToNextLevel(): Double {
+ val progress = getCounter()
+ val startTier = getTierForCrops(progress)
+ val startCrops = getCropsForTier(startTier)
+ val end = getCropsForTier(startTier + 1).toDouble()
+ return (progress - startCrops) / (end - startCrops)
+ }
+
// TODO use repo
private val cropMilestone = listOf(
100,
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt
index 402a643d1..21539451f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt
@@ -51,7 +51,7 @@ class DiscordRPCManager : IPCListener {
secondLine = getStatusByConfigId(config.secondLine.get())
startTimestamp = System.currentTimeMillis()
client = IPCClient(applicationID)
- client?.setListener(this@DiscordRPCManager) // why must kotlin be this way
+ client?.setListener(this@DiscordRPCManager)
try {
client?.connect()
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 93c05ee32..f76ea9dc4 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
@@ -4,9 +4,14 @@ package at.hannibal2.skyhanni.features.misc.discordrpc
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.ActionBarStatsData
+import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter
+import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getTierForCrops
+import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.progressToNextLevel
import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.data.ScoreboardData
+import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.colorCodeToRarity
import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import io.github.moulberry.notenoughupdates.util.SkyBlockTime
@@ -14,7 +19,6 @@ import java.util.function.Supplier
import java.util.regex.Pattern
enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) {
- // implements "ButtonSelect:SelectItem". no idea how to translate that into skyhanni
NONE(null),
@@ -137,6 +141,43 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?)
CUSTOM({
SkyHanniMod.feature.misc.discordRPC.customText.get() // custom field in the config
+ }),
+
+ AUTO({
+ val slayerResult = SLAYER.displayMessageSupplier!!.get()
+ val milestoneResult = try {
+ CROP_MILESTONES.displayMessageSupplier!!.get()
+ } catch (e: Exception) {
+ "Unable to get milestone"
+ }
+ if (slayerResult != "Planning to do a slayer quest") slayerResult
+ else if (milestoneResult != "Unable to get milestone" && milestoneResult != "Unknown Item" && milestoneResult != "") milestoneResult
+ else {
+ val statusNoAuto = DiscordStatus.values().toMutableList()
+ statusNoAuto.remove(AUTO)
+ statusNoAuto[SkyHanniMod.feature.misc.discordRPC.auto.get()].getDisplayString()
+ }
+ }),
+
+ CROP_MILESTONES({
+ val item = net.minecraft.client.Minecraft.getMinecraft().thePlayer.heldItem
+ val crop = item.getCropType()
+ val cropCounter = crop?.getCounter()
+ val tier = cropCounter?.let { getTierForCrops(it) }
+
+ val progress = tier?.let {
+ LorenzUtils.formatPercentage(crop.progressToNextLevel())
+ } ?: 100 // percentage to next milestone
+
+ tier?.let { "${crop.cropName}: Milestone $it ($progress)" } ?: ""
+ }),
+
+ PETS({
+ val pet = SkyHanniMod.feature.hidden.currentPet
+ val colorCode = pet.substring(1..2).first()
+ val petName = pet.substring(2)
+
+ "${colorCodeToRarity(colorCode)} $petName"
})
;
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index cdd3af5d9..4a67184f2 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -265,4 +265,18 @@ object LorenzUtils {
fun <K, V> Map<K, V>.editCopy(function: MutableMap<K, V>.() -> Unit) =
toMutableMap().also { function(it) }.toMap()
+
+ fun colorCodeToRarity(colorCode: Char): String {
+ return when (colorCode) {
+ 'f' -> "Common"
+ 'a' -> "Uncommon"
+ '9' -> "Rare"
+ '5' -> "Epic"
+ '6' -> "Legendary"
+ 'd' -> "Mythic"
+ 'b' -> "Divine"
+ '4' -> "Supreme" // legacy items
+ else -> "Special"
+ }
+ }
} \ No newline at end of file