diff options
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/Garden.java | 26 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt | 102 |
2 files changed, 87 insertions, 41 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java index 74b874186..d433d401e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -333,7 +333,7 @@ public class Garden { @ConfigOption(name = "Set Default", desc = "Reset all keys to default.") @ConfigEditorButton(buttonText = "Default") @ConfigAccordionId(id = 8) - public Runnable keyBindPresetDefault = ()-> { + public Runnable keyBindPresetDefault = () -> { keyBindAttack = -100; keyBindLeft = Keyboard.KEY_A; keyBindRight = Keyboard.KEY_D; @@ -594,6 +594,7 @@ public class Garden { @ConfigEditorBoolean @ConfigAccordionId(id = 13) public boolean moneyPerHourAlwaysOn = false; + @Expose @ConfigOption( name = "Compact Mode", @@ -601,6 +602,7 @@ public class Garden { @ConfigEditorBoolean @ConfigAccordionId(id = 13) public boolean moneyPerHourCompact = false; + @Expose @ConfigOption( name = "Compact Price", @@ -608,13 +610,29 @@ public class Garden { @ConfigEditorBoolean @ConfigAccordionId(id = 13) public boolean moneyPerHourCompactPrice = false; + @Expose @ConfigOption( - name = "Advanced stats", - desc = "Show not only Sell Offer price but also Instant Sell price and NPC Sell price.") + name = "Use Custom", + desc = "Use the custom format below instead of classic -> §eSell Offer §7and other profiles -> §eNPC Price.") @ConfigEditorBoolean @ConfigAccordionId(id = 13) - public boolean moneyPerHourAdvancedStats = false; + public boolean moneyPerHourUseCustomFormat = false; + + @Expose + @ConfigOption( + name = "Custom Format", + desc = "Set what prices to show") + @ConfigEditorDraggableList( + exampleText = { + "§eSell Offer", + "§eInstant Sell", + "§eNPC Price" + }, + requireNonEmpty = true + ) + @ConfigAccordionId(id = 13) + public List<Integer> moneyPerHourCustomFormat = new ArrayList<>(Arrays.asList(0, 1, 2)); @Expose public Position moneyPerHourPos = new Position(16, -232, false, true); diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt index a09102033..1b94bd231 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi +import at.hannibal2.skyhanni.features.bazaar.BazaarData import at.hannibal2.skyhanni.features.garden.GardenAPI.Companion.getSpeed import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils @@ -60,9 +61,9 @@ class CropMoneyDisplay { val newDisplay = mutableListOf<List<Any>>() val title = if (config.moneyPerHourCompact) { - "§7Money/hour:" + "§7Money/Hour:" } else { - "§7Money per hour when selling:" + "§7Money per Hour when selling:" } if (!ready) { @@ -73,16 +74,8 @@ class CropMoneyDisplay { if (!hasCropInHand && !config.moneyPerHourAlwaysOn) return newDisplay + newDisplay.addAsSingletonList(fullTitle(title)) - newDisplay.addAsSingletonList( - if (config.moneyPerHourAdvancedStats) { - "$title §7(§eSell Offer§7/§eInstant Sell§7/§eNpc Price§7)" - } else if (LorenzUtils.noTradeMode) { - "$title §7(§eNpc Price§7)" - } else { - "$title §7(§eSell Offer§7)" - } - ) val moneyPerHourData = calculateMoneyPerHour() if (moneyPerHourData.isEmpty()) { @@ -100,7 +93,7 @@ class CropMoneyDisplay { } var number = 0 - val help = moneyPerHourData.mapValues { (_, value) -> value.max() } + val help = moneyPerHourData.mapValues { (_, value) -> value.max() } for (internalName in help.sortedDesc().keys) { number++ val cropName = cropNames[internalName]!! @@ -127,22 +120,13 @@ class CropMoneyDisplay { val coinsColor = if (isCurrent && config.moneyPerHourCompact) "§e" else "§6" val moneyArray = moneyPerHourData[internalName]!! - if (config.moneyPerHourAdvancedStats) { - for (price in moneyArray) { - val format = format(price) - list.add("$coinsColor$format") - list.add("§7/") - } - list.removeLast() - } else if (LorenzUtils.noTradeMode) { - // Show npc price - val format = format(moneyArray[2]) - list.add("$coinsColor$format") - } else { - val format = format(moneyArray[0]) + + for (price in moneyArray) { + val format = format(price) list.add("$coinsColor$format") + list.add("§7/") } - + list.removeLast() newDisplay.add(list) } @@ -150,13 +134,39 @@ class CropMoneyDisplay { return newDisplay } + private fun fullTitle(title: String): String { + val titleText: String + val nameList = mutableListOf<String>() + if (config.moneyPerHourUseCustomFormat) { + val map = mapOf( + 0 to "Sell Offer", + 1 to "Instant Sell", + 2 to "NPC Price", + ) + val list = mutableListOf<String>() + for (index in config.moneyPerHourCustomFormat) { + map[index]?.let { + list.add(it) + } + } + for (line in list) { + nameList.add("§e$line") + nameList.add("§7/") + } + nameList.removeLast() + titleText = nameList.joinToString("") + } else { + titleText = if (LorenzUtils.noTradeMode) "§eNPC Price" else "§eSell Offer" + } + return "$title §7($titleText§7)" + } + private fun format(moneyPerHour: Double) = if (config.moneyPerHourCompactPrice) { NumberUtil.format(moneyPerHour) } else { LorenzUtils.formatInteger(moneyPerHour.toLong()) } - // sell offer -> instant sell -> npc private fun calculateMoneyPerHour(): Map<String, Array<Double>> { val moneyPerHours = mutableMapOf<String, Array<Double>>() for ((internalName, amount) in multipliers) { @@ -169,20 +179,38 @@ class CropMoneyDisplay { val blocksPerHour = speedPerHr / amount.toDouble() val bazaarData = BazaarApi.getBazaarDataForInternalName(internalName) ?: continue - - val npcPrice = bazaarData.npcPrice * blocksPerHour -// if (LorenzUtils.noTradeMode) { -// moneyPerHours[internalName] = arrayOf(npcPrice) -// } else { - val sellOffer = bazaarData.buyPrice * blocksPerHour - val instantSell = bazaarData.sellPrice * blocksPerHour - moneyPerHours[internalName] = arrayOf(sellOffer, instantSell, npcPrice) -// } - + moneyPerHours[internalName] = formatNumbers(bazaarData, blocksPerHour) } return moneyPerHours } + private fun formatNumbers(bazaarData: BazaarData, blocksPerHour: Double): Array<Double> { + val npcPrice = bazaarData.npcPrice * blocksPerHour + val sellOffer = bazaarData.buyPrice * blocksPerHour + val instantSell = bazaarData.sellPrice * blocksPerHour + + return if (config.moneyPerHourUseCustomFormat) { + val map = mapOf( + 0 to sellOffer, + 1 to instantSell, + 2 to npcPrice, + ) + val newList = mutableListOf<Double>() + for (index in config.moneyPerHourCustomFormat) { + map[index]?.let { + newList.add(it) + } + } + newList.toTypedArray() + } else { + if (LorenzUtils.noTradeMode) { + arrayOf(npcPrice) + } else { + arrayOf(sellOffer) + } + } + } + private fun init() { if (loaded) return |