blob: 432bfbbbac621f4ba44d3d32ee2b0310e6dd6b4e (
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
36
37
38
39
40
41
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()]);
}
}
|