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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
package com.thatgravyboat.skyblockhud.location;
import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent;
import com.thatgravyboat.skyblockhud.api.events.SidebarPostEvent;
import com.thatgravyboat.skyblockhud.overlay.MiningHud;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Arrays;
import java.util.Locale;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class MinesHandler {
public enum Event {
NONE(0, "Unknown", false, false),
TICKET(107, "Raffle", true, true),
GOBLIN(99, "Goblin Raid", true, true),
WIND(107, "Gone With The Wind", false, false),
TOGETHER(107, "Better Together", false, true);
public int x;
public String displayName;
public boolean needsMax;
public boolean display;
Event(int x, String displayName, boolean needsMax, boolean display) {
this.x = x;
this.displayName = displayName;
this.needsMax = needsMax;
this.display = display;
}
}
public static int mithril;
public static int gemstone;
public static int eventMax;
public static int eventProgress;
public static Event currentEvent;
private static final DecimalFormat NORMAL_FORMATTER = new DecimalFormat("#,###", DecimalFormatSymbols.getInstance(Locale.CANADA));
private static final DecimalFormat SHORT_FORMATTER = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.CANADA));
static {
SHORT_FORMATTER.setRoundingMode(RoundingMode.FLOOR);
}
public static String getMithrilFormatted() {
String output = NORMAL_FORMATTER.format(mithril);
if (output.equals(".0")) output = "0.0"; else if (output.equals(",0")) output = "0,0";
return output;
}
public static String getMithrilShortFormatted() {
return mithril > 999 ? SHORT_FORMATTER.format((double) mithril / 1000) + "k" : String.valueOf(mithril);
}
public static String getGemstoneFormatted() {
String output = NORMAL_FORMATTER.format(gemstone);
if (output.equals(".0")) output = "0.0"; else if (output.equals(",0")) output = "0,0";
return output;
}
public static String getGemstoneShortFormatted() {
return gemstone > 999 ? SHORT_FORMATTER.format((double) gemstone / 1000) + "k" : String.valueOf(gemstone);
}
public static void parseMithril(String line) {
try {
mithril = Integer.parseInt(line.toLowerCase().replace("mithril powder:", "").trim());
} catch (Exception ignored) {}
}
public static void parseGemstone(String line) {
try {
gemstone = Integer.parseInt(line.toLowerCase().replace("gemstone powder:", "").trim());
} catch (Exception ignored) {}
}
@SubscribeEvent
public void onSidebarLineUpdate(SidebarLineUpdateEvent event) {
if (event.formattedLine.toLowerCase().contains("heat")) {
try {
MiningHud.setHeat(Integer.parseInt(event.formattedLine.toLowerCase().replace("heat:", "").trim()));
} catch (Exception ignored) {}
}
if (event.formattedLine.toLowerCase().contains("mithril")) {
try {
mithril = Integer.parseInt(event.formattedLine.toLowerCase().replace("mithril:", "").trim());
} catch (Exception ignored) {}
}
if (event.formattedLine.toLowerCase().contains("gemstone")) {
try {
gemstone = Integer.parseInt(event.formattedLine.toLowerCase().replace("gemstone:", "").trim());
} catch (Exception ignored) {}
}
if (event.formattedLine.toLowerCase().contains("event")) {
if (event.formattedLine.toLowerCase().contains("raffle")) {
MinesHandler.currentEvent = Event.TICKET;
} else if (event.formattedLine.toLowerCase().contains("goblin raid")) {
MinesHandler.currentEvent = Event.GOBLIN;
}
}
if (event.formattedLine.equalsIgnoreCase("wind compass")) {
MinesHandler.currentEvent = Event.WIND;
}
if (event.formattedLine.toLowerCase(Locale.ENGLISH).contains("nearby players")) {
MinesHandler.currentEvent = Event.TOGETHER;
try {
MinesHandler.eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("nearby players", ""));
} catch (Exception ignored) {}
}
if (MinesHandler.currentEvent != Event.NONE) {
if (MinesHandler.currentEvent == Event.TICKET && event.formattedLine.toLowerCase().contains("tickets:")) {
if (event.formattedLine.toLowerCase().contains("pool:")) {
try {
eventMax = Integer.parseInt(event.formattedLine.toLowerCase().replace("pool:", "").trim().split("/")[0].trim());
} catch (Exception ignored) {}
} else if (event.formattedLine.toLowerCase().contains("tickets:")) {
try {
eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("tickets:", "").split("\\(")[0].trim());
} catch (Exception ignored) {}
}
} else if (MinesHandler.currentEvent == Event.GOBLIN) {
if (event.formattedLine.toLowerCase().contains("remaining:")) {
try {
eventMax = Integer.parseInt(event.formattedLine.toLowerCase().replace("goblins", "").replace("remaining:", "").trim());
} catch (Exception ignored) {}
} else if (event.formattedLine.toLowerCase().contains("your kills:") && !event.formattedLine.toLowerCase().contains("(")) {
try {
eventProgress = Integer.parseInt(event.formattedLine.toLowerCase().replace("your kills:", "").trim());
} catch (Exception ignored) {}
}
}
}
}
@SubscribeEvent
public void onSidebarPost(SidebarPostEvent event) {
String arrayString = Arrays.toString(event.arrayScores);
boolean hasEvent = arrayString.toLowerCase().contains("event:");
boolean hasWind = arrayString.toLowerCase().contains("wind compass");
boolean hasNearbyPlayers = arrayString.toLowerCase().contains("nearby players");
if (!hasEvent && !hasWind && !hasNearbyPlayers) {
MinesHandler.currentEvent = Event.NONE;
MinesHandler.eventProgress = 0;
MinesHandler.eventMax = 0;
}
if (!arrayString.toLowerCase().contains("heat:")) {
MiningHud.setHeat(0);
}
}
}
|