diff options
Diffstat (limited to 'src/main/java/me')
-rw-r--r-- | src/main/java/me/Danker/DankersSkyblockMod.java | 41 | ||||
-rw-r--r-- | src/main/java/me/Danker/commands/SetPartyCommand.java | 20 | ||||
-rw-r--r-- | src/main/java/me/Danker/commands/SetkeyCommand.java | 1 |
3 files changed, 60 insertions, 2 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index 95c5436..e253646 100644 --- a/src/main/java/me/Danker/DankersSkyblockMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -97,7 +97,7 @@ public class DankersSkyblockMod static int tickAmount = 1; static String lastMaddoxCommand = "/cb placeholder"; static double lastMaddoxTime = 0; - static KeyBinding[] keyBindings = new KeyBinding[3]; + static KeyBinding[] keyBindings = new KeyBinding[4]; static boolean usingLabymod = false; static boolean usingOAM = false; static boolean OAMWarning = false; @@ -274,6 +274,7 @@ public class DankersSkyblockMod keyBindings[0] = new KeyBinding("Open Maddox Menu", Keyboard.KEY_M, "Danker's Skyblock Mod"); keyBindings[1] = new KeyBinding("Start/Stop Skill Tracker", Keyboard.KEY_NUMPAD5, "Danker's Skyblock Mod"); keyBindings[2] = new KeyBinding("Reparty", Keyboard.KEY_P,"Danker's Skyblock Mod"); + keyBindings[3] = new KeyBinding("Get Party", Keyboard.KEY_O, "Danker's Skyblock Mod"); for (KeyBinding keyBinding : keyBindings) { ClientRegistry.registerKeyBinding(keyBinding); @@ -384,6 +385,39 @@ public class DankersSkyblockMod public void onChat(ClientChatReceivedEvent event) { String message = StringUtils.stripControlCodes(event.message.getUnformattedText()); + if(SetPartyCommand.gettingParty){ + if(message.contains("-----------------------------")){ + switch(SetPartyCommand.delimiter){ + case 0: + System.out.println("Delimiter Cancelled"); + SetPartyCommand.delimiter++; + event.setCanceled(true); + return; + case 1: + System.out.println("Done Querying Party"); + SetPartyCommand.gettingParty = false; + SetPartyCommand.delimiter = 0; + event.setCanceled(true); + return; + } + } else if(message.contains("Party M")){ + // Looks for number between parentheses + Matcher members = (Pattern.compile("^.*?\\([^\\d]*(\\d+)[^\\d]*\\).*$")).matcher(message); + if(members.find()){ + System.out.println("Number of members read: " + members.group(1)); + event.setCanceled(true); + return; + } + System.out.println("Reading Party"); + SetPartyCommand.partyResponse += message.substring(message.indexOf(":") + 2); + event.setCanceled(true); + return; + } else if (message.contains("Party Leader")){ + event.setCanceled(true); + return; + } + } + if (!Utils.inSkyblock) return; // Action Bar @@ -2995,6 +3029,11 @@ public class DankersSkyblockMod EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + //Check for pressing O to read party + if(keyBindings[3].isPressed()){ + SetPartyCommand.getParty(); + } + // Check for pressing P for reparty if (keyBindings[2].isPressed()) { if(!SetPartyCommand.set){ diff --git a/src/main/java/me/Danker/commands/SetPartyCommand.java b/src/main/java/me/Danker/commands/SetPartyCommand.java index f840527..40551d3 100644 --- a/src/main/java/me/Danker/commands/SetPartyCommand.java +++ b/src/main/java/me/Danker/commands/SetPartyCommand.java @@ -10,9 +10,14 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; +import java.util.Arrays; + public class SetPartyCommand extends CommandBase implements ICommand { public static boolean set = false; + public static int delimiter = 0; + public static boolean gettingParty; + public static String partyResponse = ""; @Override public String getCommandName() { return "setparty"; } @@ -43,4 +48,19 @@ public class SetPartyCommand extends CommandBase implements ICommand { set = true; } + + public static void getParty() { + gettingParty = true; + partyResponse = ""; + Minecraft.getMinecraft().thePlayer.sendChatMessage("/pl"); + (new Thread(() ->{ + try{ + Thread.sleep(500); + RepartyCommand.players = Arrays.stream(partyResponse.split(" ")).filter(e -> !e.contains("[") && !e.contains("●")).toArray(String[]::new); + set = true; + } catch (InterruptedException e) { + e.printStackTrace(); + } + })).start(); + } } diff --git a/src/main/java/me/Danker/commands/SetkeyCommand.java b/src/main/java/me/Danker/commands/SetkeyCommand.java index db5fb9a..ee4b5a5 100644 --- a/src/main/java/me/Danker/commands/SetkeyCommand.java +++ b/src/main/java/me/Danker/commands/SetkeyCommand.java @@ -38,5 +38,4 @@ public class SetkeyCommand extends CommandBase implements ICommand { ConfigHandler.writeStringConfig("api", "APIKey", arg1[0]); player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Set API key to " + DankersSkyblockMod.SECONDARY_COLOUR + arg1[0])); } - } |