aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Storage.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt28
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt2
5 files changed, 24 insertions, 20 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
index 9ec45a70c..da3ccd8f4 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
@@ -106,7 +106,7 @@ public class Storage {
public static class GardenStorage {
@Expose
- public int experience = -1;
+ public Long experience = null;
@Expose
public Map<CropType, Long> cropCounter = new HashMap<>();
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt
index 3524f03db..b4ad1d1af 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt
@@ -155,7 +155,7 @@ object ProfileStorageData {
}
profileSpecific?.garden?.let {
- it.experience = oldHidden.gardenExp
+ it.experience = oldHidden.gardenExp.toLong()
it.cropCounter = oldHidden.gardenCropCounter
it.cropUpgrades = oldHidden.gardenCropUpgrades
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 05e407781..d7469416f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
@@ -38,6 +38,13 @@ object GardenAPI {
private var inBarn = false
val onBarnPlot get() = inBarn && inGarden()
val config get() = ProfileStorageData.profileSpecific?.garden
+ var gardenExp: Long?
+ get() = config?.experience
+ set(value) {
+ value?.let {
+ config?.experience = it
+ }
+ }
private val barnArea = AxisAlignedBB(35.5, 70.0, -4.5, -32.5, 100.0, -46.5)
@@ -203,7 +210,8 @@ object GardenAPI {
return 0
}
- fun getLevelForExp(gardenExp: Long): Int {
+ fun getGardenLevel(): Int {
+ val gardenExp = this.gardenExp ?: return 0
var tier = 0
var totalExp = 0L
for (tierExp in gardenExperience) {
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 0fa4888cc..496fe1712 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
@@ -13,7 +13,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import kotlin.math.roundToInt
+import kotlin.math.roundToLong
import kotlin.time.Duration.Companion.milliseconds
class GardenLevelDisplay {
@@ -21,11 +21,6 @@ class GardenLevelDisplay {
private val expToNextLevelPattern = "(?:.*) §e(?<nextLevelExp>.*)§6\\/(?:.*)".toPattern()
private val overflowPattern = ".*§r §6(?<overflow>.*) XP".toPattern()
private val namePattern = "Garden Level (?<currentLevel>.*)".toPattern()
- private var gardenExp
- get() = GardenAPI.config?.experience ?: -1
- set(value) {
- GardenAPI.config?.experience = value
- }
private var display = ""
private var visitorRewardPattern = " {4}§r§8\\+§r§2(?<exp>.*) §r§7Garden Experience".toPattern()
@@ -44,9 +39,10 @@ class GardenLevelDisplay {
}
private fun addExp(moreExp: Int) {
- val oldLevel = GardenAPI.getLevelForExp(gardenExp.toLong())
- gardenExp += moreExp
- val newLevel = GardenAPI.getLevelForExp(gardenExp.toLong())
+ val gardenExp = GardenAPI.gardenExp ?: return
+ val oldLevel = GardenAPI.getGardenLevel()
+ GardenAPI.gardenExp = gardenExp + moreExp
+ val newLevel = GardenAPI.getGardenLevel()
if (newLevel == oldLevel + 1) {
if (newLevel > 15) {
LorenzUtils.runDelayed(50.milliseconds) {
@@ -69,20 +65,20 @@ class GardenLevelDisplay {
namePattern.matchMatcher(item.name!!.removeColor()) {
val currentLevel = group("currentLevel").romanToDecimalIfNeeded()
- var nextLevelExp = 0
+ var nextLevelExp = 0L
for (line in item.getLore()) {
expToNextLevelPattern.matchMatcher(line) {
- nextLevelExp = group("nextLevelExp").replace(",", "").toDouble().roundToInt()
+ nextLevelExp = group("nextLevelExp").replace(",", "").toDouble().roundToLong()
}
overflowPattern.matchMatcher(line) {
- val overflow = group("overflow").replace(",", "").toDouble().roundToInt()
- gardenExp = overflow
+ val overflow = group("overflow").replace(",", "").toDouble().roundToLong()
+ GardenAPI.gardenExp = overflow
update()
return
}
}
val expForLevel = GardenAPI.getExpForLevel(currentLevel).toInt()
- gardenExp = expForLevel + nextLevelExp
+ GardenAPI.gardenExp = expForLevel + nextLevelExp
update()
}
}
@@ -92,8 +88,8 @@ class GardenLevelDisplay {
}
private fun drawDisplay(): String {
- if (gardenExp == -1) return "§aGarden Level ? §cOpen the desk!"
- val currentLevel = GardenAPI.getLevelForExp(gardenExp.toLong())
+ val gardenExp = GardenAPI.gardenExp ?: return "§aGarden Level ? §cOpen the desk!"
+ val currentLevel = GardenAPI.getGardenLevel()
val needForLevel = GardenAPI.getExpForLevel(currentLevel).toInt()
val nextLevel = currentLevel + 1
val needForNextLevel = GardenAPI.getExpForLevel(nextLevel).toInt()
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 136917c7c..e10a8f831 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
@@ -183,7 +183,7 @@ object FFStats {
}
private fun getPetFFData(item: ItemStack, out: MutableMap<FFTypes, Double>) {
- val gardenLvl = GardenAPI.getLevelForExp((GardenAPI.config?.experience ?: -1).toLong())
+ val gardenLvl = GardenAPI.getGardenLevel()
out[FFTypes.TOTAL] = 0.0
out[FFTypes.BASE] = getPetFF(item)
out[FFTypes.PET_ITEM] = when (item.getPetItem()) {