diff options
author | olim <bobq4582@gmail.com> | 2024-06-16 22:12:37 +0100 |
---|---|---|
committer | olim <bobq4582@gmail.com> | 2024-07-15 12:36:19 +0100 |
commit | 42503766d848ca814f44537882b8a291ea63d496 (patch) | |
tree | 5cc95ccf31f8042c898f82698220ea9bb40d5cff /src/main/java/de/hysky | |
parent | ee300d371a670e5483f5bf983e43eff20f64e90d (diff) | |
download | Skyblocker-42503766d848ca814f44537882b8a291ea63d496.tar.gz Skyblocker-42503766d848ca814f44537882b8a291ea63d496.tar.bz2 Skyblocker-42503766d848ca814f44537882b8a291ea63d496.zip |
improve cword parssing
take more location formats and partial matches for names
Diffstat (limited to 'src/main/java/de/hysky')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java | 12 |
1 files changed, 5 insertions, 7 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 9bed7d50..91f6de3d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java @@ -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]).*([0-9][0-9][0-9]?).*([0-9][0-9][0-9])"); protected static Map<String, MiningLocationLabel> activeWaypoints = new HashMap<>(); @@ -73,7 +73,7 @@ public class CrystalsLocationsManager { } private static void extractLocationFromMessage(Text message, Boolean overlay) { - if (!SkyblockerConfigManager.get().mining.crystalsWaypoints.findInChat || !Utils.isInCrystalHollows()) { + if (!SkyblockerConfigManager.get().mining.crystalsWaypoints.findInChat || !Utils.isInCrystalHollows() || overlay) { return; } @@ -83,10 +83,8 @@ public class CrystalsLocationsManager { Matcher matcher = TEXT_CWORDS_PATTERN.matcher(value); //if there are coordinates in the message try to get them and what they are talking about if (matcher.find()) { - String location = matcher.group(); - int[] coordinates = Arrays.stream(location.split(" ", 3)).mapToInt(Integer::parseInt).toArray(); - BlockPos blockPos = new BlockPos(coordinates[0], coordinates[1], coordinates[2]); - + BlockPos blockPos = new BlockPos(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)), Integer.parseInt(matcher.group(3))); + String location = blockPos.getX() + " " + blockPos.getY() + " " + blockPos.getZ(); //if position is not in the hollows do not add it if (!checkInCrystals(blockPos)) { return; @@ -94,7 +92,7 @@ public class CrystalsLocationsManager { //see if there is a name of a location to add to this for (String waypointLocation : WAYPOINT_LOCATIONS.keySet()) { - if (value.toLowerCase().contains(waypointLocation.toLowerCase())) { //todo be more lenient + if (Arrays.stream(waypointLocation.toLowerCase().split(" ")).anyMatch(word -> value.toLowerCase().contains(word)) ) { //check if contains a word of location //all data found to create waypoint addCustomWaypoint(waypointLocation, blockPos); return; |