diff options
Diffstat (limited to 'src/main/java/me/Danker')
-rw-r--r-- | src/main/java/me/Danker/DankersSkyblockMod.java | 46 | ||||
-rw-r--r-- | src/main/java/me/Danker/commands/RepartyCommand.java | 78 | ||||
-rw-r--r-- | src/main/java/me/Danker/handlers/ConfigHandler.java | 3 |
3 files changed, 122 insertions, 5 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index bfd776d..8688bee 100644 --- a/src/main/java/me/Danker/DankersSkyblockMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -185,7 +185,9 @@ public class DankersSkyblockMod public static int PET_70_TO_79; public static int PET_80_TO_89; public static int PET_90_TO_99; - public static int PET_100; + public static int PET_100; + + public static List<String> partyList = new ArrayList<>(); @EventHandler public void init(FMLInitializationEvent event) { @@ -300,7 +302,8 @@ public class DankersSkyblockMod ClientCommandHandler.instance.registerCommand(new DungeonsCommand()); ClientCommandHandler.instance.registerCommand(new LobbySkillsCommand()); ClientCommandHandler.instance.registerCommand(new DankerGuiCommand()); - ClientCommandHandler.instance.registerCommand(new SkillTrackerCommand()); + ClientCommandHandler.instance.registerCommand(new SkillTrackerCommand()); + ClientCommandHandler.instance.registerCommand(new RepartyCommand()); } @EventHandler @@ -353,7 +356,42 @@ public class DankersSkyblockMod @SubscribeEvent(priority = EventPriority.HIGHEST) public void onChat(ClientChatReceivedEvent event) { String message = StringUtils.stripControlCodes(event.message.getUnformattedText()); - + + // Reparty command + if (System.currentTimeMillis() / 1000 - RepartyCommand.callTime <= 1.5) { + if (!(message.contains("----") || message.contains("disbanded") || message.contains("seconds to accept") || message.contains("●") || message.contains("Party Members"))) { + 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 { + while (members.find()) { + String partyMember = members.group(1); + if (!partyMember.equals(player.getName())) { + partyList.add(partyMember); + } + } + } + + event.setCanceled(true); + } + if (!Utils.inSkyblock) return; // Action Bar @@ -540,7 +578,7 @@ public class DankersSkyblockMod } } } - + if (ToggleCommand.golemAlertToggled) { if (message.contains("The ground begins to shake as an Endstone Protector rises from below!")) { Utils.createTitle(EnumChatFormatting.RED + "GOLEM SPAWNING!", 3); diff --git a/src/main/java/me/Danker/commands/RepartyCommand.java b/src/main/java/me/Danker/commands/RepartyCommand.java new file mode 100644 index 0000000..3ade5e9 --- /dev/null +++ b/src/main/java/me/Danker/commands/RepartyCommand.java @@ -0,0 +1,78 @@ +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.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +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.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.*; +import java.text.NumberFormat; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + + +public class RepartyCommand extends CommandBase implements ICommand { + public static double callTime = 0; + + @Override + public String getCommandName() { return "reparty"; } + + @Override + public String getCommandUsage(ICommandSender sender) { return "/" + getCommandName(); } + + @Override + public int getRequiredPermissionLevel() { return 0; } + + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + // MULTI THREAD DRIFTING + new Thread(() -> { + final EntityPlayer player_unused = (EntityPlayer) sender; + EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + callTime = System.currentTimeMillis() / 1000; + + try { + player.sendChatMessage("/p list"); + Thread.sleep(700); + + List<String> party = DankersSkyblockMod.partyList; + if (party.size() == 0) { + DankersSkyblockMod.partyList.clear(); + return; + } + + player.sendChatMessage("/p disband"); + Thread.sleep(250); + + String members = String.join(DankersSkyblockMod.SECONDARY_COLOUR + "\n- " + EnumChatFormatting.GOLD, party); + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------\n" + + DankersSkyblockMod.MAIN_COLOUR + "Repartying:" + DankersSkyblockMod.SECONDARY_COLOUR + "\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); + } + + DankersSkyblockMod.partyList.clear(); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + }).start(); + } +}
\ No newline at end of file diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java index 7bf6ce2..f7ca598 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -411,7 +411,8 @@ public class ConfigHandler { if (!hasKey("colors", "main")) writeStringConfig("colors", "main", EnumChatFormatting.GREEN.toString()); if (!hasKey("colors", "secondary")) writeStringConfig("colors", "secondary", EnumChatFormatting.DARK_GREEN.toString()); - if (!hasKey("colors", "delimiter")) writeStringConfig("colors", "delimiter", EnumChatFormatting.AQUA.toString()); + if (!hasKey("colors", "delimiter")) writeStringConfig("colors", "delimiter", EnumChatFormatting.AQUA.toString() + EnumChatFormatting.STRIKETHROUGH.toString()); + if (!getString("colors", "delimiter").contains(EnumChatFormatting.STRIKETHROUGH.toString())) writeStringConfig("colors", "delimiter", getString("colors", "delimiter") + EnumChatFormatting.STRIKETHROUGH.toString()); if (!hasKey("colors", "error")) writeStringConfig("colors", "error", EnumChatFormatting.RED.toString()); if (!hasKey("colors", "type")) writeStringConfig("colors", "type", EnumChatFormatting.GREEN.toString()); if (!hasKey("colors", "value")) writeStringConfig("colors", "value", EnumChatFormatting.DARK_GREEN.toString()); |