aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2022-04-28 01:17:00 -0400
committerbowser0000 <bowser0000@gmail.com>2022-04-28 01:17:00 -0400
commit852777345060b09ab34945cff65a095aa8cb1aa9 (patch)
tree3fd0879eaa45579b15321e7c14898fe388999499 /src
parentb3cb573fcfb7afbb0206d29b71432ab68c82a876 (diff)
downloadSkyblockMod-852777345060b09ab34945cff65a095aa8cb1aa9.tar.gz
SkyblockMod-852777345060b09ab34945cff65a095aa8cb1aa9.tar.bz2
SkyblockMod-852777345060b09ab34945cff65a095aa8cb1aa9.zip
Add Skytils waypoint support
Diffstat (limited to 'src')
-rw-r--r--src/main/java/me/Danker/DankersSkyblockMod.java2
-rw-r--r--src/main/java/me/Danker/commands/CrystalHollowWaypointCommand.java39
-rw-r--r--src/main/java/me/Danker/features/CrystalHollowWaypoints.java99
3 files changed, 90 insertions, 50 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java
index cc96448..2139549 100644
--- a/src/main/java/me/Danker/DankersSkyblockMod.java
+++ b/src/main/java/me/Danker/DankersSkyblockMod.java
@@ -64,7 +64,7 @@ import java.util.Map;
@Mod(modid = DankersSkyblockMod.MODID, version = DankersSkyblockMod.VERSION, clientSideOnly = true)
public class DankersSkyblockMod {
public static final String MODID = "Danker's Skyblock Mod";
- public static final String VERSION = "1.8.7-beta5";
+ public static final String VERSION = "1.8.7-beta6";
public static int titleTimer = -1;
public static boolean showTitle = false;
public static String titleText = "";
diff --git a/src/main/java/me/Danker/commands/CrystalHollowWaypointCommand.java b/src/main/java/me/Danker/commands/CrystalHollowWaypointCommand.java
index f5dea9b..4eaf2d6 100644
--- a/src/main/java/me/Danker/commands/CrystalHollowWaypointCommand.java
+++ b/src/main/java/me/Danker/commands/CrystalHollowWaypointCommand.java
@@ -1,14 +1,11 @@
package me.Danker.commands;
-import me.Danker.DankersSkyblockMod;
import me.Danker.features.CrystalHollowWaypoints;
-import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.util.BlockPos;
-import net.minecraft.util.ChatComponentText;
+
+import java.util.Arrays;
public class CrystalHollowWaypointCommand extends CommandBase {
@@ -30,34 +27,12 @@ public class CrystalHollowWaypointCommand extends CommandBase {
@Override
public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException {
if (arg1.length == 0) return;
- addWaypoints(String.join(" ", arg1), false);
- }
-
- public static void addWaypoints(String list, boolean auto) {
- EntityPlayer player = Minecraft.getMinecraft().thePlayer;
- String[] waypoints = list.split("\\\\n");
-
- for (String waypoint : waypoints) {
- 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]));
- CrystalHollowWaypoints.Waypoint newWaypoint = new CrystalHollowWaypoints.Waypoint(location, pos);
-
- if (auto) {
- boolean contains = false;
- for (CrystalHollowWaypoints.Waypoint existing : CrystalHollowWaypoints.waypoints) {
- if (existing.location.equals(location)) {
- contains = true;
- break;
- }
- }
- if (contains) continue;
- }
- CrystalHollowWaypoints.waypoints.add(newWaypoint);
- player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Added " + newWaypoint.location + " @ " + newWaypoint.getPos()));
+ if (arg1.length > 4 && arg1[0].equals("st")) {
+ String name = String.join(" ", Arrays.copyOfRange(arg1, 4, arg1.length));
+ CrystalHollowWaypoints.addWaypoint(name, arg1[1], arg1[2], arg1[3]);
+ } else {
+ CrystalHollowWaypoints.addDSMWaypoints(String.join(" ", arg1), false);
}
}
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()));
+ }
+ }
+
}