blob: a404bf527e4e60c0416434321f2cb39a5172335e (
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
package me.Danker.features;
import me.Danker.DankersSkyblockMod;
import me.Danker.commands.RepartyCommand;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.StringUtils;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Reparty {
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onChat(ClientChatReceivedEvent event) {
String message = StringUtils.stripControlCodes(event.message.getUnformattedText());
// 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("-----")) {
switch (RepartyCommand.Delimiter) {
case 1:
event.setCanceled(true);
RepartyCommand.Delimiter = 0;
System.out.println("Player Invited!");
RepartyCommand.inviting = false;
return;
case 0:
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("-----")) {
switch (RepartyCommand.Delimiter) {
case 1:
event.setCanceled(true);
RepartyCommand.Delimiter = 0;
System.out.println("Player Invited!");
RepartyCommand.inviting = false;
return;
case 0:
RepartyCommand.Delimiter++;
event.setCanceled(true);
}
} 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);
} else if (message.contains("Couldn't find a player") || message.contains("You cannot invite that player")) {
event.setCanceled(true);
}
}
}
}
|