diff options
| author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-03-06 23:51:02 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-06 23:51:02 +0100 |
| commit | 0a95a791eb57a546fb5421594abae740faf1dfdb (patch) | |
| tree | 82bfc13c544a60d496bab081b66ddd73e07d62a3 /src/main/java | |
| parent | 28430fe85115334fb06fb7e3cc36da819f08dace (diff) | |
| download | skyhanni-0a95a791eb57a546fb5421594abae740faf1dfdb.tar.gz skyhanni-0a95a791eb57a546fb5421594abae740faf1dfdb.tar.bz2 skyhanni-0a95a791eb57a546fb5421594abae740faf1dfdb.zip | |
Internal Changes: Many small code cleanups (#1101)
Co-authored-by: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java')
82 files changed, 352 insertions, 339 deletions
diff --git a/src/main/java/SkyHanniInstallerFrame.java b/src/main/java/SkyHanniInstallerFrame.java index dee06da43..9381e9aef 100644 --- a/src/main/java/SkyHanniInstallerFrame.java +++ b/src/main/java/SkyHanniInstallerFrame.java @@ -642,25 +642,6 @@ public class SkyHanniInstallerFrame extends JFrame implements ActionListener, Mo return version; } -// private String getVersionFromMcmodInfo() { -// String version = ""; -// try { -// BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(getClass() -// .getClassLoader() -// .getResourceAsStream("mcmod.info"), "mcmod.info not found."))); -// while ((version = bufferedReader.readLine()) != null) { -// if (version.contains("\"version\": \"")) { -// version = version.split(Pattern.quote("\"version\": \""))[1]; -// version = version.substring(0, version.length() - 2); -// break; -// } -// } -// } catch (Exception ex) { -// // It's okay, I guess just don't use the version lol. -// } -// return version; -// } - private File getThisFile() { try { return new File(SkyHanniInstallerFrame.class diff --git a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt index 1e991605e..0077a6e83 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull +import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -46,10 +47,9 @@ object CollectionAPI { val stack = event.inventoryItems[4] ?: return loop@ for (line in stack.getLore()) { singleCounterPattern.matchMatcher(line) { - val counter = group("amount").replace(",", "").toLong() + val counter = group("amount").formatLong() val name = inventoryName.split(" ").dropLast(1).joinToString(" ") - val internalName = NEUItems.getInternalNameOrNull(name) ?: continue@loop - collectionValue[internalName] = counter + collectionValue[NEUInternalName.fromItemName(name)] = counter } } CollectionUpdateEvent().postAndCatch() @@ -59,7 +59,7 @@ object CollectionAPI { if (inventoryName == "Boss Collections") return for ((_, stack) in event.inventoryItems) { - var name = stack.name?.removeColor() ?: continue + var name = stack.name.removeColor() if (name.contains("Collections")) continue val lore = stack.getLore() @@ -71,9 +71,8 @@ object CollectionAPI { loop@ for (line in lore) { counterPattern.matchMatcher(line) { - val counter = group("amount").replace(",", "").toLong() - val internalName = NEUItems.getInternalNameOrNull(name) ?: continue@loop - collectionValue[internalName] = counter + val counter = group("amount").formatLong() + collectionValue[NEUInternalName.fromItemName(name)] = counter } } } diff --git a/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt index 0df046a65..64d905ccb 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt @@ -21,8 +21,9 @@ import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.cleanName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble +import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.NumberUtil.formatLongOrUserError -import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -170,7 +171,7 @@ object SkillAPI { val previousLine = stack.getLore()[lineIndex - 1] val progress = cleanLine.substring(cleanLine.lastIndexOf(' ') + 1) if (previousLine == "§7§8Max Skill level reached!") { - var totalXp = progress.formatNumber() + var totalXp = progress.formatLong() val minus = if (skillLevel == 50) 4_000_000 else if (skillLevel == 60) 7_000_000 else 0 totalXp -= minus val (overflowLevel, overflowCurrent, overflowNeeded, overflowTotal) = getSkillInfo( @@ -192,8 +193,8 @@ object SkillAPI { } } else { val splitProgress = progress.split("/") - val currentXp = splitProgress.first().formatNumber() - val neededXp = splitProgress.last().formatNumber() + val currentXp = splitProgress.first().formatLong() + val neededXp = splitProgress.last().formatLong() val levelingArray = levelArray() val levelXp = calculateLevelXp(levelingArray, skillLevel - 1).toLong() @@ -266,8 +267,8 @@ object SkillAPI { } private fun handleSkillPattern(matcher: Matcher, skillType: SkillType, skillInfo: SkillInfo) { - val currentXp = matcher.group("current").formatNumber() - val maxXp = matcher.group("needed").formatNumber() + val currentXp = matcher.group("current").formatLong() + val maxXp = matcher.group("needed").formatLong() val level = getLevelExact(maxXp) val (levelOverflow, currentOverflow, currentMaxOverflow, totalOverflow) = getSkillInfo( @@ -311,8 +312,7 @@ object SkillAPI { } } val existingLevel = getSkillInfo(skillType) ?: SkillInfo() - val xpPercentageS = matcher.group("progress").replace(",", "") - val xpPercentage = xpPercentageS.toFloatOrNull() ?: return + val xpPercentage = matcher.group("progress").formatDouble() val levelingArray = levelArray() val levelXp = calculateLevelXp(levelingArray, existingLevel.level - 1) val nextLevelDiff = levelingArray[tablistLevel]?.asDouble ?: 7_600_000.0 @@ -341,8 +341,8 @@ object SkillAPI { } private fun handleSkillPatternMultiplier(matcher: Matcher, skillType: SkillType, skillInfo: SkillInfo) { - val currentXp = matcher.group("current").formatNumber() - val maxXp = matcher.group("needed").formatNumber() + val currentXp = matcher.group("current").formatLong() + val maxXp = matcher.group("needed").formatLong() val level = getLevelExact(maxXp) val levelingArray = levelArray() val levelXp = calculateLevelXp(levelingArray, level - 1).toLong() + currentXp diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt index 138158ccb..64eac452b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt @@ -16,8 +16,7 @@ class GardenComposterUpgradesData { if (!GardenAPI.inGarden()) return if (event.inventoryName != "Composter Upgrades") return for (item in event.inventoryItems.values) { - val itemName = item.name ?: continue - ComposterUpgrade.regex.matchMatcher(itemName) { + ComposterUpgrade.regex.matchMatcher(item.name) { val name = group("name") |
