diff options
Diffstat (limited to 'src/main')
4 files changed, 121 insertions, 66 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 a50d9201d..74f48da48 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -41,7 +41,7 @@ public class Garden { public boolean visitorTimer = false; @Expose - @ConfigOption(name = "Visitor Timer", desc = "Timer when the next visitor will appear," + + @ConfigOption(name = "Visitor Timer", desc = "Timer when the next visitor will appear, " + "and a number how many visitors are already waiting.") @ConfigEditorBoolean @ConfigAccordionId(id = 2) @@ -78,56 +78,68 @@ public class Garden { public boolean visitorNeedsOnlyWhenClose = false; @Expose - @ConfigOption(name = "Notification Chat", desc = "Show in chat when a new visitor is visiting your island.") - @ConfigEditorBoolean + @ConfigOption(name = "Visitor Inventory", desc = "") @ConfigAccordionId(id = 1) - public boolean visitorNotificationChat = true; + @ConfigEditorAccordion(id = 4) + public boolean visitorInventory = false; @Expose - @ConfigOption(name = "Notification Title", desc = "Show a title when a new visitor is visiting your island.") + @ConfigOption(name = "Visitor Price", desc = "Show the bazaar price of the items required for the visitors.") @ConfigEditorBoolean - @ConfigAccordionId(id = 1) - public boolean visitorNotificationTitle = true; + @ConfigAccordionId(id = 4) + public boolean visitorShowPrice = true; @Expose - @ConfigOption(name = "Highlight", desc = "Highlight visitor when the required items are in the inventory or the visitor is new and needs to checked what items it needs.") + @ConfigOption(name = "Amount and Time", desc = "Show the exact item amount and the remaining time when farmed manually. Especially useful for ironman.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 4) + public boolean visitorExactAmountAndTime = true; + + @Expose + @ConfigOption(name = "Copper Price", desc = "Show the price for copper inside the visitor gui.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 4) + public boolean visitorCopperPrice = false; + + @Expose + @ConfigOption(name = "Notification Chat", desc = "Show in chat when a new visitor is visiting your island.") @ConfigEditorBoolean @ConfigAccordionId(id = 1) - public boolean visitorHighlight = true; + public boolean visitorNotificationChat = true; @Expose - @ConfigOption(name = "Visitor Price", desc = "Show the bazaar price of the items required for the visitors.") + @ConfigOption(name = "Notification Title", desc = "Show a title when a new visitor is visiting your island.") @ConfigEditorBoolean @ConfigAccordionId(id = 1) - public boolean visitorShowPrice = true; + public boolean visitorNotificationTitle = true; @Expose - @ConfigOption(name = "Copper Price", desc = "Show the price for copper inside the visitor gui.") + @ConfigOption(name = "Highlight", desc = "Highlight visitor when the required items are in the inventory or the visitor is new and needs to checked what items it needs.") @ConfigEditorBoolean @ConfigAccordionId(id = 1) - public boolean visitorCopperPrice = false; + public boolean visitorHighlight = true; @Expose @ConfigOption(name = "Numbers", desc = "") - @ConfigEditorAccordion(id = 4) + @ConfigEditorAccordion(id = 5) public boolean numbers = false; @Expose @ConfigOption(name = "Crop Milestone", desc = "Show the number of crop milestones in the inventory.") @ConfigEditorBoolean - @ConfigAccordionId(id = 4) + @ConfigAccordionId(id = 5) public boolean numberCropMilestone = true; @Expose @ConfigOption(name = "Crop Upgrades", desc = "Show the number of upgrades in the crop upgrades inventory.") @ConfigEditorBoolean - @ConfigAccordionId(id = 4) + @ConfigAccordionId(id = 5) public boolean numberCropUpgrades = true; @Expose - @ConfigOption(name = "Crop Milestone", desc = "") - @ConfigEditorAccordion(id = 5) - public boolean cropMilestone = false; + @ConfigOption(name = "Crop Milestones", desc = "") + @ConfigEditorAccordion(id = 6) + public boolean cropMilestones = false; @Expose @ConfigOption( @@ -136,19 +148,19 @@ public class Garden { "§cRequires a tool with either a counter or cultivating enchantment." ) @ConfigEditorBoolean - @ConfigAccordionId(id = 5) + @ConfigAccordionId(id = 6) public boolean cropMilestoneProgress = true; @Expose @ConfigOption(name = "Display Position", desc = "") @ConfigEditorButton(runnableId = "cropMilestoneProgress", buttonText = "Edit") - @ConfigAccordionId(id = 5) + @ConfigAccordionId(id = 6) public Position cropMilestoneProgressDisplayPos = new Position(-363, 12, false, true); @Expose @ConfigOption(name = "Best Crop", desc = "") - @ConfigAccordionId(id = 5) - @ConfigEditorAccordion(id = 6) + @ConfigAccordionId(id = 6) + @ConfigEditorAccordion(id = 7) public boolean cropMilestoneNext = false; @Expose @@ -156,13 +168,13 @@ public class Garden { name = "Best Display", desc = "Lists all crops and their ETA till next milestone. Sorts for best crop for getting garden level or skyblock level.") @ConfigEditorBoolean - @ConfigAccordionId(id = 6) + @ConfigAccordionId(id = 7) public boolean cropMilestoneBestDisplay = true; @Expose @ConfigOption(name = "Sort Type", desc = "Sort the crops by either garden exp or by skyblock exp.") @ConfigEditorDropdown(values = {"Garden Exp", "SkyBlock Exp"}) - @ConfigAccordionId(id = 6) + @ConfigAccordionId(id = 7) public int cropMilestoneBestType = 0; @Expose @@ -172,7 +184,7 @@ public class Garden { maxValue = 10, minStep = 1 ) - @ConfigAccordionId(id = 6) + @ConfigAccordionId(id = 7) public int cropMilestoneShowOnlyBest = 10; @Expose @@ -180,13 +192,13 @@ public class Garden { name = "Always On", desc = "Show the Best Display always while on the garden.") @ConfigEditorBoolean - @ConfigAccordionId(id = 6) + @ConfigAccordionId(id = 7) public boolean cropMilestoneBestAlwaysOn = false; @Expose @ConfigOption(name = "Display Position", desc = "") @ConfigEditorButton(runnableId = "cropMilestoneNext", buttonText = "Edit") - @ConfigAccordionId(id = 6) + @ConfigAccordionId(id = 7) public Position cropMilestoneNextDisplayPos = new Position(-112, -143, false, true); @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java index 81d2de77b..315be5382 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java @@ -38,4 +38,7 @@ public class Hidden { @Expose public Map<String, Long> gardenTimeTillNextCropMilestone = new HashMap<>(); + + @Expose + public Map<String, Integer> gardenCropsPerSecond = new HashMap<>(); } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt index a57beed0e..62fced2f5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt @@ -30,6 +30,10 @@ class GardenCropMilestoneDisplay { private val timeTillNextCrop: MutableMap<String, Long> get() = SkyHanniMod.feature.hidden.gardenTimeTillNextCropMilestone private val config: Garden get() = SkyHanniMod.feature.garden + companion object { + val cropsPerSecond: MutableMap<String, Int> get() = SkyHanniMod.feature.hidden.gardenCropsPerSecond + } + @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { if (!isEnabled()) return @@ -45,6 +49,11 @@ class GardenCropMilestoneDisplay { if (GardenCropMilestones.cropCounter.values.sum() == 0L) { needsInventory = true } + if (cropsPerSecond.isEmpty()) { + for (key in GardenCropMilestones.cropCounter.keys) { + cropsPerSecond[key] = -1 + } + } } @SubscribeEvent @@ -237,12 +246,13 @@ class GardenCropMilestoneDisplay { progressDisplay.add(Collections.singletonList("§e$haveFormat§8/§e$needFormat")) if (averageSpeedPerSecond != 0) { + cropsPerSecond[it] = averageSpeedPerSecond val missing = need - have val missingTimeSeconds = missing / averageSpeedPerSecond val millis = missingTimeSeconds * 1000 timeTillNextCrop[it] = millis val duration = TimeUtils.formatDuration(millis) - progressDisplay.add(Collections.singletonList("§7In §b$duration")) + progressDisplay.add(Collections.singletonList("§7in §b$duration")) val format = LorenzUtils.formatInteger(averageSpeedPerSecond * 60) progressDisplay.add(Collections.singletonList("§7Crops/minute§8: §e$format")) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt index a43f9671f..3eb69a2ef 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -130,55 +130,85 @@ class GardenVisitorFeatures { fun onTooltip(event: ItemTooltipEvent) { if (!isEnabled()) return if (!nearby) return - if (!config.visitorShowPrice) return if (!inVisitorInventory) return val name = event.itemStack.name ?: return if (name != "§aAccept Offer") return - val list = event.toolTip - var totalPrice = 0.0 - var amountDifferentItems = 0 - var endReached = false - for ((i, l) in list.toMutableList().withIndex()) { - val line = l.substring(4) - if (line == "") { - if (amountDifferentItems > 1) { - val format = NumberUtil.format(totalPrice) - list[1] = list[1] + "$line §f(§6Total §6$format§f)" + // TODO remove + try { + val list = event.toolTip + var totalPrice = 0.0 + var amountItems = 0 + var endReached = false + for ((i, l) in list.toMutableList().withIndex()) { + val line = l.substring(4) + if (line == "") { + if (config.visitorShowPrice) { + if (amountItems > 1) { + val format = NumberUtil.format(totalPrice) + list[1] = list[1] + "$line §f(§6Total §6$format§f)" + } + } + endReached = true } - endReached = true - } - if (i > 1 && !endReached) { - val (itemName, amount) = ItemUtils.readItemAmount(line) - if (itemName != null) { - val internalName: String - try { - internalName = NEUItems.getInternalName(itemName) - } catch (e: NullPointerException) { - val message = "internal name is null: '$itemName'" - println(message) - LorenzUtils.error(message) - e.printStackTrace() - return + // Items Required + if (i > 1 && !endReached) { + val (itemName, amount) = ItemUtils.readItemAmount(line) + if (itemName != null) { + val internalName: String + try { + internalName = NEUItems.getInternalName(itemName) + } catch (e: NullPointerException) { + val message = "internal name is null: '$itemName'" + println(message) + LorenzUtils.error(message) + e.printStackTrace() + return + } + if (config.visitorShowPrice) { + val price = NEUItems.getPrice(internalName) * amount + totalPrice += price + val format = NumberUtil.format(price) + list[i] = "$line §7(§6$format§7)" + } + amountItems++ + + if (config.visitorExactAmountAndTime) { + val multiplier = NEUItems.getMultiplier(internalName) + val rawName = NEUItems.getItemStack(multiplier.first).name ?: continue + val crop = rawName.removeColor() + val cropAmount = multiplier.second.toLong() * amount + GardenCropMilestoneDisplay.cropsPerSecond[crop]?.let { + val formatAmount = LorenzUtils.formatInteger(cropAmount) + val formatName = "§e${formatAmount}§7x $crop " + val formatSpeed = if (it != -1) { + val missingTimeSeconds = cropAmount / it + val duration = TimeUtils.formatDuration(missingTimeSeconds * 1000) + "in §b$duration" + } else { + "§cno speed data!" + } + list.add(i + amountItems, " §7- $formatName($formatSpeed§7)") + } + } } - val price = NEUItems.getPrice(internalName) * amount - totalPrice += price - val format = NumberUtil.format(price) - list[i] = "$line §7(§6$format§7)" - amountDifferentItems++ } - } - if (config.visitorCopperPrice) { - val matcher = copperPattern.matcher(line) - if (matcher.matches()) { - val coppers = matcher.group(1).replace(",", "").toInt() - val pricePerCopper = NumberUtil.format((totalPrice / coppers).toInt()) - list[i] = list[i] + " §f(§7Copper price §6$pricePerCopper§f)" + if (config.visitorCopperPrice) { + val matcher = copperPattern.matcher(line) + if (matcher.matches()) { + val coppers = matcher.group(1).replace(",", "").toInt() + val pricePerCopper = NumberUtil.format((totalPrice / coppers).toInt()) + list[i] = list[i] + " §f(§7Copper price §6$pricePerCopper§f)" + } } } + + } catch (e: Exception) { + e.printStackTrace() + LorenzUtils.debug("crash!") } } |