aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/location
diff options
context:
space:
mode:
authorThatGravyBoat <thatgravyboat@gmail.com>2021-07-11 18:57:24 -0230
committerThatGravyBoat <thatgravyboat@gmail.com>2021-07-11 18:57:24 -0230
commit3a1917c8a0af4157cc1e6d5f3986e89377f245d8 (patch)
tree0a25fdc3ad1fc48da3f0d06c501f772ac9cfc353 /src/main/java/com/thatgravyboat/skyblockhud/location
parent5a98a98dfc0009599b90280ae3a1f166de21e6e8 (diff)
downloadSkyblockHud-Death-Defied-3a1917c8a0af4157cc1e6d5f3986e89377f245d8.tar.gz
SkyblockHud-Death-Defied-3a1917c8a0af4157cc1e6d5f3986e89377f245d8.tar.bz2
SkyblockHud-Death-Defied-3a1917c8a0af4157cc1e6d5f3986e89377f245d8.zip
Added Mining Overlay including drill bar and heat bar
Added mana cost display Update Location Stuff Added new mining events stopped scoreboard logging spam removed missing location logging as hypixel dumb and sends the wrong thing once and a while causing it to log useless stuff. Added DEV Commands
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/location')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java95
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java11
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java13
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java10
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java157
5 files changed, 172 insertions, 114 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java
deleted file mode 100644
index 3b17899..0000000
--- a/src/main/java/com/thatgravyboat/skyblockhud/location/DwarvenMineHandler.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package com.thatgravyboat.skyblockhud.location;
-
-import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent;
-import com.thatgravyboat.skyblockhud.api.events.SidebarPostEvent;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.util.Arrays;
-import java.util.Locale;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-
-public class DwarvenMineHandler {
-
- public enum Event {
- NONE(0, "Unknown"),
- TICKET(107, "Raffle"),
- GOBLIN(99, "Goblin Raid");
-
- public int x;
- public String displayName;
-
- Event(int x, String displayName) {
- this.x = x;
- this.displayName = displayName;
- }
- }
-
- public static int mithril;
-
- public static int eventMax;
- public static int eventProgress;
- public static Event currentEvent;
-
- private static final DecimalFormat formatter = new DecimalFormat("#,###", DecimalFormatSymbols.getInstance(Locale.CANADA));
-
- public static String getMithrilFormatted() {
- String output = formatter.format(mithril);
- if (output.equals(".0")) output = "0.0"; else if (output.equals(",0")) output = "0,0";
- return output;
- }
-
- public static void parseMithril(String line) {
- try {
- mithril = Integer.parseInt(line.toLowerCase().replace("mithril powder:", "").trim());
- } catch (Exception ignored) {}
- }
-
- @SubscribeEvent
- public void onSidebarLineUpdate(SidebarLineUpdateEvent event) {
- if (event.formattedLine.toLowerCase().contains("mithril")) {
- try {
- mithril = Integer.parseInt(event.formattedLine.toLowerCase().replace("mithril:", "").trim());
- } catch (Exception ignored) {}
- }
- if (event.formattedLine.toLowerCase().contains("event")) {
- if (event.formattedLine.toLowerCase().contains("raffle")) {
- DwarvenMineHandler.currentEvent = Event.TICKET;
- } else if (event.formattedLine.toLowerCase().contains("goblin raid")) {
- DwarvenMineHandler.currentEvent = Event.GOBLIN;
- }
- }
- if (DwarvenMineHandler.currentEvent != Event.NONE) {
- if (DwarvenMineHandler.currentEvent == Event.TICKET && event.formattedLine.toLowerCase().contains("tickets:")) {
- if (event.formattedLine.toLowerCase().contains("pool:")) {
- try {
- eventMax = Integer.parseInt(event.formattedLine.toLowerCase().replace("pool:", "").trim().split("/")[0].trim());
- } catch (Exception ignored) {}
- } else if (event.formattedLine.toLowerCase().contains("tickets:")) {
- try {
- eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("tickets:", "").split("\\(")[0].trim());
- } catch (Exception ignored) {}
- }
- } else if (DwarvenMineHandler.currentEvent == Event.GOBLIN) {
- if (event.formattedLine.toLowerCase().contains("remaining:")) {
- try {
- eventMax = Integer.parseInt(event.formattedLine.toLowerCase().replace("goblins", "").replace("remaining:", "").trim());
- } catch (Exception ignored) {}
- } else if (event.formattedLine.toLowerCase().contains("your kills:") && !event.formattedLine.toLowerCase().contains("(")) {
- try {
- eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("your kills:", "").trim());
- } catch (Exception ignored) {}
- }
- }
- }
- }
-
- @SubscribeEvent
- public void onSidebarPost(SidebarPostEvent event) {
- String arrayString = Arrays.toString(event.arrayScores);
- if (!arrayString.toLowerCase().contains("event:")) {
- DwarvenMineHandler.currentEvent = Event.NONE;
- DwarvenMineHandler.eventProgress = 0;
- DwarvenMineHandler.eventMax = 0;
- }
- }
-}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java
index a337f3d..f37a22d 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java
@@ -1,9 +1,9 @@
package com.thatgravyboat.skyblockhud.location;
-import static com.thatgravyboat.skyblockhud.handlers.MapHandler.Maps;
-
import com.thatgravyboat.skyblockhud.handlers.MapHandler;
+import static com.thatgravyboat.skyblockhud.handlers.MapHandler.Maps;
+
public enum LocationCategory {
ERROR("error", 34),
ISLAND("island", 43),
@@ -19,7 +19,7 @@ public enum LocationCategory {
JERRY("jerry", 59),
THEEND("the_end", 123),
DWARVENMINES("dwarven_mines", 131, Maps.DWARVEN),
- CRYSTALHOLLOWS("crystal_hollows", 131);
+ CRYSTALHOLLOWS("crystal_hollows", 139);
private final String name;
private final int texturePos;
@@ -46,4 +46,9 @@ public enum LocationCategory {
public MapHandler.Maps getMap() {
return this.map;
}
+
+ public boolean isMiningCategory() {
+ return this == LocationCategory.DWARVENMINES || this == LocationCategory.CRYSTALHOLLOWS;
+ }
+
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java
index bf55db6..6abc7b7 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java
@@ -1,15 +1,13 @@
package com.thatgravyboat.skyblockhud.location;
import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import java.util.Locale;
+
public class LocationHandler {
private static Locations currentLocation = Locations.NONE;
- private static final List<String> UndocumentedLocations = new ArrayList<>();
@SubscribeEvent
public void onSidebarLineUpdate(SidebarLineUpdateEvent event) {
@@ -41,11 +39,4 @@ public class LocationHandler {
currentLocation = Locations.CATACOMBS;
} else setCurrentLocation(location.replaceAll("[^A-Za-z0-9]", ""));
}
-
- public static void reportUndocumentedLocation(String locationId) {
- if (!UndocumentedLocations.contains(locationId)) {
- UndocumentedLocations.add(locationId);
- System.out.println("Missing Location value for: " + locationId);
- }
- }
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java b/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java
index f887b1d..722d9f9 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java
@@ -114,14 +114,15 @@ public enum Locations {
JUNGLETEMPLE("jungletemple", "Jungle Temple", LocationCategory.CRYSTALHOLLOWS),
MITHRILDEPOSITS("mithrildeposits", "Mithril Deposits", LocationCategory.CRYSTALHOLLOWS),
MINESOFDIVAN("minesofdivan", "Mines of Divan", LocationCategory.CRYSTALHOLLOWS),
- MAMGAFIELDS("magmafields", "Magma Fields", LocationCategory.CRYSTALHOLLOWS),
- KHAZADDM("khzaddm", "Khazad-dûm", LocationCategory.CRYSTALHOLLOWS),
+ MAGMAFIELDS("magmafields", "Magma Fields", LocationCategory.CRYSTALHOLLOWS),
+ KHAZADDM("khzaddm", "Khazad-d\u00FBm", LocationCategory.CRYSTALHOLLOWS),
GOBLINHOLDOUT("goblinholdout", "Goblin Holdout", LocationCategory.CRYSTALHOLLOWS),
GOBLINQUEENSDEN("goblinqueensden", "Goblin Queens Den", LocationCategory.CRYSTALHOLLOWS),
- PERCURSORREMNANTS("precursorremnants", "Precursor Remnants", LocationCategory.CRYSTALHOLLOWS),
+ PRECURSORREMNANTS("precursorremnants", "Precursor Remnants", LocationCategory.CRYSTALHOLLOWS),
LOSTPRECURSORCITY("lostprecursorcity", "Lost Precursor City", LocationCategory.CRYSTALHOLLOWS),
CRYSTALNUCLEUS("crystalnucleus", "Crystal Nucleus", LocationCategory.CRYSTALHOLLOWS),
- CRYSTALHOLLOWS("crystalhollows", "Crystal Hollows", LocationCategory.CRYSTALHOLLOWS);
+ CRYSTALHOLLOWS("crystalhollows", "Crystal Hollows", LocationCategory.CRYSTALHOLLOWS),
+ FAIRYGROTTO("fairygrotto", "Fairy Grotto", LocationCategory.CRYSTALHOLLOWS);
private final String name;
private final String displayName;
@@ -149,7 +150,6 @@ public enum Locations {
try {
return Locations.valueOf(id.replace(" ", "").toUpperCase());
} catch (IllegalArgumentException ex) {
- LocationHandler.reportUndocumentedLocation(id);
return DEFAULT;
}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java
new file mode 100644
index 0000000..1e1a065
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java
@@ -0,0 +1,157 @@
+package com.thatgravyboat.skyblockhud.location;
+
+import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent;
+import com.thatgravyboat.skyblockhud.api.events.SidebarPostEvent;
+import com.thatgravyboat.skyblockhud.overlay.MiningHud;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+
+import java.math.RoundingMode;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.Arrays;
+import java.util.Locale;
+
+public class MinesHandler {
+
+ public enum Event {
+ NONE(0, "Unknown", false, false),
+ TICKET(107, "Raffle", true, true),
+ GOBLIN(99, "Goblin Raid", true, true),
+ WIND(107, "Gone With The Wind", false, false),
+ TOGETHER(107, "Better Together", false, true);
+
+ public int x;
+ public String displayName;
+ public boolean needsMax;
+ public boolean display;
+
+ Event(int x, String displayName, boolean needsMax, boolean display) {
+ this.x = x;
+ this.displayName = displayName;
+ this.needsMax = needsMax;
+ this.display = display;
+ }
+ }
+
+ public static int mithril;
+ public static int gemstone;
+
+ public static int eventMax;
+ public static int eventProgress;
+ public static Event currentEvent;
+
+ private static final DecimalFormat NORMAL_FORMATTER = new DecimalFormat("#,###", DecimalFormatSymbols.getInstance(Locale.CANADA));
+ private static final DecimalFormat SHORT_FORMATTER = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.CANADA));
+
+ static {
+ SHORT_FORMATTER.setRoundingMode(RoundingMode.FLOOR);
+ }
+
+ public static String getMithrilFormatted() {
+ String output = NORMAL_FORMATTER.format(mithril);
+ if (output.equals(".0")) output = "0.0"; else if (output.equals(",0")) output = "0,0";
+ return output;
+ }
+
+ public static String getMithrilShortFormatted() {
+ return mithril > 999 ? SHORT_FORMATTER.format((double) mithril / 1000) + "k" : String.valueOf(mithril);
+ }
+
+ public static String getGemstoneFormatted() {
+ String output = NORMAL_FORMATTER.format(gemstone);
+ if (output.equals(".0")) output = "0.0"; else if (output.equals(",0")) output = "0,0";
+ return output;
+ }
+
+ public static String getGemstoneShortFormatted() {
+ return gemstone > 999 ? SHORT_FORMATTER.format((double) gemstone / 1000) + "k" : String.valueOf(gemstone);
+ }
+
+ public static void parseMithril(String line) {
+ try {
+ mithril = Integer.parseInt(line.toLowerCase().replace("mithril powder:", "").trim());
+ } catch (Exception ignored) {}
+ }
+
+ public static void parseGemstone(String line) {
+ try {
+ gemstone = Integer.parseInt(line.toLowerCase().replace("gemstone powder:", "").trim());
+ } catch (Exception ignored) {}
+ }
+
+ @SubscribeEvent
+ public void onSidebarLineUpdate(SidebarLineUpdateEvent event) {
+ if (event.formattedLine.toLowerCase().contains("heat")){
+ try {
+ MiningHud.setHeat(Integer.parseInt(event.formattedLine.toLowerCase().replace("heat:", "").trim()));
+ } catch (Exception ignored) {}
+ }
+ if (event.formattedLine.toLowerCase().contains("mithril")) {
+ try {
+ mithril = Integer.parseInt(event.formattedLine.toLowerCase().replace("mithril:", "").trim());
+ } catch (Exception ignored) {}
+ }
+ if (event.formattedLine.toLowerCase().contains("gemstone")) {
+ try {
+ gemstone = Integer.parseInt(event.formattedLine.toLowerCase().replace("gemstone:", "").trim());
+ } catch (Exception ignored) {}
+ }
+ if (event.formattedLine.toLowerCase().contains("event")) {
+ if (event.formattedLine.toLowerCase().contains("raffle")) {
+ MinesHandler.currentEvent = Event.TICKET;
+ } else if (event.formattedLine.toLowerCase().contains("goblin raid")) {
+ MinesHandler.currentEvent = Event.GOBLIN;
+ }
+ }
+ if (event.formattedLine.equalsIgnoreCase("wind compass")) {
+ MinesHandler.currentEvent = Event.WIND;
+ }
+ if (event.formattedLine.equalsIgnoreCase("nearby players")){
+ MinesHandler.currentEvent = Event.TOGETHER;
+ try {
+ MinesHandler.eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("nearby players", ""));
+ } catch (Exception ignored) {}
+ }
+
+ if (MinesHandler.currentEvent != Event.NONE) {
+ if (MinesHandler.currentEvent == Event.TICKET && event.formattedLine.toLowerCase().contains("tickets:")) {
+ if (event.formattedLine.toLowerCase().contains("pool:")) {
+ try {
+ eventMax = Integer.parseInt(event.formattedLine.toLowerCase().replace("pool:", "").trim().split("/")[0].trim());
+ } catch (Exception ignored) {}
+ } else if (event.formattedLine.toLowerCase().contains("tickets:")) {
+ try {
+ eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("tickets:", "").split("\\(")[0].trim());
+ } catch (Exception ignored) {}
+ }
+ } else if (MinesHandler.currentEvent == Event.GOBLIN) {
+ if (event.formattedLine.toLowerCase().contains("remaining:")) {
+ try {
+ eventMax = Integer.parseInt(event.formattedLine.toLowerCase().replace("goblins", "").replace("remaining:", "").trim());
+ } catch (Exception ignored) {}
+ } else if (event.formattedLine.toLowerCase().contains("your kills:") && !event.formattedLine.toLowerCase().contains("(")) {
+ try {
+ eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("your kills:", "").trim());
+ } catch (Exception ignored) {}
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onSidebarPost(SidebarPostEvent event) {
+ String arrayString = Arrays.toString(event.arrayScores);
+ boolean hasEvent = arrayString.toLowerCase().contains("event:");
+ boolean hasWind = arrayString.toLowerCase().contains("wind compass");
+ boolean hasNearbyPlayers = arrayString.toLowerCase().contains("nearby players");
+
+ if (!hasEvent && !hasWind && !hasNearbyPlayers) {
+ MinesHandler.currentEvent = Event.NONE;
+ MinesHandler.eventProgress = 0;
+ MinesHandler.eventMax = 0;
+ }
+ if (!arrayString.toLowerCase().contains("heat:")){
+ MiningHud.setHeat(0);
+ }
+ }
+}