aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/utils
diff options
context:
space:
mode:
authorsyeyoung <42869671+cyoung06@users.noreply.github.com>2020-11-21 22:59:02 +0900
committersyeyoung <42869671+cyoung06@users.noreply.github.com>2020-11-21 22:59:02 +0900
commit643ca3e4c149fa91be782ef36391f3492d404d3b (patch)
treec771945c907c617ead532b37e3cc73495a35c638 /src/main/java/kr/syeyoung/dungeonsguide/utils
parentc88e76e90431cf9b242a6831429092b576fdc0c1 (diff)
downloadSkyblock-Dungeons-Guide-643ca3e4c149fa91be782ef36391f3492d404d3b.tar.gz
Skyblock-Dungeons-Guide-643ca3e4c149fa91be782ef36391f3492d404d3b.tar.bz2
Skyblock-Dungeons-Guide-643ca3e4c149fa91be782ef36391f3492d404d3b.zip
Methods for Identifying Skyblock Status
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/utils')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/utils/SkyblockIdentifier.java9
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java81
2 files changed, 81 insertions, 9 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/SkyblockIdentifier.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/SkyblockIdentifier.java
deleted file mode 100644
index 87425f7d..00000000
--- a/src/main/java/kr/syeyoung/dungeonsguide/utils/SkyblockIdentifier.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package kr.syeyoung.dungeonsguide.utils;
-
-import net.minecraft.client.Minecraft;
-
-public class SkyblockIdentifier {
- public static boolean isInSkyblock() {
- return true;
- }
-}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java
new file mode 100644
index 00000000..1cfb156c
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java
@@ -0,0 +1,81 @@
+package kr.syeyoung.dungeonsguide.utils;
+
+import java.text.DecimalFormat;
+import java.util.regex.Pattern;
+
+public class TextUtils {
+ private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)ยง[0-9A-FK-OR]");
+
+ private static final Pattern NUMBERS_SLASHES = Pattern.compile("[^0-9 /]");
+
+ private static final Pattern SCOREBOARD_CHARACTERS = Pattern.compile("[^a-z A-Z:0-9/'.]");
+
+ private static final Pattern FLOAT_CHARACTERS = Pattern.compile("[^.0-9\\-]");
+
+ private static final Pattern INTEGER_CHARACTERS = Pattern.compile("[^0-9]");
+
+ private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#,###.##");
+
+ public static String formatDouble(double number) {
+ return DECIMAL_FORMAT.format(number);
+ }
+
+ public static String stripColor(String input) {
+ return STRIP_COLOR_PATTERN.matcher(input).replaceAll("");
+ }
+
+ public static String keepScoreboardCharacters(String text) {
+ return SCOREBOARD_CHARACTERS.matcher(text).replaceAll("");
+ }
+
+ public static String keepFloatCharactersOnly(String text) {
+ return FLOAT_CHARACTERS.matcher(text).replaceAll("");
+ }
+
+ public static String keepIntegerCharactersOnly(String text) {
+ return INTEGER_CHARACTERS.matcher(text).replaceAll("");
+ }
+
+ public static String getNumbersOnly(String text) {
+ return NUMBERS_SLASHES.matcher(text).replaceAll("");
+ }
+
+ public static String removeDuplicateSpaces(String text) {
+ return text.replaceAll("\\s+", " ");
+ }
+
+ public static String reverseText(String originalText) {
+ StringBuilder newString = new StringBuilder();
+ String[] parts = originalText.split(" ");
+ for (int i = parts.length; i > 0; i--) {
+ String textPart = parts[i - 1];
+ boolean foundCharacter = false;
+ for (char letter : textPart.toCharArray()) {
+ if (letter > ')') {
+ foundCharacter = true;
+ newString.append((new StringBuilder(textPart)).reverse().toString());
+ break;
+ }
+ }
+ newString.append(" ");
+ if (!foundCharacter)
+ newString.insert(0, textPart);
+ newString.insert(0, " ");
+ }
+ return removeDuplicateSpaces(newString.toString().trim());
+}
+
+ public static String getOrdinalSuffix(int n) {
+ if (n >= 11 && n <= 13)
+ return "th";
+ switch (n % 10) {
+ case 1:
+ return "st";
+ case 2:
+ return "nd";
+ case 3:
+ return "rd";
+ }
+ return "th";
+ }
+} \ No newline at end of file