aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock
diff options
context:
space:
mode:
authorYasin <LifeIsAParadox@users.noreply.github.com>2024-01-25 18:00:47 +0100
committerGitHub <noreply@github.com>2024-01-25 18:00:47 +0100
commitf3877c4ed2eb5e08d19f9d2f45563226db311904 (patch)
treeecb0be09aa9879cd4e8ca786505abecc734af2d6 /src/main/java/de/hysky/skyblocker/skyblock
parent7af455cbb806a1e6840971a0b27adc2fdf9e24e6 (diff)
parent8d1c345674eb4cd5fec9610ef025f92b9f113a5c (diff)
downloadSkyblocker-f3877c4ed2eb5e08d19f9d2f45563226db311904.tar.gz
Skyblocker-f3877c4ed2eb5e08d19f9d2f45563226db311904.tar.bz2
Skyblocker-f3877c4ed2eb5e08d19f9d2f45563226db311904.zip
Merge pull request #512 from Emirlol/anita-fortune-tabhud
Add anita's talisman fortune boost indicator next to the relevant crop
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/JacobsContestWidget.java47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/JacobsContestWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/JacobsContestWidget.java
index 472e6d61..24dcc229 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/JacobsContestWidget.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/JacobsContestWidget.java
@@ -1,9 +1,5 @@
package de.hysky.skyblocker.skyblock.tabhud.widget;
-import java.util.HashMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import de.hysky.skyblocker.skyblock.tabhud.util.Ico;
import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr;
import de.hysky.skyblocker.skyblock.tabhud.widget.component.IcoTextComponent;
@@ -14,6 +10,12 @@ import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static java.util.Map.entry;
+
// this widget shows info about the current jacob's contest (garden only)
public class JacobsContestWidget extends Widget {
@@ -22,23 +24,20 @@ public class JacobsContestWidget extends Widget {
Formatting.BOLD);
//TODO Properly match the contest placement and display it
- private static final Pattern CROP_PATTERN = Pattern.compile("(?:☘|○) (?<crop>[A-Za-z ]+)(?:.+)?");
+ private static final Pattern CROP_PATTERN = Pattern.compile("(?<fortune>[☘○]) (?<crop>[A-Za-z ]+).*");
- private static final HashMap<String, ItemStack> FARM_DATA = new HashMap<>();
-
- // again, there HAS to be a better way to do this
- static {
- FARM_DATA.put("Wheat", new ItemStack(Items.WHEAT));
- FARM_DATA.put("Sugar Cane", new ItemStack(Items.SUGAR_CANE));
- FARM_DATA.put("Carrot", new ItemStack(Items.CARROT));
- FARM_DATA.put("Potato", new ItemStack(Items.POTATO));
- FARM_DATA.put("Melon", new ItemStack(Items.MELON_SLICE));
- FARM_DATA.put("Pumpkin", new ItemStack(Items.PUMPKIN));
- FARM_DATA.put("Cocoa Beans", new ItemStack(Items.COCOA_BEANS));
- FARM_DATA.put("Nether Wart", new ItemStack(Items.NETHER_WART));
- FARM_DATA.put("Cactus", new ItemStack(Items.CACTUS));
- FARM_DATA.put("Mushroom", new ItemStack(Items.RED_MUSHROOM));
- }
+ private static final Map<String, ItemStack> FARM_DATA = Map.ofEntries(
+ entry("Wheat", new ItemStack(Items.WHEAT)),
+ entry("Sugar Cane", new ItemStack(Items.SUGAR_CANE)),
+ entry("Carrot", new ItemStack(Items.CARROT)),
+ entry("Potato", new ItemStack(Items.POTATO)),
+ entry("Melon", new ItemStack(Items.MELON_SLICE)),
+ entry("Pumpkin", new ItemStack(Items.PUMPKIN)),
+ entry("Cocoa Beans", new ItemStack(Items.COCOA_BEANS)),
+ entry("Nether Wart", new ItemStack(Items.NETHER_WART)),
+ entry("Cactus", new ItemStack(Items.CACTUS)),
+ entry("Mushroom", new ItemStack(Items.RED_MUSHROOM))
+ );
public JacobsContestWidget() {
super(TITLE, Formatting.YELLOW.getColorValue());
@@ -54,7 +53,7 @@ public class JacobsContestWidget extends Widget {
this.addSimpleIcoText(Ico.CLOCK, "Starts in:", Formatting.GOLD, 76);
}
- TableComponent tc = new TableComponent(1, 3, Formatting.YELLOW .getColorValue());
+ TableComponent tc = new TableComponent(1, 3, Formatting.YELLOW.getColorValue());
for (int i = 77; i < 80; i++) {
Matcher item = PlayerListMgr.regexAt(i, CROP_PATTERN);
@@ -63,7 +62,11 @@ public class JacobsContestWidget extends Widget {
itc = new IcoTextComponent();
} else {
String cropName = item.group("crop").trim(); //Trimming is needed because during a contest the space separator will be caught
- itc = new IcoTextComponent(FARM_DATA.get(cropName), Text.of(cropName));
+ if (item.group("fortune").equals("☘")) {
+ itc = new IcoTextComponent(FARM_DATA.get(cropName), Text.literal(cropName).append(Text.literal(" ☘").formatted(Formatting.GOLD)));
+ } else {
+ itc = new IcoTextComponent(FARM_DATA.get(cropName), Text.of(cropName));
+ }
}
tc.addToCell(0, i - 77, itc);
}