diff options
author | olim <bobq4582@gmail.com> | 2024-06-19 20:14:36 +0100 |
---|---|---|
committer | olim <bobq4582@gmail.com> | 2024-07-15 12:36:19 +0100 |
commit | b3aa88019789eeec86627afd7e25e2edcd1dd675 (patch) | |
tree | b3cd7c12db178a340ecae69352e28e73df31b90d /src/main/java | |
parent | 8fa21f0ec183da2e626cbe0ad2f95226308c9b9a (diff) | |
download | Skyblocker-b3aa88019789eeec86627afd7e25e2edcd1dd675.tar.gz Skyblocker-b3aa88019789eeec86627afd7e25e2edcd1dd675.tar.bz2 Skyblocker-b3aa88019789eeec86627afd7e25e2edcd1dd675.zip |
clean up some unwanted cwords being passed
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java | 50 | ||||
-rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/dwarven/WishingCompassSolver.java | 4 |
2 files changed, 32 insertions, 22 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 aa72007a..0a3d6641 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java @@ -78,33 +78,39 @@ public class CrystalsLocationsManager { return; } try { - //get the message text - 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))); - String location = blockPos.getX() + " " + blockPos.getY() + " " + blockPos.getZ(); - //if position is not in the hollows do not add it - if (!checkInCrystals(blockPos)) { - return; - } + //make sure that it is only reading user messages and not from skyblocker + if (text.contains(":") && !text.startsWith(Constants.PREFIX.get().getString())) { + String userMessage = text.split(":",2)[1]; + + //get the message text + Matcher matcher = TEXT_CWORDS_PATTERN.matcher(userMessage); + //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))); + String location = blockPos.getX() + " " + blockPos.getY() + " " + blockPos.getZ(); + //if position is not in the hollows do not add it + if (!checkInCrystals(blockPos)) { + return; + } + + //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 -> userMessage.toLowerCase().contains(word))) { //check if contains a word of location + //all data found to create waypoint + addCustomWaypoint(waypointLocation, blockPos); + return; + } + } - //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 -> text.toLowerCase().contains(word))) { //check if contains a word of location - //all data found to create waypoint - addCustomWaypoint(waypointLocation, blockPos); + //if the location is not found ask the user for the location (could have been in a previous chat message) + if (CLIENT.player == null || CLIENT.getNetworkHandler() == null) { return; } - } - //if the location is not found ask the user for the location (could have been in a previous chat message) - if (CLIENT.player == null || CLIENT.getNetworkHandler() == null) { - return; + CLIENT.player.sendMessage(getLocationInputText(location), false); } - - CLIENT.player.sendMessage(getLocationInputText(location), false); } + } catch (Exception e) { LOGGER.error("[Skyblocker Crystals Locations Manager] Encountered an exception while extracing a location from a chat message!", e); } @@ -200,7 +206,7 @@ public class CrystalsLocationsManager { } - private static void addCustomWaypoint(String waypointName, BlockPos pos) { + protected static void addCustomWaypoint(String waypointName, BlockPos pos) { MiningLocationLabel.CrystalHollowsLocationsCategory category = WAYPOINT_LOCATIONS.get(waypointName); MiningLocationLabel waypoint = new MiningLocationLabel(category, pos); activeWaypoints.put(waypointName, waypoint); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/WishingCompassSolver.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/WishingCompassSolver.java index 48ceeb74..930bdad8 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/WishingCompassSolver.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/WishingCompassSolver.java @@ -15,6 +15,7 @@ import net.minecraft.particle.ParticleTypes; import net.minecraft.text.Text; import net.minecraft.util.*; import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; @@ -225,6 +226,9 @@ public class WishingCompassSolver { .append(Text.literal(location.getName()).withColor(location.getColor())) .append(Text.literal(": " + (int) targetLocation.getX() + " " + (int) targetLocation.getY() + " " + (int) targetLocation.getZ())), false); + + //add waypoint + CrystalsLocationsManager.addCustomWaypoint(location.getName(), BlockPos.ofFloored(targetLocation)); } //reset ready for another go |