diff options
author | flame-cat <kaldraganov05@gmail.com> | 2020-12-27 15:31:13 -0500 |
---|---|---|
committer | flame-cat <kaldraganov05@gmail.com> | 2020-12-27 15:31:13 -0500 |
commit | c23aabd86e5cf33d69afc6368f7a4ad28afaeea0 (patch) | |
tree | d92362c585211ffd9340888891de5dce52502008 /src/main | |
parent | 822bccd3221eab32a4bdd5c1e800ba37c262d44f (diff) | |
download | SkyblockMod-c23aabd86e5cf33d69afc6368f7a4ad28afaeea0.tar.gz SkyblockMod-c23aabd86e5cf33d69afc6368f7a4ad28afaeea0.tar.bz2 SkyblockMod-c23aabd86e5cf33d69afc6368f7a4ad28afaeea0.zip |
Add Error Message to Reparty
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/me/Danker/DankersSkyblockMod.java | 18 | ||||
-rw-r--r-- | src/main/java/me/Danker/commands/RepartyCommand.java | 40 |
2 files changed, 31 insertions, 27 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index a6cc772..ce02128 100644 --- a/src/main/java/me/Danker/DankersSkyblockMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -78,7 +78,7 @@ 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-beta5"; + public static final String VERSION = "1.8.5-beta6"; static double checkItemsNow = 0; static double itemsChecked = 0; @@ -103,9 +103,6 @@ public class DankersSkyblockMod static Entity livid = null; public static double cakeTime; - public static List<String> partyList = new ArrayList<>(); - public static List<String> repartyFailList = new ArrayList<>(); - public static final ResourceLocation CAKE_ICON = new ResourceLocation("dsm", "icons/cake.png"); static String[] riddleSolutions = {"The reward is not in my chest!", "At least one of them is lying, and the reward is not in", @@ -360,8 +357,8 @@ public class DankersSkyblockMod String message = StringUtils.stripControlCodes(event.message.getUnformattedText()); // Reparty command - if (System.currentTimeMillis() / 1000 - RepartyCommand.callTime <= 3) { - if (!(message.contains("----") || message.contains("disbanded") || message.contains("seconds to accept") || message.contains("●") || message.contains("Party Members"))) { + 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; } @@ -370,30 +367,27 @@ public class DankersSkyblockMod 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("cannot invite that player")) { - + 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())) { - partyList.add(partyMember); + RepartyCommand.party.add(partyMember); } } } - event.setCanceled(true); } diff --git a/src/main/java/me/Danker/commands/RepartyCommand.java b/src/main/java/me/Danker/commands/RepartyCommand.java index fbcea7f..6442588 100644 --- a/src/main/java/me/Danker/commands/RepartyCommand.java +++ b/src/main/java/me/Danker/commands/RepartyCommand.java @@ -25,6 +25,10 @@ import java.util.regex.Pattern; public class RepartyCommand extends CommandBase implements ICommand { public static double callTime = 0; + public static boolean inviteFailed = false; + public static String currentMember; + public static List<String> party = new ArrayList<>(); + public static List<String> repartyFailList = new ArrayList<>(); @Override public String getCommandName() { @@ -43,37 +47,43 @@ public class RepartyCommand extends CommandBase implements ICommand { @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { + party.clear(); + repartyFailList.clear(); + // MULTI THREAD DRIFTING new Thread(() -> { EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; - callTime = System.currentTimeMillis() / 1000; + RepartyCommand.callTime = (double) System.currentTimeMillis() / 1000; try { player.sendChatMessage("/p list"); - Thread.sleep(700); - - List<String> party = DankersSkyblockMod.partyList; - if (party.size() == 0) { - DankersSkyblockMod.partyList.clear(); - return; - } + System.out.println("Grabbing the party members..."); + Thread.sleep(550); + if (RepartyCommand.party.size() == 0) return; player.sendChatMessage("/p disband"); - Thread.sleep(250); + Thread.sleep(210); - String members = String.join(EnumChatFormatting.WHITE + "\n- " + EnumChatFormatting.GOLD, party); + 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.GOLD + members + "\n" + DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------\n")); - Thread.sleep(250); - for (int i = 0; i < party.size(); i++) { - player.sendChatMessage("/p " + party.get(i)); - Thread.sleep(250); + for (int i = 0; i < RepartyCommand.party.size(); i++) { + RepartyCommand.currentMember = RepartyCommand.party.get(i); + player.sendChatMessage("/p " + RepartyCommand.currentMember); + Thread.sleep(400); } - DankersSkyblockMod.partyList.clear(); + 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.ERROR_COLOUR + "Unable to Invite:" + EnumChatFormatting.WHITE + "\n- " + + EnumChatFormatting.GOLD + failedMembers + "\n" + + DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------\n")); + } } catch (InterruptedException e) { e.printStackTrace(); } |