aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/dungeons
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/dungeons')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/dungeons/Classes.java48
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java120
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonPlayer.java55
3 files changed, 125 insertions, 98 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/Classes.java b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/Classes.java
index 14634d8..b05fe91 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/Classes.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/Classes.java
@@ -1,47 +1,45 @@
package com.thatgravyboat.skyblockhud.dungeons;
public enum Classes {
-
- H("Healer", "H", 154),
- M("Mage", "M", 90),
- B("Berserk", "B", 122),
- A("Archer", "A", 58),
- T("Tank", "T", 186);
-
- private final String displayName;
- private final String classId;
- private final int textureY;
-
- Classes(String name, String id, int textureY)
- {
+ H("Healer", "H", 154),
+ M("Mage", "M", 90),
+ B("Berserk", "B", 122),
+ A("Archer", "A", 58),
+ T("Tank", "T", 186);
+
+ private final String displayName;
+ private final String classId;
+ private final int textureY;
+
+ Classes(String name, String id, int textureY) {
this.displayName = name;
this.classId = id;
this.textureY = textureY;
}
-
+
public String getDisplayName() {
- return this.displayName;
+ return this.displayName;
}
-
+
public String getClassId() {
- return this.classId;
+ return this.classId;
}
public int getTextureY() {
return this.textureY;
}
- public static Classes findClass(String input){
- if (input.length() == 1){
- try{
+ public static Classes findClass(String input) {
+ if (input.length() == 1) {
+ try {
return Classes.valueOf(input.toUpperCase());
- } catch (IllegalArgumentException ignored){}
- } else if (input.length() == 3){
- try{
+ } catch (IllegalArgumentException ignored) {}
+ } else if (input.length() == 3) {
+ try {
return Classes.valueOf(input.replace("[", "").replace("]", "").toUpperCase());
- } catch (IllegalArgumentException ignored){}
+ } catch (IllegalArgumentException ignored) {}
} else {
- for(Classes clazz : Classes.values()){
+ for (Classes clazz : Classes.values()) {
if (clazz.displayName.equalsIgnoreCase(input)) return clazz;
}
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java
index 4524c0f..2418b13 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java
@@ -5,14 +5,14 @@ import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent;
import com.thatgravyboat.skyblockhud.api.events.SidebarPostEvent;
import com.thatgravyboat.skyblockhud.location.LocationHandler;
import com.thatgravyboat.skyblockhud.location.Locations;
-import net.minecraft.client.Minecraft;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import net.minecraft.client.Minecraft;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class DungeonHandler {
+
private static final HashMap<String, DungeonPlayer> dungeonPlayersMap = new HashMap<>();
private static int dungeonTime = 0;
private static int dungeonCleared = 0;
@@ -27,7 +27,7 @@ public class DungeonHandler {
private static final Pattern DungeonPlayerRegex = Pattern.compile("^\\[([HMBAT])] ([\\w]+) ([0-9]+|DEAD)$");
@SubscribeEvent
- public void onSidebarLineUpdate(SidebarLineUpdateEvent event){
+ public void onSidebarLineUpdate(SidebarLineUpdateEvent event) {
if (LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) {
DungeonHandler.checkForDungeonTime(event.formattedLine);
DungeonHandler.checkForDungeonCleared(event.formattedLine);
@@ -37,110 +37,110 @@ public class DungeonHandler {
}
@SubscribeEvent
- public void onSidebarPost(SidebarPostEvent event){
+ public void onSidebarPost(SidebarPostEvent event) {
if (!LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)) {
DungeonHandler.clearDungeonStats();
}
}
- public static void checkForDungeonPlayers(String scoreLine, Minecraft mc){
+ public static void checkForDungeonPlayers(String scoreLine, Minecraft mc) {
Matcher dungeonMatcher = DungeonPlayerRegex.matcher(scoreLine);
- if (dungeonMatcher.matches() && DungeonHandler.dungeonTime > 0){
+ if (dungeonMatcher.matches() && DungeonHandler.dungeonTime > 0) {
Classes playerClass = Classes.valueOf(dungeonMatcher.group(1));
String displayName = dungeonMatcher.group(2);
String health = dungeonMatcher.group(3);
- if (!mc.thePlayer.getName().toLowerCase().startsWith(displayName.toLowerCase().trim())){
+ if (!mc.thePlayer.getName().toLowerCase().startsWith(displayName.toLowerCase().trim())) {
int healthNum = 0;
- if (!health.equalsIgnoreCase("dead")){
+ if (!health.equalsIgnoreCase("dead")) {
try {
healthNum = Integer.parseInt(health);
- } catch (NumberFormatException ignored){}
+ } catch (NumberFormatException ignored) {}
}
DungeonPlayer player = new DungeonPlayer(playerClass, displayName, healthNum, health.equalsIgnoreCase("dead"));
- dungeonPlayersMap.put(displayName.toLowerCase(),player);
+ dungeonPlayersMap.put(displayName.toLowerCase(), player);
}
}
}
- public static void checkForDungeonTime(String scoreLine){
- if (scoreLine.toLowerCase().trim().contains("time elapsed:")){
+ public static void checkForDungeonTime(String scoreLine) {
+ if (scoreLine.toLowerCase().trim().contains("time elapsed:")) {
String timeLine = scoreLine.toLowerCase().trim().replace("time elapsed:", "");
String[] times = timeLine.split("m ");
int time = 0;
try {
time += Integer.parseInt(times[0].replace(" ", "").replace("m", "")) * 60;
time += Integer.parseInt(times[1].replace(" ", "").replace("s", ""));
- } catch (NumberFormatException ignored){}
+ } catch (NumberFormatException ignored) {}
dungeonTime = time;
}
}
- public static void checkForDungeonCleared(String scoreline){
- if (scoreline.toLowerCase().trim().contains("dungeon cleared:")){
+ public static void checkForDungeonCleared(String scoreline) {
+ if (scoreline.toLowerCase().trim().contains("dungeon cleared:")) {
String dungeonClearedText = scoreline.toLowerCase().trim().replace("dungeon cleared:", "").replace(" ", "").replace("%", "");
- try{
+ try {
dungeonCleared = Integer.parseInt(dungeonClearedText);
- }catch (NumberFormatException ignored){ }
+ } catch (NumberFormatException ignored) {}
}
}
- public static void checkForDungeonKeys(String scoreline, String rawString){
- if (scoreline.toLowerCase().trim().contains("keys:")){
+ public static void checkForDungeonKeys(String scoreline, String rawString) {
+ if (scoreline.toLowerCase().trim().contains("keys:")) {
String dungeonClearedText = scoreline.toLowerCase().trim().replace("keys:", "").replace(" ", "").replace("x", "");
bloodKey = rawString.contains("\u2713");
- try{
+ try {
witherKeys = Integer.parseInt(dungeonClearedText);
- }catch (NumberFormatException ignored){}
+ } catch (NumberFormatException ignored) {}
}
}
- public static void parseSecrets(String statusBar){
+ public static void parseSecrets(String statusBar) {
boolean hasSecrets = false;
String[] parts = statusBar.split(" {4,}");
for (String part : parts) {
- if (part.toLowerCase().contains("secrets") && !statusBar.toLowerCase().contains("no secrets")){
+ if (part.toLowerCase().contains("secrets") && !statusBar.toLowerCase().contains("no secrets")) {
hasSecrets = true;
try {
String secret = Utils.removeColor(part.replace("Secrets", "")).replace(" ", "");
maxSecrets = Integer.parseInt(secret.split("/")[1]);
secrets = Integer.parseInt(secret.split("/")[0]);
- }catch (NumberFormatException ignored){ }
+ } catch (NumberFormatException ignored) {}
}
}
- if (!hasSecrets){
+ if (!hasSecrets) {
maxSecrets = 0;
secrets = 0;
}
}
- public static void parseTotalSecrets(String playerName){
- if (playerName.toLowerCase().contains("secrets found:")){
+ public static void parseTotalSecrets(String playerName) {
+ if (playerName.toLowerCase().contains("secrets found:")) {
String totalSecret = Utils.removeColor(playerName.toLowerCase().replace("secrets found:", "")).replace(" ", "");
try {
totalSecrets = Integer.parseInt(totalSecret);
- }catch (NumberFormatException ignored){}
+ } catch (NumberFormatException ignored) {}
}
}
- public static void parseDeaths(String playerName){
- if (playerName.toLowerCase().contains("deaths:")){
+ public static void parseDeaths(String playerName) {
+ if (playerName.toLowerCase().contains("deaths:")) {
String death = Utils.removeColor(playerName.toLowerCase().replace("deaths:", "")).replace("(", "").replace(")", "").replace(" ", "");
try {
deaths = Integer.parseInt(death);
- }catch (NumberFormatException ignored){}
+ } catch (NumberFormatException ignored) {}
}
}
- public static void parseCrypts(String playerName){
- if (playerName.toLowerCase().contains("crypts:")){
+ public static void parseCrypts(String playerName) {
+ if (playerName.toLowerCase().contains("crypts:")) {
String crypt = Utils.removeColor(playerName.toLowerCase().replace("crypts:", "")).replace(" ", "");
try {
crypts = Integer.parseInt(crypt);
- }catch (NumberFormatException ignored){}
+ } catch (NumberFormatException ignored) {}
}
}
- public static void clearDungeonStats(){
+ public static void clearDungeonStats() {
dungeonPlayersMap.clear();
dungeonTime = 0;
dungeonCleared = 0;
@@ -153,15 +153,43 @@ public class DungeonHandler {
crypts = 0;
}
- public static HashMap<String,DungeonPlayer> getDungeonPlayers(){ return dungeonPlayersMap; }
+ public static HashMap<String, DungeonPlayer> getDungeonPlayers() {
+ return dungeonPlayersMap;
+ }
+
+ public static int getDungeonTime() {
+ return dungeonTime;
+ }
+
+ public static int getDungeonCleared() {
+ return dungeonCleared;
+ }
+
+ public static int getWitherKeys() {
+ return witherKeys;
+ }
+
+ public static boolean hasBloodkey() {
+ return bloodKey;
+ }
- public static int getDungeonTime() { return dungeonTime; }
- public static int getDungeonCleared() { return dungeonCleared; }
- public static int getWitherKeys() { return witherKeys; }
- public static boolean hasBloodkey() { return bloodKey; }
- public static int getMaxSecrets() { return maxSecrets; }
- public static int getSecrets() { return secrets; }
- public static int getDeaths() { return deaths; }
- public static int getTotalSecrets() { return totalSecrets; }
- public static int getCrypts() { return crypts; }
+ public static int getMaxSecrets() {
+ return maxSecrets;
+ }
+
+ public static int getSecrets() {
+ return secrets;
+ }
+
+ public static int getDeaths() {
+ return deaths;
+ }
+
+ public static int getTotalSecrets() {
+ return totalSecrets;
+ }
+
+ public static int getCrypts() {
+ return crypts;
+ }
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonPlayer.java b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonPlayer.java
index e34424d..b0816fb 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonPlayer.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonPlayer.java
@@ -1,31 +1,32 @@
package com.thatgravyboat.skyblockhud.dungeons;
public class DungeonPlayer {
- private final Classes dungeonClass;
- private final String name;
- private final int health;
- private final boolean dead;
-
- public DungeonPlayer(Classes playersClass, String playersName, int playersHealth, boolean isDead) {
- this.dungeonClass = playersClass;
- this.name = playersName;
- this.health = isDead ? 0 : playersHealth;
- this.dead = isDead;
- }
-
- public Classes getDungeonClass() {
- return this.dungeonClass;
- }
-
- public String getName() {
- return this.name;
- }
-
- public int getHealth() {
- return this.dead ? 0 : this.health;
- }
-
- public boolean isDead() {
- return this.dead;
- }
+
+ private final Classes dungeonClass;
+ private final String name;
+ private final int health;
+ private final boolean dead;
+
+ public DungeonPlayer(Classes playersClass, String playersName, int playersHealth, boolean isDead) {
+ this.dungeonClass = playersClass;
+ this.name = playersName;
+ this.health = isDead ? 0 : playersHealth;
+ this.dead = isDead;
+ }
+
+ public Classes getDungeonClass() {
+ return this.dungeonClass;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public int getHealth() {
+ return this.dead ? 0 : this.health;
+ }
+
+ public boolean isDead() {
+ return this.dead;
+ }
}