aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/Danker/features')
-rw-r--r--src/main/java/me/Danker/features/CrystalHollowWaypoints.java99
1 files changed, 82 insertions, 17 deletions
diff --git a/src/main/java/me/Danker/features/CrystalHollowWaypoints.java b/src/main/java/me/Danker/features/CrystalHollowWaypoints.java
index f367877..795c49c 100644
--- a/src/main/java/me/Danker/features/CrystalHollowWaypoints.java
+++ b/src/main/java/me/Danker/features/CrystalHollowWaypoints.java
@@ -1,7 +1,6 @@
package me.Danker.features;
import me.Danker.DankersSkyblockMod;
-import me.Danker.commands.CrystalHollowWaypointCommand;
import me.Danker.commands.ToggleCommand;
import me.Danker.handlers.ScoreboardHandler;
import me.Danker.utils.RenderUtils;
@@ -20,11 +19,14 @@ import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.util.ArrayList;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
public class CrystalHollowWaypoints {
public static List<Waypoint> waypoints = new ArrayList<>();
-
+ public static Pattern skytilsPattern = Pattern.compile("(?<name>.*?): (?<x>\\d{1,3}) (?<y>\\d{1,3}) (?<z>\\d{1,3})");
+
static boolean khazad = false;
static boolean fairy = false;
static boolean temple = false;
@@ -123,25 +125,54 @@ public class CrystalHollowWaypoints {
$SBECHWP:Khazad-dûm@-292,63,281\nFairy Grotto@-216,110,400\njungle temple@-525,110,395\nJungle Temple@-493,101,425\nMines of Divan@-673,117,426
*/
if (ToggleCommand.crystalHollowWaypoints && Utils.tabLocation.equals("Crystal Hollows")) {
- if (!message.contains(player.getName()) && (message.contains(": $DSMCHWP:") || message.contains(": $SBECHWP:"))) {
- String waypoints = message.substring(message.lastIndexOf(":") + 1);
+ if (!message.contains(player.getName())) {
+ if (message.contains(": $DSMCHWP:") || message.contains(": $SBECHWP:")) {
+ String waypoints = message.substring(message.lastIndexOf(":") + 1);
- if (ToggleCommand.crystalAutoPlayerWaypoints) {
- CrystalHollowWaypointCommand.addWaypoints(waypoints, true);
- return;
- }
+ if (ToggleCommand.crystalAutoPlayerWaypoints) {
+ addDSMWaypoints(waypoints, true);
+ return;
+ }
+
+ ChatComponentText add = new ChatComponentText(EnumChatFormatting.GREEN + "" + EnumChatFormatting.BOLD + " [ADD]\n");
+ add.setChatStyle(add.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dsmaddcrystalhollowwaypoints " + waypoints)));
+
+ new Thread(() -> {
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ player.addChatMessage(new ChatComponentText("\n" + DankersSkyblockMod.MAIN_COLOUR + "DSM/SBE Crystal Hollows waypoints found. Click to add.\n").appendSibling(add));
+ }).start();
+ } else {
+ String text = message.substring(message.indexOf(":") + 2);
+ Matcher matcher = skytilsPattern.matcher(text);
- ChatComponentText add = new ChatComponentText(EnumChatFormatting.GREEN + "" + EnumChatFormatting.BOLD + " [ADD]\n");
- add.setChatStyle(add.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dsmaddcrystalhollowwaypoints " + waypoints)));
+ if (matcher.matches()) {
+ String name = matcher.group("name");
+ String x = matcher.group("x");
+ String y = matcher.group("y");
+ String z = matcher.group("z");
- new Thread(() -> {
- try {
- Thread.sleep(10);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
+ if (ToggleCommand.crystalAutoPlayerWaypoints) {
+ addWaypoint(name, x, y, z);
+ return;
+ }
+
+ ChatComponentText add = new ChatComponentText(EnumChatFormatting.GREEN + "" + EnumChatFormatting.BOLD + " [ADD]\n");
+ add.setChatStyle(add.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dsmaddcrystalhollowwaypoints st " + x + " " + y + " " + z + " " + name)));
+
+ new Thread(() -> {
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ player.addChatMessage(new ChatComponentText("\n" + DankersSkyblockMod.MAIN_COLOUR + "Skytils Crystal Hollows waypoints found. Click to add.\n").appendSibling(add));
+ }).start();
}
- player.addChatMessage(new ChatComponentText("\n" + DankersSkyblockMod.MAIN_COLOUR + "DSM/SBE Crystal Hollows waypoints found. Click to add.\n").appendSibling(add));
- }).start();
+ }
}
}
}
@@ -201,4 +232,38 @@ public class CrystalHollowWaypoints {
}
+ public static void addWaypoint(String name, String x, String y, String z) {
+ BlockPos pos = new BlockPos(Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(z));
+ Waypoint waypoint = new Waypoint(name, pos);
+ waypoints.add(waypoint);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Added " + waypoint.location + " @ " + waypoint.getPos()));
+ }
+
+ public static void addDSMWaypoints(String list, boolean auto) {
+ String[] waypointsList = list.split("\\\\n");
+
+ for (String waypoint : waypointsList) {
+ String[] parts = waypoint.split("@-");
+ String[] coords = parts[1].split(",");
+
+ String location = parts[0];
+ BlockPos pos = new BlockPos(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2]));
+ Waypoint newWaypoint = new Waypoint(location, pos);
+
+ if (auto) {
+ boolean contains = false;
+ for (Waypoint existing : waypoints) {
+ if (existing.location.equals(location)) {
+ contains = true;
+ break;
+ }
+ }
+ if (contains) continue;
+ }
+
+ waypoints.add(newWaypoint);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Added " + newWaypoint.location + " @ " + newWaypoint.getPos()));
+ }
+ }
+
}