aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-01-23 20:13:56 +0100
committerGitHub <noreply@github.com>2024-01-23 20:13:56 +0100
commit25b0c0b8dc2776c2649c3e91a718093c23745aa4 (patch)
treea93a9f336712cc44a114b4d8e3052df9f07ced9f /src
parent3710093b9d386e4f161ba2539c888cab27544928 (diff)
downloadNotEnoughUpdates-25b0c0b8dc2776c2649c3e91a718093c23745aa4.tar.gz
NotEnoughUpdates-25b0c0b8dc2776c2649c3e91a718093c23745aa4.tar.bz2
NotEnoughUpdates-25b0c0b8dc2776c2649c3e91a718093c23745aa4.zip
Fix RNG Meter Progress (#1009)
* Fix RNG Meter Progress * Fix some RNG meter values not being detected * Fix nearly full RNG meters
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipRngListener.java24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipRngListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipRngListener.java
index 7c10b86e..b6a88d88 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipRngListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipRngListener.java
@@ -40,6 +40,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -55,8 +56,9 @@ public class ItemTooltipRngListener {
private final Pattern ODDS_PATTERN = Pattern.compile("§5§o§7Odds: (.+) §7\\(§7(.*)%\\)");
private final Pattern ODDS_SELECTED_PATTERN = Pattern.compile("§5§o§7Odds: (.+) §7\\(§8§m(.*)%§r §7(.+)%\\)");
- private final Pattern RUNS_PATTERN = Pattern.compile("§5§o§7(Dungeon Score|Slayer XP): §d(.*)§5/§d(.+)");
- private final Pattern RUNS_SELECTED_PATTERN = Pattern.compile("§5§o§d-(.+)- §d(.*)§5/§d(.+)");
+ private final Pattern RUNS_PATTERN = Pattern.compile("§5§o§7(?:Dungeon Score|Slayer XP): §d(.*)§5/§d(.+)");
+ private final Pattern RUNS_SELECTED_PATTERN = Pattern.compile(
+ "(?:§5§o)?§d§l§m *(?:§f§l§m *)?§r §d([0-9,]+)§5/§d([0-9kKmM,.]+)");
private final Pattern SLAYER_INVENTORY_TITLE_PATTERN = Pattern.compile("(.+) RNG Meter");
@@ -73,7 +75,9 @@ public class ItemTooltipRngListener {
public void onItemTooltip(ItemTooltipEvent event) {
if (!neu.isOnSkyblock()) return;
if (event.toolTip == null) return;
- if (!Utils.getOpenChestName().endsWith(" RNG Meter") && !slayerData.containsKey(Utils.getOpenChestName())) return;
+ if (!Utils.getOpenChestName().endsWith(" RNG Meter")
+ && !slayerData.containsKey(Utils.getOpenChestName())
+ && !ItemUtils.getLore(event.itemStack).contains("§dRNG Meter")) return;
List<String> newToolTip = new ArrayList<>();
@@ -100,14 +104,14 @@ public class ItemTooltipRngListener {
if (m != null) {
int having;
try {
- having = Calculator.calculate(m.group(2).replace(",", "")).intValue();
+ having = Calculator.calculate(m.group(1).replace(",", "").toLowerCase(Locale.ROOT)).intValue();
} catch (Calculator.CalculatorException e) {
having = -1;
}
int needed;
try {
- needed = Calculator.calculate(m.group(3).replace(",", "")).intValue();
+ needed = Calculator.calculate(m.group(2).replace(",", "").toLowerCase(Locale.ROOT)).intValue();
} catch (Calculator.CalculatorException e) {
needed = -1;
}
@@ -140,7 +144,14 @@ public class ItemTooltipRngListener {
event.toolTip.addAll(newToolTip);
}
- private String getFormatCoinsPer(ItemStack stack, int needed, int multiplier, int amountPerTier, int cost, String label) {
+ private String getFormatCoinsPer(
+ ItemStack stack,
+ int needed,
+ int multiplier,
+ int amountPerTier,
+ int cost,
+ String label
+ ) {
String internalName = neu.manager.createItemResolutionQuery().withItemStack(stack).resolveInternalName();
double profit = neu.manager.auctionManager.getBazaarOrBin(internalName, false) * amountPerTier;
if (profit <= 0) return null;
@@ -227,7 +238,6 @@ public class ItemTooltipRngListener {
return;
}
-
List<Integer> defaultSlayerExp = new ArrayList<>();
for (JsonElement element : leveling.get("slayer_boss_xp").getAsJsonArray()) {
defaultSlayerExp.add(element.getAsInt());