Skip to content

Treasure Hunter Waypoints #1246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package de.hysky.skyblocker.skyblock.barn;

import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Constants;
import de.hysky.skyblocker.utils.chat.ChatFilterResult;
import de.hysky.skyblocker.utils.chat.ChatPatternListener;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.ClickEvent;
import net.minecraft.text.HoverEvent;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import org.jetbrains.annotations.NotNull;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -28,10 +34,22 @@ public boolean onMatch(Text message, Matcher matcher) {
String hint = matcher.group(1);
String location = locations.get(hint);
if (location == null) return false;
client.player.sendMessage(Text.of("§e[NPC] Treasure Hunter§f: Go mine around " + location + "."), false);
client.player.sendMessage(Text.of("§e[NPC] Treasure Hunter§f: Go mine around " + location), false);
requestWaypoint(location);
return true;
}

private static void requestWaypoint(String location) {
String command = "/skyblocker waypoints individual " + location + " Treasure";
MutableText requestMessage = Constants.PREFIX.get().append(Text.translatable("skyblocker.config.chat.waypoints.display", java.util.Arrays.stream(location.split(" ")).mapToInt(Integer::parseInt).boxed().toArray()).formatted(Formatting.AQUA)
.styled(style -> style
.withHoverEvent(new HoverEvent.ShowText(Text.translatable("skyblocker.config.chat.waypoints.display")))
.withClickEvent(new ClickEvent.RunCommand(command.trim()))
)
);
MinecraftClient.getInstance().player.sendMessage(requestMessage, false);
}

static {
locations = new HashMap<>();
locations.put("There's a treasure chest somewhere in a small cave in the gorge.", "258 70 -492");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ private static void onMessage(Text text, boolean overlay) {
if (Utils.isOnSkyblock() && SkyblockerConfigManager.get().uiAndVisuals.waypoints.enableWaypoints) {
String message = text.getString();

// prevents parsing skyblocker's own messages. Also prevents TH solver from parsing as it already has own waypoint
if (message.startsWith("[Skyblocker]") || message.startsWith("§e[NPC] Treasure Hunter§f:")) {
return;
}

for (Pattern pattern : PATTERNS) {
Matcher matcher = pattern.matcher(message);
if (matcher.find()) {
Expand Down