aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/Reparty.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/Reparty.java')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/Reparty.java43
1 files changed, 16 insertions, 27 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/Reparty.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/Reparty.java
index c3da7c18..3af82b6e 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/Reparty.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/Reparty.java
@@ -16,7 +16,7 @@ public class Reparty extends ChatPatternListener {
private static final MinecraftClient client = MinecraftClient.getInstance();
private static final SkyblockerMod skyblocker = SkyblockerMod.getInstance();
public static final Pattern PLAYER = Pattern.compile(" ([a-zA-Z0-9_]{2,16}) ●");
- private static final int BASE_DELAY = 20;
+ private static final int BASE_DELAY = 10;
private String[] players;
private int playersSoFar;
@@ -24,12 +24,11 @@ public class Reparty extends ChatPatternListener {
public Reparty() {
super("^(?:You are not currently in a party\\.|Party (?:Membe|Moderato)rs(?: \\(([0-9]+)\\)|:( .*)))$");
- repartying = false;
+ this.repartying = false;
ClientCommandManager.DISPATCHER.register(
ClientCommandManager.literal("rp").executes(context -> {
- if (!Utils.isOnSkyblock || repartying || client.player == null)
- return 0;
- repartying = true;
+ if (!Utils.isOnSkyblock || this.repartying || client.player == null) return 0;
+ this.repartying = true;
client.player.sendChatMessage("/p list");
return 0;
})
@@ -38,52 +37,42 @@ public class Reparty extends ChatPatternListener {
@Override
public ChatFilterResult state() {
- return repartying ? ChatFilterResult.FILTER : ChatFilterResult.PASS;
+ return this.repartying ? ChatFilterResult.FILTER : ChatFilterResult.PASS;
}
@Override
public boolean onMatch(Text message, Matcher matcher) {
if (matcher.group(1) != null) {
- playersSoFar = 0;
- players = new String[Integer.parseInt(matcher.group(1)) - 1];
+ this.playersSoFar = 0;
+ this.players = new String[Integer.parseInt(matcher.group(1)) - 1];
} else if (matcher.group(2) != null) {
Matcher m = PLAYER.matcher(matcher.group(2));
while (m.find()) {
- players[playersSoFar++] = m.group(1);
+ this.players[playersSoFar++] = m.group(1);
}
} else {
- repartying = false;
+ this.repartying = false;
return false;
}
- if (playersSoFar == players.length)
- reparty();
+ if (this.playersSoFar == this.players.length) reparty();
return false;
}
private void reparty() {
ClientPlayerEntity playerEntity = client.player;
if (playerEntity == null) {
- repartying = false;
+ this.repartying = false;
return;
}
sendCommand(playerEntity, "/p disband", 1);
- StringBuilder sb = new StringBuilder();
- int invites = (players.length - 1) / 5 + 1;
- for (int i = 0; i < invites; i++) {
- sb.setLength(0);
- sb.append("/p invite");
- for (int j = 0; j < 5 && i * 5 + j < players.length; j++) {
- sb.append(' ');
- sb.append(players[i * 5 + j]);
- }
- sendCommand(playerEntity, sb.toString(), i + 2);
+ for (int i = 0; i < this.players.length; ++i) {
+ String command = "/p invite " + this.players[i];
+ sendCommand(playerEntity, command, i + 2);
}
- skyblocker.scheduler.schedule(() -> repartying = false, invites + 2);
+ skyblocker.scheduler.schedule(() -> this.repartying = false, this.players.length + 2);
}
private void sendCommand(ClientPlayerEntity player, String command, int delay) {
- skyblocker.scheduler.schedule(() ->
- player.sendChatMessage(command), delay * BASE_DELAY
- );
+ skyblocker.scheduler.schedule(() -> player.sendChatMessage(command), delay * BASE_DELAY);
}
}