aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-02 14:08:43 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-02 14:08:43 +0100
commit017edfa6eaca6b682a68c16fc0a9c621ebaf1177 (patch)
tree01953452b6043374d384eb5024d11c006f52e8cb /src/main/java
parentbed5c3e71c36086b7dcdfaeb8db357ba28472ab9 (diff)
downloadskyhanni-017edfa6eaca6b682a68c16fc0a9c621ebaf1177.tar.gz
skyhanni-017edfa6eaca6b682a68c16fc0a9c621ebaf1177.tar.bz2
skyhanni-017edfa6eaca6b682a68c16fc0a9c621ebaf1177.zip
Show the price for copper inside the visitor gui.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Garden.java8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt22
2 files changed, 23 insertions, 7 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 d05b29442..a50d9201d 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
@@ -96,12 +96,18 @@ public class Garden {
public boolean visitorHighlight = true;
@Expose
- @ConfigOption(name = "Show Price", desc = "Show the bazaar price of the items required for the visitors.")
+ @ConfigOption(name = "Visitor Price", desc = "Show the bazaar price of the items required for the visitors.")
@ConfigEditorBoolean
@ConfigAccordionId(id = 1)
public boolean visitorShowPrice = true;
@Expose
+ @ConfigOption(name = "Copper Price", desc = "Show the price for copper inside the visitor gui.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean visitorCopperPrice = false;
+
+ @Expose
@ConfigOption(name = "Numbers", desc = "")
@ConfigEditorAccordion(id = 4)
public boolean numbers = false;
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 0a064401e..b9fb4ee5f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt
@@ -19,6 +19,7 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
import java.util.*
+import java.util.regex.Pattern
class GardenVisitorFeatures {
@@ -27,6 +28,7 @@ class GardenVisitorFeatures {
private var lastClickedNpc = 0
private var nearby = false
private var tick = 0
+ private val copperPattern = Pattern.compile(" §8\\+§c(.*) Copper")
private val config: Garden get() = SkyHanniMod.feature.garden
companion object {
@@ -134,21 +136,21 @@ class GardenVisitorFeatures {
val name = event.itemStack.name ?: return
if (name != "§aAccept Offer") return
- var i = 0
val list = event.toolTip
var totalPrice = 0.0
var amountDifferentItems = 0
- for (l in list) {
+ var endReached = false
+ for ((i, l) in list.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)"
}
- break
+ endReached = true
}
- if (i > 1) {
+ if (i > 1 && !endReached) {
val (itemName, amount) = ItemUtils.readItemAmount(line)
if (itemName != null) {
val lowestBin: Double
@@ -159,7 +161,7 @@ class GardenVisitorFeatures {
println(message)
LorenzUtils.error(message)
e.printStackTrace()
- continue
+ return
}
val price = lowestBin * amount
totalPrice += price
@@ -168,7 +170,15 @@ class GardenVisitorFeatures {
amountDifferentItems++
}
}
- i++
+
+ 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)"
+ }
+ }
}
}