aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java41
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java5
2 files changed, 28 insertions, 18 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java
index cfbfdc3..40d39d0 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java
@@ -2,23 +2,33 @@ package com.thatgravyboat.skyblockhud.location;
import com.thatgravyboat.skyblockhud.api.events.LocationChangeEvent;
import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent;
-import java.util.Locale;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import java.util.Locale;
+
public class LocationHandler {
private static Locations currentLocation = Locations.NONE;
- @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);
+ public static void handleLocation(String locationLine, boolean isGuesting) {
+ String location = locationLine.replace(" ", "")
+ .toUpperCase(Locale.ENGLISH).trim()
+ .replaceAll("[^A-Za-z0-9]", "");
+ if (location.startsWith("THECATACOMBS")) {
+ MinecraftForge.EVENT_BUS.post(new LocationChangeEvent(currentLocation, Locations.CATACOMBS));
+ currentLocation = Locations.CATACOMBS;
+ } else {
+ Locations locations;
+ if (isGuesting && location.endsWith("GARDEN")) {
+ locations = Locations.GUESTGARDEN;
+ } else if (isGuesting) {
+ locations = Locations.GUESTISLAND;
} else {
- LocationHandler.handleLocation(event.formattedLine);
+ locations = Locations.get(location);
}
+ MinecraftForge.EVENT_BUS.post(new LocationChangeEvent(currentLocation, locations));
+ currentLocation = locations;
}
}
@@ -30,15 +40,12 @@ public class LocationHandler {
return currentLocation;
}
- public static void handleLocation(String locationLine) {
- String location = locationLine.replace(" ", "").toUpperCase(Locale.ENGLISH).trim();
- if (location.startsWith("THECATACOMBS")) {
- MinecraftForge.EVENT_BUS.post(new LocationChangeEvent(currentLocation, Locations.CATACOMBS));
- currentLocation = Locations.CATACOMBS;
- } else {
- Locations locations = Locations.get(location.replaceAll("[^A-Za-z0-9]", ""));
- MinecraftForge.EVENT_BUS.post(new LocationChangeEvent(currentLocation, locations));
- currentLocation = locations;
+ @SubscribeEvent
+ public void onSidebarLineUpdate(SidebarLineUpdateEvent event) {
+ if (event.rawLine.contains("\u23E3")) {
+ String objectiveName = event.objective.getDisplayName().replaceAll("(?i)\\u00A7.", "");
+ boolean isGuesting = objectiveName.toLowerCase(Locale.ENGLISH).endsWith("guest");
+ LocationHandler.handleLocation(event.formattedLine, isGuesting);
}
}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java b/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java
index 05f20ab..1ae126f 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java
@@ -7,6 +7,8 @@ public enum Locations {
//PRIVATE ISLAND
YOURISLAND("yourisland", "Your Island", LocationCategory.ISLAND),
GUESTISLAND("guestisland", "Guest Island", LocationCategory.ISLAND),
+ THEGARDEN("garden", "The Garden", LocationCategory.ISLAND),
+ GUESTGARDEN("guestgarden", "Guest Garden", LocationCategory.ISLAND),
MOULBERRYSISLAND("moulberryisland", "Cool Dude Hub", LocationCategory.ISLAND),
//HUB
VILLAGE("village", "Village", LocationCategory.HUB),
@@ -163,7 +165,8 @@ public enum Locations {
LOSTPRECURSORCITY("lostprecursorcity", "Lost Precursor City", LocationCategory.CRYSTALHOLLOWS),
CRYSTALNUCLEUS("crystalnucleus", "Crystal Nucleus", LocationCategory.CRYSTALHOLLOWS),
CRYSTALHOLLOWS("crystalhollows", "Crystal Hollows", LocationCategory.CRYSTALHOLLOWS),
- FAIRYGROTTO("fairygrotto", "Fairy Grotto", LocationCategory.CRYSTALHOLLOWS);
+ FAIRYGROTTO("fairygrotto", "Fairy Grotto", LocationCategory.CRYSTALHOLLOWS),
+ ;
private final String name;
private final String displayName;