Skip to content

Commit

Permalink
Fix dungeon meter
Browse files Browse the repository at this point in the history
  • Loading branch information
bowser0000 committed Dec 20, 2023
1 parent 3dd15e4 commit afd60a5
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/main/java/me/Danker/features/MeterTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,17 @@ public void onTick(TickEvent.ClientTickEvent event) {
int progress;
int goal = 0;

if (StringUtils.stripControlCodes(lore.get(15)).equals("Selected Drop")) {
drop = lore.get(16);
String line = StringUtils.stripControlCodes(lore.get(19));
if (StringUtils.stripControlCodes(lore.get(13)).equals("Selected Drop")) {
drop = lore.get(14);
String line = StringUtils.stripControlCodes(lore.get(17));
progress = getProgressFromLine(line);
goal = getGoalFromLine(line);
} else {
progress = Integer.parseInt(StringUtils.stripControlCodes(lore.get(19)).replaceAll("\\D", ""));
try {
progress = Integer.parseInt(StringUtils.stripControlCodes(lore.get(17)).replaceAll("\\D", ""));
} catch (NumberFormatException ex) {
progress = 0;
}
}

JsonObject floorMeter = meter.getAsJsonObject(floor);
Expand Down Expand Up @@ -232,15 +236,24 @@ public static void save() {
}

static int getProgressFromLine(String line) {
return Integer.parseInt(line.substring(0, line.indexOf("/")).replaceAll("\\D", ""));
try {
return Integer.parseInt(line.substring(0, line.indexOf("/")).replaceAll("\\D", ""));
} catch (NumberFormatException ex) {
return 0;
}
}

static int getGoalFromLine(String line) {
String goalString = line.substring(line.indexOf("/") + 1);
if (goalString.endsWith("k")) {
return Integer.parseInt(goalString.replaceAll("\\D", "")) * 1000;
} else {
return Integer.parseInt(goalString.replaceAll("\\D", ""));

try {
if (goalString.endsWith("k")) {
return Integer.parseInt(goalString.replaceAll("\\D", "")) * 1000;
} else {
return Integer.parseInt(goalString.replaceAll("\\D", ""));
}
} catch (NumberFormatException ex) {
return 1;
}
}

Expand Down

0 comments on commit afd60a5

Please sign in to comment.