Skip to content

Commit

Permalink
Merge branch 'refs/heads/beta' into fork/transfer_cooldown
Browse files Browse the repository at this point in the history
  • Loading branch information
hannibal002 committed Jun 9, 2024
2 parents 10c0e65 + 32806b6 commit 5880640
Show file tree
Hide file tree
Showing 11 changed files with 371 additions and 221 deletions.
9 changes: 5 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ ktlint_code_style = intellij_idea
ij_kotlin_name_count_to_use_star_import = 2147483647
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
ij_kotlin_enum_constants_wrap = split_into_lines
ij_kotlin_allow_trailing_comma_on_call_site = false
ij_kotlin_allow_trailing_comma_on_call_site = true
ij_kotlin_allow_trailing_comma = true
ij_kotlin_packages_to_use_import_on_demand = unset
ktlint_standard_chain-wrapping = always

ktlint_standard_multiline-if-else = disabled
ktlint_standard_no-empty-first-line-in-class-body = disabled
Expand All @@ -46,12 +48,11 @@ ktlint_standard_string-template = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled
ktlint_standard_context-receiver-wrapping = disabled
ktlint_standard_multiline-expression-wrapping = disabled
ktlint_standard_multiline-expression-wrapping = false
ktlint_standard_string-template-indent = disabled
ktlint_standard_no-trailing-spaces = disabled
ktlint_standard_function-signature = disabled
ktlint_standard_wrapping = disabled
ktlint_standard_wrapping = enabled

ktlint_standard_no-line-break-before-assignment = true
ktlint_standard_no-wildcard-imports = enabled
ktlint_standard_function-expression-body = disabled
16 changes: 10 additions & 6 deletions src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ object GardenCropMilestones {
private val patternGroup = RepoPattern.group("data.garden.milestone")
private val cropPattern by patternGroup.pattern(
"crop",
"§7Harvest §f(?<name>.*) §7on .*"
"§7Harvest §f(?<name>.*) §7on .*",
)
val totalPattern by patternGroup.pattern(
"total",
"§7Total: §a(?<name>.*)"
"§7Total: §a(?<name>.*)",
)

private val config get() = GardenAPI.config.cropMilestones
Expand Down Expand Up @@ -67,9 +67,10 @@ object GardenCropMilestones {
add(" §r§7§8+§d2 SkyHanni User Luck")
}

val cropName = crop.cropName
val messages = listOf(
"§r§3§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬§r",
" §r§b§lGARDEN MILESTONE §3${crop.cropName} §8$oldLevel➜§3$newLevel§r",
" §r§b§lGARDEN MILESTONE §3$cropName §8$oldLevel➜§3$newLevel§r",
if (goalReached)
listOf(
"",
Expand All @@ -80,13 +81,16 @@ object GardenCropMilestones {
"",
" §r§a§lREWARDS§r",
rewards.joinToString("\n"),
"§r§3§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬§r"
"§r§3§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬§r",
)

chat(messages.joinToString("\n"), false)

if (goalReached)
chat("§e§lYou have reached your milestone goal of §b§l${customGoalLevel} §e§lin the §b§l${crop.cropName} §e§lcrop!", false)
val message = "§e§lYou have reached your milestone goal of §b§l$customGoalLevel " +
"§e§lin the §b§l$cropName §e§lcrop!"
if (goalReached) {
chat(message, false)
}

SoundUtils.createSound("random.levelup", 1f, 1f).playSound()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object GardenCropMilestonesCommunityFix {
private val amountPattern by RepoPattern.pattern(
"data.garden.milestonefix.amount",
".*§e(?<having>.*)§6/§e(?<max>.*)"
".*§e(?<having>.*)§6/§e(?<max>.*)",
)

private var showWrongData = false
Expand Down Expand Up @@ -67,7 +67,7 @@ object GardenCropMilestonesCommunityFix {
ChatUtils.chat(
"Found §c${data.size} §ewrong crop milestone steps in the menu! " +
"Correct data got put into clipboard. " +
"Please share it on the §bSkyHanni Discord §ein the channel §b#share-data§e."
"Please share it on the §bSkyHanni Discord §ein the channel §b#share-data§e.",
)
OSUtils.copyToClipboard("```${data.joinToString("\n")}```")
} else {
Expand All @@ -93,8 +93,8 @@ object GardenCropMilestonesCommunityFix {
// debug("crop: $crop")
// debug("realTier: $realTier")

val guessNextMax = GardenCropMilestones.getCropsForTier(realTier + 1, crop) - GardenCropMilestones.getCropsForTier(realTier, crop)
// debug("guessNextMax: ${guessNextMax.addSeparators()}")
val guessNextMax = nextMax(realTier, crop)
// debug("guessNextMax: ${guessNextMax.addSeparators()}")
val nextMax = amountPattern.matchMatcher(next) {
group("max").formatLong()
} ?: return
Expand All @@ -114,7 +114,7 @@ object GardenCropMilestonesCommunityFix {
// debug("$crop total offf by: ${totalOffBy.addSeparators()}")
}

// fun debug(message: String) {
// fun debug(message: String) {
// if (SkyHanniMod.feature.dev.debug.enabled) {
// println(message)
// }
Expand Down Expand Up @@ -162,14 +162,17 @@ object GardenCropMilestonesCommunityFix {
}

private fun tryFix(crop: CropType, tier: Int, amount: Int): Boolean {
val guessNextMax = GardenCropMilestones.getCropsForTier(tier + 1, crop) - GardenCropMilestones.getCropsForTier(tier, crop)
val guessNextMax = nextMax(tier, crop)
if (guessNextMax.toInt() == amount) return false
GardenCropMilestones.cropMilestoneData = GardenCropMilestones.cropMilestoneData.editCopy {
fix(crop, this, tier, amount)
}
return true
}

private fun nextMax(tier: Int, crop: CropType): Long =
GardenCropMilestones.getCropsForTier(tier + 1, crop) - GardenCropMilestones.getCropsForTier(tier, crop)

private fun fix(crop: CropType, map: MutableMap<CropType, List<Int>>, tier: Int, amount: Int) {
map[crop] = map[crop]!!.editCopy {
this[tier] = amount
Expand Down
Loading

0 comments on commit 5880640

Please sign in to comment.