aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java26
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java31
2 files changed, 36 insertions, 21 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java
index 91f6de3d..aa72007a 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java
@@ -28,10 +28,10 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import org.slf4j.Logger;
-import java.awt.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -56,7 +56,7 @@ public class CrystalsLocationsManager {
* A look-up table to convert between location names and waypoint in the {@link MiningLocationLabel.CrystalHollowsLocationsCategory} values.
*/
private static final Map<String, MiningLocationLabel.CrystalHollowsLocationsCategory> WAYPOINT_LOCATIONS = Arrays.stream(MiningLocationLabel.CrystalHollowsLocationsCategory.values()).collect(Collectors.toMap(MiningLocationLabel.CrystalHollowsLocationsCategory::getName, Function.identity()));
- private static final Pattern TEXT_CWORDS_PATTERN = Pattern.compile("([0-9][0-9][0-9]).*([0-9][0-9][0-9]?).*([0-9][0-9][0-9])");
+ private static final Pattern TEXT_CWORDS_PATTERN = Pattern.compile("([0-9][0-9][0-9])\\D*([0-9][0-9][0-9]?)\\D*([0-9][0-9][0-9])");
protected static Map<String, MiningLocationLabel> activeWaypoints = new HashMap<>();
@@ -73,14 +73,13 @@ public class CrystalsLocationsManager {
}
private static void extractLocationFromMessage(Text message, Boolean overlay) {
- if (!SkyblockerConfigManager.get().mining.crystalsWaypoints.findInChat || !Utils.isInCrystalHollows() || overlay) {
+ String text = Formatting.strip(message.getString());
+ if (!SkyblockerConfigManager.get().mining.crystalsWaypoints.findInChat || !Utils.isInCrystalHollows() || overlay || text == null) {
return;
}
-
try {
//get the message text
- String value = message.getString();
- Matcher matcher = TEXT_CWORDS_PATTERN.matcher(value);
+ Matcher matcher = TEXT_CWORDS_PATTERN.matcher(text);
//if there are coordinates in the message try to get them and what they are talking about
if (matcher.find()) {
BlockPos blockPos = new BlockPos(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)), Integer.parseInt(matcher.group(3)));
@@ -92,7 +91,7 @@ public class CrystalsLocationsManager {
//see if there is a name of a location to add to this
for (String waypointLocation : WAYPOINT_LOCATIONS.keySet()) {
- if (Arrays.stream(waypointLocation.toLowerCase().split(" ")).anyMatch(word -> value.toLowerCase().contains(word)) ) { //check if contains a word of location
+ if (Arrays.stream(waypointLocation.toLowerCase().split(" ")).anyMatch(word -> text.toLowerCase().contains(word))) { //check if contains a word of location
//all data found to create waypoint
addCustomWaypoint(waypointLocation, blockPos);
return;
@@ -109,6 +108,16 @@ public class CrystalsLocationsManager {
} catch (Exception e) {
LOGGER.error("[Skyblocker Crystals Locations Manager] Encountered an exception while extracing a location from a chat message!", e);
}
+
+ //move waypoint to be more accurate based on locational chat messages
+ if (CLIENT.player != null) {
+ for (MiningLocationLabel.CrystalHollowsLocationsCategory waypointLocation : WAYPOINT_LOCATIONS.values()) {
+ String waypointLinkedMessage = waypointLocation.getLinkedMessage();
+ if (waypointLinkedMessage != null && text.contains(waypointLinkedMessage)) {
+ addCustomWaypoint(waypointLocation.getName(), CLIENT.player.getBlockPos());
+ }
+ }
+ }
}
protected static Boolean checkInCrystals(BlockPos pos) {
@@ -178,7 +187,7 @@ public class CrystalsLocationsManager {
public static int shareWaypoint(String place) {
if (activeWaypoints.containsKey(place)) {
Vec3d pos = activeWaypoints.get(place).centerPos();
- MessageScheduler.INSTANCE.sendMessageAfterCooldown(Constants.PREFIX.get().getString() + " " + place + ": " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ());
+ MessageScheduler.INSTANCE.sendMessageAfterCooldown(Constants.PREFIX.get().getString() + " " + place + ": " + (int) pos.getX() + ", " + (int) pos.getY() + ", " + (int) pos.getZ());
} else {
//send fail message
if (CLIENT.player == null || CLIENT.getNetworkHandler() == null) {
@@ -201,7 +210,6 @@ public class CrystalsLocationsManager {
if (SkyblockerConfigManager.get().mining.crystalsWaypoints.enabled) {
for (MiningLocationLabel crystalsWaypoint : activeWaypoints.values()) {
crystalsWaypoint.render(context);
-
}
}
}
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java
index 30f33aa2..0fc0c64f 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/MiningLocationLabel.java
@@ -27,6 +27,7 @@ public record MiningLocationLabel(Category category, Vec3d centerPos) implements
/**
* Renders the name and distance to the label scaled so can be seen at a distance
+ *
* @param context render context
*/
@Override
@@ -162,24 +163,26 @@ public record MiningLocationLabel(Category category, Vec3d centerPos) implements
* enum for the different waypoints used int the crystals hud each with a {@link CrystalHollowsLocationsCategory#name} and associated {@link CrystalHollowsLocationsCategory#color}
*/
enum CrystalHollowsLocationsCategory implements Category {
- JUNGLE_TEMPLE("Jungle Temple", new Color(DyeColor.PURPLE.getSignColor())),
- MINES_OF_DIVAN("Mines of Divan", Color.GREEN),
- GOBLIN_QUEENS_DEN("Goblin Queen's Den", new Color(DyeColor.ORANGE.getSignColor())),
- LOST_PRECURSOR_CITY("Lost Precursor City", Color.CYAN),
- KHAZAD_DUM("Khazad-dûm", Color.YELLOW),
- FAIRY_GROTTO("Fairy Grotto", Color.PINK),
- DRAGONS_LAIR("Dragon's Lair", Color.BLACK),
- CORLEONE("Corleone", Color.WHITE),
- KING_YOLKAR("King Yolkar", Color.RED),
- ODAWA("Odawa", Color.MAGENTA),
- KEY_GUARDIAN("Key Guardian", Color.LIGHT_GRAY);
+ JUNGLE_TEMPLE("Jungle Temple", new Color(DyeColor.PURPLE.getSignColor()), "[NPC] Kalhuiki Door Guardian:"),
+ MINES_OF_DIVAN("Mines of Divan", Color.GREEN, " Jade Crystal"),
+ GOBLIN_QUEENS_DEN("Goblin Queen's Den", new Color(DyeColor.ORANGE.getSignColor()), " Amber Crystal"),
+ LOST_PRECURSOR_CITY("Lost Precursor City", Color.CYAN, " Sapphire Crystal"),
+ KHAZAD_DUM("Khazad-dûm", Color.YELLOW, " Topaz Crystal"),
+ FAIRY_GROTTO("Fairy Grotto", Color.PINK, null),
+ DRAGONS_LAIR("Dragon's Lair", Color.BLACK, null),
+ CORLEONE("Corleone", Color.WHITE, null),
+ KING_YOLKAR("King Yolkar", Color.RED, "[NPC] King Yolkar:"),
+ ODAWA("Odawa", Color.MAGENTA, "[NPC] Odawa:"),
+ KEY_GUARDIAN("Key Guardian", Color.LIGHT_GRAY, null);
public final Color color;
private final String name;
+ private final String linkedMessage;
- CrystalHollowsLocationsCategory(String name, Color color) {
+ CrystalHollowsLocationsCategory(String name, Color color, String linkedMessage) {
this.name = name;
this.color = color;
+ this.linkedMessage = linkedMessage;
}
@Override
@@ -191,6 +194,10 @@ public record MiningLocationLabel(Category category, Vec3d centerPos) implements
public int getColor() {
return this.color.getRGB();
}
+
+ public String getLinkedMessage() {
+ return this.linkedMessage;
+ }
}
}