diff options
author | nea <nea@nea.moe> | 2023-02-17 00:02:40 +0100 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-02-17 00:02:40 +0100 |
commit | e347661f6a1cf506294004fd1516c3ef04030b70 (patch) | |
tree | 58e00026ec8b3db38afbb8d1a3ffcb9bb28852b7 /src/main | |
parent | a4f0b848706e61fe3ceb69c0be908002f9ab8d58 (diff) | |
download | SkyblockHud-Death-Defied-e347661f6a1cf506294004fd1516c3ef04030b70.tar.gz SkyblockHud-Death-Defied-e347661f6a1cf506294004fd1516c3ef04030b70.tar.bz2 SkyblockHud-Death-Defied-e347661f6a1cf506294004fd1516c3ef04030b70.zip |
Add garden to locations
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java | 41 | ||||
-rw-r--r-- | src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java | 5 |
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; |