aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/location
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/location')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/location/FarmHouseHandler.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/FarmHouseHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/FarmHouseHandler.java
new file mode 100644
index 0000000..432bfbb
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/location/FarmHouseHandler.java
@@ -0,0 +1,42 @@
+package com.thatgravyboat.skyblockhud.location;
+
+import com.thatgravyboat.skyblockhud.api.events.ProfileSwitchedEvent;
+import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent;
+import java.util.Arrays;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+
+public class FarmHouseHandler {
+
+ public enum Medal {
+ BRONZE,
+ SILVER,
+ GOLD
+ }
+
+ private static final int[] medals = new int[Medal.values().length];
+
+ @SubscribeEvent
+ public void onSidebarLineUpdate(SidebarLineUpdateEvent event) {
+ if (event.formattedLine.contains("medals:")){
+ for (Medal value : Medal.values()) {
+ if (event.formattedLine.contains(value.name())){
+ try {
+ medals[value.ordinal()] = Integer.parseInt(event.formattedLine.replace("medals:", "").replace(value.name(), "").trim());
+ }catch (Exception ignored){}
+ break;
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onProfileSwitch(ProfileSwitchedEvent event){
+ Arrays.fill(medals, 0);
+ }
+
+ public static String getFormattedMedals(Medal medal){
+ if (medal == null) return "0";
+ return String.valueOf(medals[medal.ordinal()]);
+ }
+
+}