aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/commands/RepartyCommand.java
blob: 6442588771607d3ba3a0ea0815310f68dbed1127 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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;
    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() { 
        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 {
        party.clear();
        repartyFailList.clear();

        // MULTI THREAD DRIFTING
		new Thread(() -> {
            EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
            RepartyCommand.callTime = (double) System.currentTimeMillis() / 1000;
            
            try {
                player.sendChatMessage("/p list");
                System.out.println("Grabbing the party members...");
                Thread.sleep(550);
                if (RepartyCommand.party.size() == 0) return;
                
                player.sendChatMessage("/p disband");
                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.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 (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();
            }
        }).start();
    }
}