From 852777345060b09ab34945cff65a095aa8cb1aa9 Mon Sep 17 00:00:00 2001 From: bowser0000 Date: Thu, 28 Apr 2022 01:17:00 -0400 Subject: Add Skytils waypoint support --- src/main/java/me/Danker/DankersSkyblockMod.java | 2 +- .../commands/CrystalHollowWaypointCommand.java | 39 ++------- .../me/Danker/features/CrystalHollowWaypoints.java | 99 ++++++++++++++++++---- 3 files changed, 90 insertions(+), 50 deletions(-) (limited to 'src') 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 waypoints = new ArrayList<>(); - + public static Pattern skytilsPattern = Pattern.compile("(?.*?): (?\\d{1,3}) (?\\d{1,3}) (?\\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())); + } + } + } -- cgit