From d20b0500e64a92d2db48d15d2ccf9f033b08f003 Mon Sep 17 00:00:00 2001 From: Sychic Date: Sun, 10 Jan 2021 18:11:52 -0500 Subject: Ghost party argument. Planning on changing to individual partying later when I can figure the logic out. --- .../java/me/Danker/commands/RepartyCommand.java | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/me/Danker/commands/RepartyCommand.java b/src/main/java/me/Danker/commands/RepartyCommand.java index 92836c5..fd63f39 100644 --- a/src/main/java/me/Danker/commands/RepartyCommand.java +++ b/src/main/java/me/Danker/commands/RepartyCommand.java @@ -25,13 +25,11 @@ import java.util.regex.Pattern; public class RepartyCommand extends CommandBase implements ICommand { - public static double callTime = 0; public static boolean gettingParty = false; public static int Delimiter = 0; public static boolean disbanding = false; public static boolean inviting = false; public static boolean failInviting = false; - public static String currentMember; public static List party = new ArrayList<>(); public static List repartyFailList = new ArrayList<>(); public static List joinList = new ArrayList<>(); @@ -62,7 +60,6 @@ public class RepartyCommand extends CommandBase implements ICommand { if (args.length > 0 && (args[0].startsWith("fail") || args[0].equals("f"))) { partyThread = new Thread(() -> { EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; - RepartyCommand.callTime = (double) System.currentTimeMillis() / 1000; GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); @@ -94,22 +91,25 @@ public class RepartyCommand extends CommandBase implements ICommand { return; } + boolean ghost = args.length > 0 && (args[0].toLowerCase().equals("g") || args[0].toLowerCase().equals("ghost")); - party.clear(); - repartyFailList.clear(); + if(ghost){ + party.clear(); + repartyFailList.clear(); + } // MULTI THREAD DRIFTING partyThread = new Thread(() -> { EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; - RepartyCommand.callTime = (double) System.currentTimeMillis() / 1000; - GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); try { - player.sendChatMessage("/pl"); - gettingParty = true; - while (gettingParty) { - Thread.sleep(10); + if(ghost){ + player.sendChatMessage("/pl"); + gettingParty = true; + while (gettingParty) { + Thread.sleep(10); + } } if (party.size() == 0) return; player.sendChatMessage("/p disband"); -- cgit From 39bf45abfcd4d1704f1173149f8f028e07016f39 Mon Sep 17 00:00:00 2001 From: Sychic Date: Mon, 11 Jan 2021 21:50:58 -0500 Subject: Revert reparty edit commits 1/2 --- .../java/me/Danker/commands/RepartyCommand.java | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/me/Danker/commands/RepartyCommand.java b/src/main/java/me/Danker/commands/RepartyCommand.java index fd63f39..92836c5 100644 --- a/src/main/java/me/Danker/commands/RepartyCommand.java +++ b/src/main/java/me/Danker/commands/RepartyCommand.java @@ -25,11 +25,13 @@ import java.util.regex.Pattern; public class RepartyCommand extends CommandBase implements ICommand { + public static double callTime = 0; public static boolean gettingParty = false; public static int Delimiter = 0; public static boolean disbanding = false; public static boolean inviting = false; public static boolean failInviting = false; + public static String currentMember; public static List party = new ArrayList<>(); public static List repartyFailList = new ArrayList<>(); public static List joinList = new ArrayList<>(); @@ -60,6 +62,7 @@ public class RepartyCommand extends CommandBase implements ICommand { if (args.length > 0 && (args[0].startsWith("fail") || args[0].equals("f"))) { partyThread = new Thread(() -> { EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + RepartyCommand.callTime = (double) System.currentTimeMillis() / 1000; GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); @@ -91,25 +94,22 @@ public class RepartyCommand extends CommandBase implements ICommand { return; } - boolean ghost = args.length > 0 && (args[0].toLowerCase().equals("g") || args[0].toLowerCase().equals("ghost")); - if(ghost){ - party.clear(); - repartyFailList.clear(); - } + party.clear(); + repartyFailList.clear(); // MULTI THREAD DRIFTING partyThread = new Thread(() -> { EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + RepartyCommand.callTime = (double) System.currentTimeMillis() / 1000; + GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); try { - if(ghost){ - player.sendChatMessage("/pl"); - gettingParty = true; - while (gettingParty) { - Thread.sleep(10); - } + player.sendChatMessage("/pl"); + gettingParty = true; + while (gettingParty) { + Thread.sleep(10); } if (party.size() == 0) return; player.sendChatMessage("/p disband"); -- cgit From 9838bc712ff8c4614a658b1bde4dae913f03541f Mon Sep 17 00:00:00 2001 From: Sychic Date: Mon, 11 Jan 2021 21:51:20 -0500 Subject: Revert reparty edit commits 2/2 --- src/main/java/me/Danker/DankersSkyblockMod.java | 160 +++++---------------- .../java/me/Danker/commands/RepartyCommand.java | 105 ++++---------- 2 files changed, 63 insertions(+), 202 deletions(-) diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index 8285bec..0bcecba 100644 --- a/src/main/java/me/Danker/DankersSkyblockMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -63,7 +63,6 @@ import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent; import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; import org.apache.commons.lang3.time.StopWatch; -import org.apache.logging.log4j.Logger; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; @@ -80,7 +79,6 @@ import java.util.regex.Pattern; public class DankersSkyblockMod { public static final String MODID = "Danker's Skyblock Mod"; public static final String VERSION = "1.8.5-beta8"; - public static Logger DSMLogger; static double checkItemsNow = 0; static double itemsChecked = 0; public static Map t6Enchants = new HashMap<>(); @@ -110,9 +108,8 @@ public class DankersSkyblockMod { public static final ResourceLocation CAKE_ICON = new ResourceLocation("dsm", "icons/cake.png"); public static final ResourceLocation BONZO_ICON = new ResourceLocation("dsm", "icons/bonzo.png"); - public static final ResourceLocation LOGO = new ResourceLocation("dsm", "icons/dsm.png"); - static String[] riddleSolutions = {"The reward is not in my chest!", "At least one of them is lying, and the reward is not in", + static String[] riddleSolutions = {"The reward is not in my chest!", "At least one of them is lying, and the reward is not in", "My chest doesn't have the reward. We are all telling the truth", "My chest has the reward and I'm telling the truth", "The reward isn't in any of our chests", "Both of them are telling the truth."}; static Map triviaSolutions = new HashMap<>(); @@ -288,7 +285,6 @@ public class DankersSkyblockMod { @EventHandler public void preInit(final FMLPreInitializationEvent event) { - DSMLogger = event.getModLog(); ClientCommandHandler.instance.registerCommand(new ToggleCommand()); ClientCommandHandler.instance.registerCommand(new SetkeyCommand()); ClientCommandHandler.instance.registerCommand(new GetkeyCommand()); @@ -319,7 +315,6 @@ public class DankersSkyblockMod { public void postInit(final FMLPostInitializationEvent event) { Package[] packages = Package.getPackages(); for(Package p : packages){ - DSMLogger.info(p); if(p.getName().startsWith("com.spiderfrog.gadgets") || p.getName().startsWith("com.spiderfrog.oldanimations")){ usingOAM = true; break; @@ -431,125 +426,38 @@ public class DankersSkyblockMod { } // Reparty command - // Getting party - if (RepartyCommand.gettingParty) { - if (message.contains("-----")) { - switch(RepartyCommand.Delimiter) { - case 0: - System.out.println("Get Party Delimiter Cancelled"); - RepartyCommand.Delimiter++; - event.setCanceled(true); - return; - case 1: - System.out.println("Done querying party"); - RepartyCommand.gettingParty = false; - RepartyCommand.Delimiter = 0; - event.setCanceled(true); - return; - } - }else if (message.startsWith("Party M") || message.startsWith("Party Leader")){ - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; - - Pattern party_start_pattern = Pattern.compile("^Party Members \\((\\d+)\\)$"); - Pattern leader_pattern = Pattern.compile("^Party Leader: (?:\\[.+?] )?(\\w+) ●$"); - Pattern members_pattern = Pattern.compile(" (?:\\[.+?] )?(\\w+) ●"); - Matcher party_start = party_start_pattern.matcher(message); - Matcher leader = leader_pattern.matcher(message); - Matcher members = members_pattern.matcher(message); - - if (party_start.matches() && Integer.parseInt(party_start.group(1)) == 1) { - player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "You cannot reparty yourself.")); - RepartyCommand.partyThread.interrupt(); - } else if (leader.matches() && !(leader.group(1).equals(player.getName()))) { - player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "You are not party leader.")); - RepartyCommand.partyThread.interrupt(); - } else { - while (members.find()) { - String partyMember = members.group(1); - if (!partyMember.equals(player.getName())) { - RepartyCommand.party.add(partyMember); - System.out.println(partyMember); - } - } - } - event.setCanceled(true); - return; - } - } - // Disbanding party - if (RepartyCommand.disbanding) { - if (message.contains("-----")) { - switch (RepartyCommand.Delimiter) { - case 0: - System.out.println("Disband Delimiter Cancelled"); - RepartyCommand.Delimiter++; - event.setCanceled(true); - return; - case 1: - System.out.println("Done disbanding"); - RepartyCommand.disbanding = false; - RepartyCommand.Delimiter = 0; - event.setCanceled(true); - return; - } - } else if (message.endsWith("has disbanded the party!")) { - event.setCanceled(true); - return; - } - } - // Inviting - if (RepartyCommand.inviting) { - if (message.contains("-----")) { - if (RepartyCommand.Delimiter >= RepartyCommand.party.size() * 2 - 1) { - event.setCanceled(true); - RepartyCommand.Delimiter = 0; - System.out.println("Done Inviting!"); - RepartyCommand.inviting = false; - return; - } else { - RepartyCommand.Delimiter++; - event.setCanceled(true); - return; - } - } else if (message.endsWith(" to the party! They have 60 seconds to accept.")) { - Pattern invitePattern = Pattern.compile("(?:(?:\\[.+?] )?(?:\\w+) invited )(?:\\[.+?] )?(\\w+)"); - Matcher invitee = invitePattern.matcher(message); - if (invitee.find()) { - System.out.println("" + invitee.group(1) + ": " + RepartyCommand.repartyFailList.remove(invitee.group(1))); - } - event.setCanceled(true); - return; - } else if (message.contains("Couldn't find a player") || message.contains("You cannot invite that player")) { - event.setCanceled(true); - return; - } - } - // Fail Inviting - if (RepartyCommand.failInviting) { - if (message.contains("-----")) { - if (RepartyCommand.Delimiter >= RepartyCommand.repartyFailList.size() * 2 - 1) { - event.setCanceled(true); - RepartyCommand.Delimiter = 0; - System.out.println("Done Inviting!"); - RepartyCommand.inviting = false; - return; - } else { - RepartyCommand.Delimiter++; - event.setCanceled(true); - return; - } - } else if (message.endsWith(" to the party! They have 60 seconds to accept.")) { - Pattern invitePattern = Pattern.compile("(?:(?:\\[.+?] )?(?:\\w+) invited )(?:\\[.+?] )?(\\w+)"); - Matcher invitee = invitePattern.matcher(message); - if (invitee.find()) { - System.out.println("" + invitee.group(1) + ": " + RepartyCommand.repartyFailList.remove(invitee.group(1))); - } - event.setCanceled(true); - return; - } else if (message.contains("Couldn't find a player") || message.contains("You cannot invite that player")) { - event.setCanceled(true); - return; - } + if (System.currentTimeMillis() / 1000 - RepartyCommand.callTime <= 5) { + if (!(message.contains("----") || message.contains("disbanded") || message.contains("seconds to accept") || message.contains("●") || message.contains("Party Members") || message.contains("Couldn't find a player") || message.contains("cannot invite that player") || message.length() == 0)) { + return; + } + + EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + + Pattern party_start_pattern = Pattern.compile("^Party Members \\((\\d+)\\)$"); + Pattern leader_pattern = Pattern.compile("^Party Leader: (?:\\[.+?] )?(\\w+) ●$"); + Pattern members_pattern = Pattern.compile(" (?:\\[.+?] )?(\\w+) ●"); + Matcher party_start = party_start_pattern.matcher(message); + Matcher leader = leader_pattern.matcher(message); + Matcher members = members_pattern.matcher(message); + + if (party_start.matches() && Integer.parseInt(party_start.group(1)) == 1) { + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "You cannot reparty yourself.")); + } + else if (leader.matches() && !(leader.group(1).equals(player.getName()))) { + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "You are not party leader.")); + } + else if (message.contains("Couldn't find a player") || message.contains("You cannot invite that player")) { + RepartyCommand.repartyFailList.add(RepartyCommand.currentMember); + } + else { + while (members.find()) { + String partyMember = members.group(1); + if (!partyMember.equals(player.getName())) { + RepartyCommand.party.add(partyMember); + } + } + } + event.setCanceled(true); } if (!Utils.inSkyblock) return; @@ -781,7 +689,7 @@ public class DankersSkyblockMod { return; } } - + if (ToggleCommand.oruoToggled && Utils.inDungeons) { if (message.contains("What SkyBlock year is it?")) { double currentTime = System.currentTimeMillis() /1000L; diff --git a/src/main/java/me/Danker/commands/RepartyCommand.java b/src/main/java/me/Danker/commands/RepartyCommand.java index 92836c5..d3bf9e4 100644 --- a/src/main/java/me/Danker/commands/RepartyCommand.java +++ b/src/main/java/me/Danker/commands/RepartyCommand.java @@ -1,9 +1,9 @@ package me.Danker.commands; import me.Danker.DankersSkyblockMod; +import me.Danker.utils.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.gui.GuiNewChat; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommand; @@ -13,7 +13,6 @@ import net.minecraft.util.*; import net.minecraft.util.ChatComponentText; import net.minecraftforge.client.event.*; import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -26,16 +25,10 @@ import java.util.regex.Pattern; public class RepartyCommand extends CommandBase implements ICommand { public static double callTime = 0; - public static boolean gettingParty = false; - public static int Delimiter = 0; - public static boolean disbanding = false; - public static boolean inviting = false; - public static boolean failInviting = false; + public static boolean inviteFailed = false; public static String currentMember; public static List party = new ArrayList<>(); public static List repartyFailList = new ArrayList<>(); - public static List joinList = new ArrayList<>(); - public static Thread partyThread = null; @Override public String getCommandName() { @@ -59,87 +52,47 @@ public class RepartyCommand extends CommandBase implements ICommand { @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length > 0 && (args[0].startsWith("fail") || args[0].equals("f"))) { - partyThread = new Thread(() -> { - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; - RepartyCommand.callTime = (double) System.currentTimeMillis() / 1000; - GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); - - - try { - player.sendChatMessage("/p " + String.join(" ", repartyFailList)); - String members = String.join(EnumChatFormatting.WHITE + "\n- " + EnumChatFormatting.YELLOW, repartyFailList); - player.addChatMessage(new ChatComponentText(DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------\n" + - DankersSkyblockMod.MAIN_COLOUR + "Partying:" + EnumChatFormatting.WHITE + "\n- " + - EnumChatFormatting.YELLOW + members + "\n" + - DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------")); - failInviting = true; - while (failInviting) { - Thread.sleep(10); - } - if (repartyFailList.size() > 0) { - String repartyFails = String.join("\n- " + EnumChatFormatting.RED, repartyFailList); - player.addChatMessage(new ChatComponentText(DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------\n" + - DankersSkyblockMod.MAIN_COLOUR + "Failed to invite:" + EnumChatFormatting.WHITE + "\n- " + - EnumChatFormatting.RED + repartyFails + "\n" + - DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------")); - } - } catch (InterruptedException e) { - e.printStackTrace(); - } - }); - - partyThread.start(); - - return; - } - - party.clear(); repartyFailList.clear(); // MULTI THREAD DRIFTING - partyThread = new Thread(() -> { + new Thread(() -> { EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; RepartyCommand.callTime = (double) System.currentTimeMillis() / 1000; - GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); - - + try { - player.sendChatMessage("/pl"); - gettingParty = true; - while (gettingParty) { - Thread.sleep(10); - } - if (party.size() == 0) return; + Thread.sleep(210); + player.sendChatMessage("/p list"); + System.out.println("Grabbing the party members..."); + Thread.sleep(550); + if (RepartyCommand.party.size() == 0) return; + player.sendChatMessage("/p disband"); - disbanding = true; - while (disbanding) { - Thread.sleep(10); - } - player.sendChatMessage("/p " + String.join(" ", party)); - String members = String.join(EnumChatFormatting.WHITE + "\n- " + EnumChatFormatting.YELLOW, RepartyCommand.party); + Thread.sleep(210); + + String members = String.join(EnumChatFormatting.WHITE + "\n- " + EnumChatFormatting.GOLD, RepartyCommand.party); player.addChatMessage(new ChatComponentText(DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------\n" + - DankersSkyblockMod.MAIN_COLOUR + "Repartying:" + EnumChatFormatting.WHITE + "\n- " + - EnumChatFormatting.YELLOW + members + "\n" + - DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------")); - inviting = true; - repartyFailList = new ArrayList<>(party); - while (inviting) { - Thread.sleep(10); + DankersSkyblockMod.MAIN_COLOUR + "Repartying:" + EnumChatFormatting.WHITE + "\n- " + + EnumChatFormatting.GOLD + members + "\n" + + DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------\n")); + + for (int i = 0; i < RepartyCommand.party.size(); i++) { + RepartyCommand.currentMember = RepartyCommand.party.get(i); + player.sendChatMessage("/p " + RepartyCommand.currentMember); + Thread.sleep(400); } - if (repartyFailList.size() > 0) { - String repartyFails = String.join("\n- " + EnumChatFormatting.RED, repartyFailList); + + if (RepartyCommand.repartyFailList.size() > 0) { + Thread.sleep(300); + String failedMembers = String.join(EnumChatFormatting.WHITE + "\n- " + EnumChatFormatting.GOLD, RepartyCommand.repartyFailList); player.addChatMessage(new ChatComponentText(DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------\n" + - DankersSkyblockMod.MAIN_COLOUR + "Failed to invite:" + EnumChatFormatting.WHITE + "\n- " + - EnumChatFormatting.RED + repartyFails + "\n" + - DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------")); + DankersSkyblockMod.ERROR_COLOUR + "Unable to Invite:" + EnumChatFormatting.WHITE + "\n- " + + EnumChatFormatting.GOLD + failedMembers + "\n" + + DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------\n")); } } catch (InterruptedException e) { e.printStackTrace(); } - }); - - partyThread.start(); + }).start(); } } \ No newline at end of file -- cgit