aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/util
diff options
context:
space:
mode:
authorohowe <42757516+carelesshippo@users.noreply.github.com>2021-06-02 11:55:36 -0600
committerohowe <42757516+carelesshippo@users.noreply.github.com>2021-06-02 11:55:36 -0600
commiteeb5c45d71997cb259fc35330490a19db7865603 (patch)
tree65771b27ed837896fa3140dec1af78306accebcd /src/main/java/io/github/moulberry/notenoughupdates/util
parent4d9e538ced80728bca74491698347333f515bfcc (diff)
parent1b172089ce502803f7644611afd618ce00dcb860 (diff)
downloadnotenoughupdates-eeb5c45d71997cb259fc35330490a19db7865603.tar.gz
notenoughupdates-eeb5c45d71997cb259fc35330490a19db7865603.tar.bz2
notenoughupdates-eeb5c45d71997cb259fc35330490a19db7865603.zip
Merge branch 'Moulberry:master' into master
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java13
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java22
2 files changed, 34 insertions, 1 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
index 13317776..73d61a1e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
@@ -55,6 +55,7 @@ public class SBInfo {
private long lastLocRaw = -1;
private long joinedWorld = -1;
private JsonObject locraw = null;
+ public boolean isInDungeon = false;
public String currentProfile = null;
@@ -134,10 +135,14 @@ public class SBInfo {
currentProfile = Utils.cleanColour(name.substring(profilePrefix.length()));
}
}
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ try {
Scoreboard scoreboard = Minecraft.getMinecraft().thePlayer.getWorldScoreboard();
- ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1); //§707/14/20
+ ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1);
List<Score> scores = new ArrayList<>(scoreboard.getSortedScores(sidebarObjective));
@@ -147,8 +152,14 @@ public class SBInfo {
ScorePlayerTeam scoreplayerteam1 = scoreboard.getPlayersTeam(score.getPlayerName());
String line = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score.getPlayerName());
line = Utils.cleanDuplicateColourCodes(line);
+
+ if(Utils.cleanColour(line).contains("Dungeon Cleared: ")) {
+ isInDungeon = true;
+ }
+
lines.add(line);
}
+
if(lines.size() >= 5) {
date = Utils.cleanColour(lines.get(1)).trim();
//§74:40am
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
index 4a72a85e..d77f3c9e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
@@ -194,6 +194,28 @@ public class Utils {
return chromaString(str, 0, false);
}
+ private static final Pattern CHROMA_REPLACE_PATTERN = Pattern.compile("\u00a7z(.+?)(?=\u00a7|$)");
+
+ public static String chromaStringByColourCode(String str) {
+ if(str.contains("\u00a7z")) {
+ Matcher matcher = CHROMA_REPLACE_PATTERN.matcher(str);
+
+ StringBuffer sb = new StringBuffer();
+
+ while(matcher.find()) {
+ matcher.appendReplacement(sb,
+ Utils.chromaString(matcher.group(1))
+ .replace("\\", "\\\\")
+ .replace("$", "\\$")
+ );
+ }
+ matcher.appendTail(sb);
+
+ str = sb.toString();
+ }
+ return str;
+ }
+
private static long startTime = 0;
public static String chromaString(String str, float offset, boolean bold) {
str = cleanColour(str);