Skip to content

Commit

Permalink
Add glacite to powder tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
bowser0000 committed Apr 14, 2024
1 parent 4f9e0a2 commit 3a3ceea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/main/java/me/Danker/features/PowderTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
public class PowderTracker {

public static StopWatch powderStopwatch = new StopWatch();
static int lastMithril = -1;
static int mithrilGained = 0;
static int lastGemstone = -1;
static int gemstoneGained = 0;
private static int lastMithril = -1;
private static int mithrilGained = 0;
private static int lastGemstone = -1;
private static int gemstoneGained = 0;
private static int lastGlacite = -1;
private static int glaciteGained = 0;

@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
Expand All @@ -44,14 +46,18 @@ public void onTick(TickEvent.ClientTickEvent event) {
for (NetworkPlayerInfo player : players) {
if (player == null || player.getDisplayName() == null) continue;
String text = player.getDisplayName().getUnformattedText();
if (text.startsWith(" Mithril Powder:")) {
if (text.startsWith(" Mithril: ")) {
int mithril = Integer.parseInt(text.replaceAll("\\D", ""));
if (powderStopwatch.isStarted() && !powderStopwatch.isSuspended() && lastMithril != -1 && mithril > lastMithril) mithrilGained += mithril - lastMithril;
lastMithril = mithril;
} else if (text.startsWith(" Gemstone Powder:")) {
} else if (text.startsWith(" Gemstone: ")) {
int gemstone = Integer.parseInt(text.replaceAll("\\D", ""));
if (powderStopwatch.isStarted() && !powderStopwatch.isSuspended() && lastGemstone != -1 && gemstone > lastGemstone) gemstoneGained += gemstone - lastGemstone;
lastGemstone = gemstone;
} else if (text.startsWith(" Glacite: ")) {
int glacite = Integer.parseInt(text.replaceAll("\\D", ""));
if (powderStopwatch.isStarted() && !powderStopwatch.isSuspended() && lastGlacite != -1 && glacite > lastGlacite) glaciteGained += glacite - lastGlacite;
lastGlacite = glacite;
}
}
}
Expand Down Expand Up @@ -80,6 +86,8 @@ public static void reset() {
mithrilGained = 0;
lastGemstone = -1;
gemstoneGained = 0;
lastGlacite = -1;
glaciteGained = 0;
}

public static class PowderTrackerHud extends Hud {
Expand All @@ -89,6 +97,8 @@ public static class PowderTrackerHud extends Hud {
EnumChatFormatting.DARK_GREEN + "Mithril Per Hour: 107,326\n" +
EnumChatFormatting.LIGHT_PURPLE + "Gemstone Gained: 101,299\n" +
EnumChatFormatting.LIGHT_PURPLE + "Gemstone Per Hour: 146,397\n" +
EnumChatFormatting.AQUA + "Glacite Gained: 123,456\n" +
EnumChatFormatting.AQUA + "Glacite Per Hour: 178,418\n" +
ModConfig.getColour(powderTrackerColour) + "Time Elapsed: " + Utils.getTimeBetween(0, 2491);

@Button(
Expand Down Expand Up @@ -149,7 +159,7 @@ protected void draw(UMatrixStack matrices, float x, float y, float scale, boolea
}

if (enabled && Utils.inSkyblock) {
if (!onlyInArea || (Utils.currentLocation == Location.DWARVEN_MINES || Utils.currentLocation == Location.CRYSTAL_HOLLOWS)) {
if (!onlyInArea || (Utils.currentLocation == Location.DWARVEN_MINES || Utils.currentLocation == Location.CRYSTAL_HOLLOWS || Utils.currentLocation == Location.MINESHAFT)) {
TextRenderer.drawHUDText(getText(), x, y, scale);
}
}
Expand All @@ -168,12 +178,15 @@ protected float getHeight(float scale, boolean example) {
String getText() {
int mithrilPerHour = (int) Math.round(mithrilGained / ((powderStopwatch.getTime() + 1) / 3600000d));
int gemstonePerHour = (int) Math.round(gemstoneGained / ((powderStopwatch.getTime() + 1) / 3600000d));
int glacitePerHour = (int) Math.round(glaciteGained / ((powderStopwatch.getTime() + 1) / 3600000d));

NumberFormat nf = NumberFormat.getIntegerInstance(Locale.US);
String powderTrackerText = EnumChatFormatting.DARK_GREEN + "Mithril Gained: " + nf.format(mithrilGained) + "\n" +
EnumChatFormatting.DARK_GREEN + "Mithril Per Hour: " + nf.format(mithrilPerHour) + "\n" +
EnumChatFormatting.LIGHT_PURPLE + "Gemstone Gained: " + nf.format(gemstoneGained) + "\n" +
EnumChatFormatting.LIGHT_PURPLE + "Gemstone Per Hour: " + nf.format(gemstonePerHour) + "\n" +
EnumChatFormatting.AQUA + "Glacite Gained: " + nf.format(glaciteGained) + "\n" +
EnumChatFormatting.AQUA + "Glacite Per Hour: " + nf.format(glacitePerHour) + "\n" +
ModConfig.getColour(powderTrackerColour) + "Time Elapsed: " + Utils.getTimeBetween(0, powderStopwatch.getTime() / 1000d);
if (!powderStopwatch.isStarted() || powderStopwatch.isSuspended()) {
powderTrackerText += "\n" + EnumChatFormatting.RED + "PAUSED";
Expand Down
1 change: 1 addition & 0 deletions src/main/java/me/Danker/locations/Location.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum Location {
HUB("Hub"),
KUUDRA("Kuudra"),
JERRY_WORKSHOP("Jerry's Workshop"),
MINESHAFT("Mineshaft"),
PARK("The Park"),
PRIVATE_ISLAND("Private Island"),
RIFT("The Rift"),
Expand Down

0 comments on commit 3a3ceea

Please sign in to comment.