Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: Compact Farming Fortune Display #3119

Open
wants to merge 9 commits into
base: beta
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ public class FarmingFortuneConfig {
@FeatureToggle
public boolean display = false;

@Expose
@ConfigOption(name = "Compact Format", desc = "Compact the farming fortune display.")
@ConfigEditorBoolean
public boolean compactFormat = false;

@Expose
@ConfigOption(name = "Hide Missing Fortune Warnings", desc = "Hide missing fortune warnings from the display.")
@ConfigEditorBoolean
public boolean hideMissingFortuneWarnings = false;

@ConfigOption(name = "Farming Fortune Guide", desc = "Open a guide that breaks down your Farming Fortune.\n§eCommand: /ff")
@ConfigEditorButton(buttonText = "Open")
public Runnable open = FFGuideGUI::onCommand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,37 +163,51 @@ object FarmingFortuneDisplay {

var recentlySwitchedTool = lastToolSwitch.passedSince() < 1.5.seconds
val wrongTabCrop = GardenAPI.cropInHand != null && GardenAPI.cropInHand != currentCrop
val ffReduction = getPestFFReduction()

val farmingFortune = if (wrongTabCrop) {
(displayCrop.getLatestTrueFarmingFortune() ?: -1.0).also {
recentlySwitchedTool = false
}
} else getCurrentFarmingFortune()

list.add(
Renderable.string(
"§6Farming Fortune§7: §e" + if (!recentlySwitchedTool && farmingFortune != -1.0) {
farmingFortune.roundTo(0).addSeparators()
} else "§7" + (displayCrop.getLatestTrueFarmingFortune()?.addSeparators() ?: "?"),
),
)
val farmingFortuneText = if (config.compactFormat) "§6FF§7: " else "§6Farming Fortune§7: "
val fortuneColorCode = if (ffReduction > 0) "§c" else "§e"
val fortuneAmount = if (!recentlySwitchedTool && farmingFortune != -1.0) {
farmingFortune.roundTo(0).addSeparators()
} else "§7" + (displayCrop.getLatestTrueFarmingFortune()?.addSeparators() ?: "?")

list.add(Renderable.string(farmingFortuneText + fortuneColorCode + fortuneAmount))

add(Renderable.horizontalContainer(list))

val ffReduction = getPestFFReduction()
if (ffReduction > 0) {
add(Renderable.string("§cPests are reducing your fortune by §e$ffReduction%§c!"))
add(
Renderable.string(
if (config.compactFormat) "§cPests: §7-§e$ffReduction%"
else "§cPests are reducing your fortune by §e$ffReduction%§c!"
)
)
}

if (wrongTabCrop) {
var text = "§cBreak §e${GardenAPI.cropInHand?.cropName}§c to see"
if (farmingFortune != -1.0) text += " latest"
text += " fortune!"

if (wrongTabCrop && !config.hideMissingFortuneWarnings) {
val latest = if (farmingFortune != -1.0) " latest" else ""
val text = when {
config.compactFormat -> "§cInaccurate!"
else -> {
"§cBreak §e${GardenAPI.cropInHand?.cropName}§c to see" + latest + " fortune!"
}
}
add(Renderable.string(text))
}
}

private fun drawMissingFortuneDisplay(cropFortune: Boolean) = buildList {
if (config.hideMissingFortuneWarnings) return@buildList
if (config.compactFormat) {
add(Renderable.string("§cInaccurate!"))
return@buildList
}
if (cropFortune) {
add(
Renderable.clickAndHover(
Expand Down
Loading