aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/location/FarmingIslandHandler.java
blob: 8997fa4119d9b94be40cb1045746f83dad18ef62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.thatgravyboat.skyblockhud.location;

import com.thatgravyboat.skyblockhud.api.events.SidebarPostEvent;
import java.util.Arrays;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class FarmingIslandHandler {

    public static Locations location = Locations.NONE;
    public static int pelts;

    @SubscribeEvent
    public void onSidebarPost(SidebarPostEvent event) {
        boolean isTracking = Arrays
            .toString(event.arrayScores)
            .toLowerCase()
            .contains("tracker mob location:");
        if (isTracking && location == Locations.NONE) {
            for (int i = 0; i < event.scores.size(); i++) {
                String line = event.scores.get(i);
                if (
                    line.toLowerCase().contains("tracker mob location:") &&
                    i > 2
                ) {
                    location =
                        Locations.get(event.scores.get(i - 1).toLowerCase());
                    break;
                }
            }
        }
        if (!isTracking && location != Locations.NONE) {
            location = Locations.NONE;
        }
    }
}