aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorRime <81419447+Emirlol@users.noreply.github.com>2025-03-15 23:01:22 +0300
committerGitHub <noreply@github.com>2025-03-15 16:01:22 -0400
commit6bfb0d869d2e004fab37979a97d73501b40f3fe6 (patch)
tree20236cce894fbc3d0a3221280126e49593aa9a79 /src/main/java
parent50f0f5c0c6326e77c2a28d8162578cc307eedded (diff)
downloadSkyblocker-6bfb0d869d2e004fab37979a97d73501b40f3fe6.tar.gz
Skyblocker-6bfb0d869d2e004fab37979a97d73501b40f3fe6.tar.bz2
Skyblocker-6bfb0d869d2e004fab37979a97d73501b40f3fe6.zip
Fix catacombs level adder (#1213)
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/CatacombsLevelAdder.java11
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/PotionLevelAdder.java25
2 files changed, 15 insertions, 21 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/CatacombsLevelAdder.java b/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/CatacombsLevelAdder.java
index 0877751c..196f2ab0 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/CatacombsLevelAdder.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/CatacombsLevelAdder.java
@@ -1,13 +1,12 @@
package de.hysky.skyblocker.skyblock.item.slottext.adders;
-import de.hysky.skyblocker.skyblock.item.slottext.SlotText;
import de.hysky.skyblocker.skyblock.item.slottext.SimpleSlotTextAdder;
+import de.hysky.skyblocker.skyblock.item.slottext.SlotText;
import de.hysky.skyblocker.utils.RomanNumerals;
import de.hysky.skyblocker.utils.container.SlotTextAdder;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.slot.Slot;
import net.minecraft.text.Text;
-import net.minecraft.util.Formatting;
import org.apache.commons.lang3.math.NumberUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -16,8 +15,8 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-//This class is split into 3 inner classes as there are multiple screens for showing catacombs levels, each with different slot ids or different style of showing the level.
-//It's still kept in 1 main class for organization purposes.
+// This class is split into 3 inner classes as there are multiple screens for showing catacombs levels, each with different slot ids or different style of showing the level.
+// It's still kept in 1 main class for the shared config information.
public class CatacombsLevelAdder {
private static final SlotTextAdder.ConfigInformation CONFIG_INFORMATION = new SlotTextAdder.ConfigInformation(
@@ -28,7 +27,7 @@ public class CatacombsLevelAdder {
}
public static class Dungeoneering extends SimpleSlotTextAdder {
- private static final Pattern LEVEL_PATTERN = Pattern.compile(".*?(?:(?<arabic>\\d+)|(?<roman>\\S+))? ?✯?");
+ private static final Pattern LEVEL_PATTERN = Pattern.compile(".*?(?:(?: (?<arabic>\\d+)| (?<roman>[IVXLC]+))(?: ✯)?)?");
public Dungeoneering() {
super("^Dungeoneering", CONFIG_INFORMATION);
}
@@ -41,7 +40,7 @@ public class CatacombsLevelAdder {
if (!matcher.matches()) return List.of();
String arabic = matcher.group("arabic");
String roman = matcher.group("roman");
- if (arabic == null && roman == null) return SlotText.bottomLeftList(Text.literal("0").formatted(Formatting.RED));
+ if (arabic == null && roman == null) return SlotText.bottomLeftList(Text.literal("0").withColor(SlotText.CREAM));
String level;
if (arabic != null) {
if (!NumberUtils.isDigits(arabic)) return List.of(); //Sanity check
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/PotionLevelAdder.java b/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/PotionLevelAdder.java
index 4e06f47a..380471e8 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/PotionLevelAdder.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/item/slottext/adders/PotionLevelAdder.java
@@ -22,19 +22,14 @@ public class PotionLevelAdder extends SimpleSlotTextAdder {
super(CONFIG_INFORMATION);
}
- @Override
- public @NotNull List<SlotText> getText(@Nullable Slot slot, @NotNull ItemStack stack, int slotId) {
- NbtCompound customData = ItemUtils.getCustomData(stack);
- String title = stack.getName().getString();
- if (customData.contains("potion_level", NbtElement.INT_TYPE) && !title.contains("Healer Class") && !title.contains("Class Passives")) {
- if (title.contains("Healer Level ")){
- String level = title.replaceAll("\\D", "");
- return SlotText.bottomRightList(Text.literal(level).withColor(SlotText.WHITE));
- } else {
- int level = customData.getInt("potion_level");
- return SlotText.bottomRightList(Text.literal(String.valueOf(level)).withColor(SlotText.CREAM));
- }
- }
- return List.of();
- }
+ @Override
+ public @NotNull List<SlotText> getText(@Nullable Slot slot, @NotNull ItemStack stack, int slotId) {
+ NbtCompound customData = ItemUtils.getCustomData(stack);
+ String title = stack.getName().getString();
+ if (customData.contains("potion_level", NbtElement.INT_TYPE) && !title.contains("Healer") && !title.contains("Class Passives")) {
+ int level = customData.getInt("potion_level");
+ return SlotText.bottomRightList(Text.literal(String.valueOf(level)).withColor(SlotText.CREAM));
+ }
+ return List.of();
+ }
}