aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenLevelConfig.java13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt114
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt4
5 files changed, 119 insertions, 27 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenLevelConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenLevelConfig.java
index e117a1858..875532763 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenLevelConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenLevelConfig.java
@@ -6,6 +6,7 @@ import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
+import io.github.notenoughupdates.moulconfig.observer.Property;
public class GardenLevelConfig {
@Expose
@@ -15,6 +16,18 @@ public class GardenLevelConfig {
public boolean display = false;
@Expose
+ @ConfigOption(name = "Overflow", desc = "Enable overflow Garden levels")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public Property<Boolean> overflow = Property.of(true);
+
+ @Expose
+ @ConfigOption(name = "Overflow Chat", desc = "Enable overflow Garden level up messages in chat.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean overflowChat = true;
+
+ @Expose
@ConfigLink(owner = GardenLevelConfig.class, field = "display")
public Position pos = new Position(390, 40, false, true);
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java
index 1007168a9..e30f62946 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java
@@ -17,6 +17,9 @@ public class PlayerSpecificStorage {
public Map<String, ProfileSpecificStorage> profiles = new HashMap<>(); // profile name
@Expose
+ public Boolean useRomanNumerals = true;
+
+ @Expose
public Integer gardenCommunityUpgrade = -1;
@Expose
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 7cf2fde5c..b080e53d1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
@@ -226,7 +226,7 @@ object GardenAPI {
return 0
}
- fun getGardenLevel(): Int {
+ fun getGardenLevel(overflow: Boolean = true): Int {
val gardenExp = this.gardenExp ?: return 0
var tier = 0
var totalExp = 0L
@@ -237,11 +237,13 @@ object GardenAPI {
}
tier++
}
- totalExp += gardenOverflowExp
-
- while (totalExp < gardenExp) {
- tier++
+ if (overflow) {
totalExp += gardenOverflowExp
+
+ while (totalExp < gardenExp) {
+ tier++
+ totalExp += gardenOverflowExp
+ }
}
return tier
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
index 54db1d71d..566589358 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
@@ -1,18 +1,28 @@
package at.hannibal2.skyhanni.features.garden
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
+import at.hannibal2.skyhanni.data.ProfileStorageData
+import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.ConditionalUtils
+import at.hannibal2.skyhanni.utils.InventoryUtils
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.groupOrNull
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.format
import at.hannibal2.skyhanni.utils.NumberUtil.formatLong
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
+import at.hannibal2.skyhanni.utils.NumberUtil.toRoman
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
+import at.hannibal2.skyhanni.utils.StringUtils
+import at.hannibal2.skyhanni.utils.StringUtils.isRoman
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -23,6 +33,11 @@ import kotlin.time.Duration.Companion.milliseconds
class GardenLevelDisplay {
private val config get() = GardenAPI.config.gardenLevels
+ private var useRomanNumerals: Boolean
+ get() = ProfileStorageData.playerSpecific?.useRomanNumerals ?: true
+ set(value) {
+ ProfileStorageData.playerSpecific?.useRomanNumerals = value
+ }
private val patternGroup = RepoPattern.group("garden.level")
private val expToNextLevelPattern by patternGroup.pattern(
@@ -41,6 +56,10 @@ class GardenLevelDisplay {
"inventory.levelprogress",
"§7Progress to Level (?<currentLevel>[^:]*).*"
)
+ private val gardenMaxLevelPattern by patternGroup.pattern(
+ "inventory.max",
+ "§5§o§7§8Max level reached!"
+ )
private val visitorRewardPattern by patternGroup.pattern(
"chat.increase",
" {4}§r§8\\+§r§2(?<exp>.*) §r§7Garden Experience"
@@ -66,18 +85,19 @@ class GardenLevelDisplay {
val gardenExp = GardenAPI.gardenExp ?: return
val oldLevel = GardenAPI.getGardenLevel()
GardenAPI.gardenExp = gardenExp + moreExp
+ update()
+
+ if (!config.overflowChat) return
val newLevel = GardenAPI.getGardenLevel()
- if (newLevel == oldLevel + 1 && newLevel > 15) {
- LorenzUtils.runDelayed(50.milliseconds) {
- ChatUtils.clickableChat(
- " \n§b§lGARDEN LEVEL UP §8$oldLevel ➜ §b$newLevel\n" +
- " §8+§aRespect from Elite Farmers and SkyHanni members :)\n ",
- "/gardenlevels",
- false
- )
- }
+ if (newLevel != oldLevel + 1 || newLevel <= 15) return
+ LorenzUtils.runDelayed(50.milliseconds) {
+ ChatUtils.clickableChat(
+ " \n§b§lGARDEN LEVEL UP §8$oldLevel ➜ §b$newLevel\n" +
+ " §8+§aRespect from Elite Farmers and SkyHanni members :)\n ",
+ "/gardenlevels",
+ false
+ )
}
- update()
}
@SubscribeEvent
@@ -88,7 +108,10 @@ class GardenLevelDisplay {
"SkyBlock Menu" -> event.inventoryItems[10] ?: return
else -> return
}
- if (!gardenItemNamePattern.matches(item.name.removeColor())) return
+ gardenItemNamePattern.matchMatcher(item.name.removeColor()) {
+ val level = groupOrNull("currentLevel")
+ if (level != null) useRomanNumerals = level.isRoman()
+ } ?: return
var nextLevelExp = 0L
var currentLevel = 0
for (line in item.getLore()) {
@@ -111,23 +134,69 @@ class GardenLevelDisplay {
update()
}
+ @SubscribeEvent
+ fun onTooltip(event: LorenzToolTipEvent) {
+ if (!GardenAPI.inGarden()) return
+ if (!config.overflow.get()) return
+ val slotIndex = event.slot.slotIndex
+ val name = InventoryUtils.openInventoryName()
+ if (!((name == "Desk" && slotIndex == 4) || (name == "SkyBlock Menu" && slotIndex == 10))) return
+
+ val gardenExp = GardenAPI.gardenExp ?: return
+ val currentLevel = GardenAPI.getGardenLevel()
+ if (currentLevel < 15) return
+
+ val needForLevel = GardenAPI.getExpForLevel(currentLevel).toInt()
+ val overflow = (gardenExp - needForLevel).toDouble()
+ val overflowTotal = (gardenExp - GardenAPI.getExpForLevel(15)).toInt()
+ val needForNextLevel = GardenAPI.getExpForLevel(currentLevel + 1).toInt()
+ val needForOnlyNextLvl = needForNextLevel - needForLevel
+
+ val iterator = event.toolTip.listIterator()
+ if (slotIndex == 4 && currentLevel > 15) {
+ event.itemStack.name = "§aGarden Level ${currentLevel.toRomanIfNecessary()}"
+ }
+ var next = false
+ for (line in iterator) {
+ if (gardenMaxLevelPattern.matches(line)) {
+ iterator.set("§7Progress to Level ${(currentLevel + 1).toRomanIfNecessary()}")
+ next = true
+ continue
+ }
+ if (next && line.contains(" ")) {
+ val progress = overflow / needForOnlyNextLvl
+ val progressBar = StringUtils.progressBar(progress, 20)
+ iterator.set("$progressBar §e${overflow.addSeparators()}§6/§e${format(needForOnlyNextLvl)}")
+ iterator.add("")
+ iterator.add("§b§lOVERFLOW XP:")
+ iterator.add("§7▸ ${overflowTotal.addSeparators()}")
+ return
+ }
+ }
+ }
+
private fun update() {
display = drawDisplay()
}
private fun drawDisplay(): String {
val gardenExp = GardenAPI.gardenExp ?: return "§aGarden Level ? §cOpen the desk!"
- val currentLevel = GardenAPI.getGardenLevel()
+ val currentLevel = GardenAPI.getGardenLevel(overflow = config.overflow.get())
+ val isMax = !config.overflow.get() && currentLevel == 15
val needForLevel = GardenAPI.getExpForLevel(currentLevel).toInt()
- val nextLevel = currentLevel + 1
- val needForNextLevel = GardenAPI.getExpForLevel(nextLevel).toInt()
-
- return "§aGarden Level $currentLevel" + if (needForNextLevel != 0) {
- val overflow = gardenExp - needForLevel
- val needForOnlyNextLvl = needForNextLevel - needForLevel
+ val overflow = gardenExp - needForLevel
+
+ return "§aGarden level $currentLevel " + if (isMax) {
+ "§7(§e${overflow.addSeparators()}§7)"
+ } else {
+ val needForNextLevel = GardenAPI.getExpForLevel(currentLevel + 1).toInt()
+ val needForOnlyNextLevel = needForNextLevel - needForLevel
+ "§7(§e${overflow.addSeparators()}§7/§e${needForOnlyNextLevel.addSeparators()}§7)"
+ }
+ }
- " §7(§e${overflow.addSeparators()}§7/§e${needForOnlyNextLvl.addSeparators()}§7)"
- } else ""
+ private fun Int.toRomanIfNecessary(): String {
+ return if (useRomanNumerals) this.toRoman() else this.toString()
}
@SubscribeEvent
@@ -138,6 +207,11 @@ class GardenLevelDisplay {
config.pos.renderString(display, posLabel = "Garden Level")
}
+ @SubscribeEvent
+ fun onConfigLoad(event: ConfigLoadEvent) {
+ ConditionalUtils.onToggle(config.overflow) { update() }
+ }
+
private fun isEnabled() = GardenAPI.inGarden() && config.display
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt
index 0732535f4..a23f34c66 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt
@@ -165,11 +165,11 @@ object FFStats {
}
private fun getPetFFData(item: ItemStack, out: MutableMap<FFTypes, Double>) {
- val gardenLvl = GardenAPI.getGardenLevel()
+ val gardenLvl = GardenAPI.getGardenLevel(overflow = false)
out[FFTypes.TOTAL] = 0.0
out[FFTypes.BASE] = getPetFF(item)
out[FFTypes.PET_ITEM] = when (item.getPetItem()) {
- "GREEN_BANDANA" -> (4.0 * gardenLvl).coerceAtMost(60.0)
+ "GREEN_BANDANA" -> 4.0 * gardenLvl
"YELLOW_BANDANA" -> 30.0
"MINOS_RELIC" -> (out[FFTypes.BASE] ?: 0.0) * .33
else -> 0.0