diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-14 01:29:06 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-14 01:29:06 +0100 |
commit | 529be3695bad582d9a845d11dfba7fbe3ec235ee (patch) | |
tree | c5ed7fce0ba5a3bc41d4daf40220b92392b21cf3 /src/main/java | |
parent | e54c3ef28a9fb91b3438b4fcf7abebf41f9b1828 (diff) | |
download | skyhanni-529be3695bad582d9a845d11dfba7fbe3ec235ee.tar.gz skyhanni-529be3695bad582d9a845d11dfba7fbe3ec235ee.tar.bz2 skyhanni-529be3695bad582d9a845d11dfba7fbe3ec235ee.zip |
code cleanup
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt | 36 |
1 files changed, 18 insertions, 18 deletions
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 c4177ade0..1d85443ca 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt @@ -8,12 +8,12 @@ import at.hannibal2.skyhanni.events.ProfileJoinEvent 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.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary 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.roundToLong import kotlin.time.Duration.Companion.milliseconds class GardenLevelDisplay { @@ -47,7 +47,7 @@ class GardenLevelDisplay { LorenzUtils.runDelayed(50.milliseconds) { LorenzUtils.clickableChat( " \n§b§lGARDEN LEVEL UP §8$oldLevel ➜ §b$newLevel\n" + - " §8+§aRespect from Elite Farmers and SkyHanni members :)\n ", + " §8+§aRespect from Elite Farmers and SkyHanni members :)\n ", "/gardenlevels", false ) @@ -62,24 +62,24 @@ class GardenLevelDisplay { if (event.inventoryName != "Desk") return val item = event.inventoryItems[4]!! - namePattern.matchMatcher(item.name!!.removeColor()) { - val currentLevel = group("currentLevel").romanToDecimalIfNecessary() - var nextLevelExp = 0L - for (line in item.getLore()) { - expToNextLevelPattern.matchMatcher(line) { - nextLevelExp = group("nextLevelExp").replace(",", "").toDouble().roundToLong() - } - overflowPattern.matchMatcher(line) { - val overflow = group("overflow").replace(",", "").toDouble().roundToLong() - GardenAPI.gardenExp = overflow - update() - return - } + val currentLevel = namePattern.matchMatcher(item.name!!.removeColor()) { + group("currentLevel").romanToDecimalIfNecessary() + } ?: return + var nextLevelExp = 0L + for (line in item.getLore()) { + expToNextLevelPattern.matchMatcher(line) { + nextLevelExp = group("nextLevelExp").formatNumber() + } + overflowPattern.matchMatcher(line) { + val overflow = group("overflow").formatNumber() + GardenAPI.gardenExp = overflow + update() + return } - val expForLevel = GardenAPI.getExpForLevel(currentLevel).toInt() - GardenAPI.gardenExp = expForLevel + nextLevelExp - update() } + val expForLevel = GardenAPI.getExpForLevel(currentLevel).toInt() + GardenAPI.gardenExp = expForLevel + nextLevelExp + update() } private fun update() { |