aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java
diff options
context:
space:
mode:
authorThatGravyBoat <thatgravyboat@gmail.com>2021-07-06 15:10:29 -0230
committerThatGravyBoat <thatgravyboat@gmail.com>2021-07-06 15:10:29 -0230
commit6d8e1e5659f64a4f9ba86d6ab5bbc8e688faf22a (patch)
tree7451e53ceeae3c324d83a7faba83ce80005e6f23 /src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java
downloadskyblockhud-6d8e1e5659f64a4f9ba86d6ab5bbc8e688faf22a.tar.gz
skyblockhud-6d8e1e5659f64a4f9ba86d6ab5bbc8e688faf22a.tar.bz2
skyblockhud-6d8e1e5659f64a4f9ba86d6ab5bbc8e688faf22a.zip
Initial Commit
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java
new file mode 100644
index 0000000..274baf8
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java
@@ -0,0 +1,54 @@
+package com.thatgravyboat.skyblockhud.location;
+
+import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+
+import java.util.ArrayList;
+import java.util.List;
+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){
+ if (event.rawLine.contains("\u23E3")) {
+ String objectiveName = event.objective.getDisplayName().replaceAll("(?i)\\u00A7.", "");
+ if (objectiveName.toLowerCase(Locale.ENGLISH).endsWith("guest")){
+ LocationHandler.setCurrentLocation(Locations.GUESTISLAND);
+ }else {
+ LocationHandler.handleLocation(event.formattedLine);
+ }
+ }
+ }
+
+ public static void setCurrentLocation(String location){
+ currentLocation = Locations.get(location);
+ }
+
+ public static void setCurrentLocation(Locations location){
+ currentLocation = location;
+ }
+
+ public static Locations getCurrentLocation(){ return currentLocation; }
+
+ public static void handleLocation(String locationLine){
+ String location = locationLine.replace(" ", "").toUpperCase(Locale.ENGLISH).trim();
+ if (location.startsWith("THECATACOMBS")){
+ 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);
+ }
+ }
+
+}