aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/commands
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-01-09 18:55:10 +0900
committersyeyoung <cyong06@naver.com>2021-01-09 18:55:10 +0900
commit41535cf2d3dd84e3f3d1059666a584a5fdaa263c (patch)
tree402fcbfb47fdff15b44583d8a876a8e15d969918 /src/main/java/kr/syeyoung/dungeonsguide/commands
parent282c57eceb033bb5b98fe8d742db983716a90594 (diff)
downloadSkyblock-Dungeons-Guide-41535cf2d3dd84e3f3d1059666a584a5fdaa263c.tar.gz
Skyblock-Dungeons-Guide-41535cf2d3dd84e3f3d1059666a584a5fdaa263c.tar.bz2
Skyblock-Dungeons-Guide-41535cf2d3dd84e3f3d1059666a584a5fdaa263c.zip
BETTUH
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/commands')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/commands/CommandReparty.java60
1 files changed, 59 insertions, 1 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandReparty.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandReparty.java
index 92d5546a..10e99dc6 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandReparty.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandReparty.java
@@ -3,6 +3,7 @@ package kr.syeyoung.dungeonsguide.commands;
import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry;
import kr.syeyoung.dungeonsguide.e;
+import kr.syeyoung.dungeonsguide.utils.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
@@ -10,6 +11,7 @@ import net.minecraft.util.ChatComponentText;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
+import scala.collection.parallel.ParIterableLike;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
@@ -18,6 +20,8 @@ import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.List;
public class CommandReparty extends CommandBase {
@Override
@@ -32,17 +36,71 @@ public class CommandReparty extends CommandBase {
@Override
public void processCommand(ICommandSender sender, String[] args) {
+ requestReparty();
+ }
+ public static enum Phase {
+ NOT,
+ REQUESTED,
+ RECEIVE_PARTYMEMBERS,
+ DISBAND,
+ REPARTY
}
+ private List<String> players = new ArrayList<String>();
+ private long nextTrigger = Long.MAX_VALUE;
+ private Phase phase = Phase.NOT;
@SubscribeEvent
public void onChat(ClientChatReceivedEvent e) {
-
+ if (e.type == 2) return;
+ if (e.message.getFormattedText().startsWith("§6Party Members ") && phase == Phase.REQUESTED) {
+ players.clear();
+ phase = Phase.RECEIVE_PARTYMEMBERS;
+ }
+ if (e.message.getFormattedText().startsWith("§cYou are not currently in a party.§r") && phase == Phase.REQUESTED) {
+ phase = Phase.NOT;
+ }
+ String txt = e.message.getFormattedText();
+ if (txt.startsWith("§eParty ") && txt.contains(":")) {
+ String playerNames = TextUtils.stripColor(txt.split(":")[1]);
+ for (String s : playerNames.split(" ")) {
+ if (s.isEmpty()) continue;
+ if (s.equals("●")) continue;
+ if (s.startsWith("[")) continue;
+ players.add(s);
+ }
+ }
+ if (e.message.getFormattedText().equals("§9§m-----------------------------§r") && phase == Phase.RECEIVE_PARTYMEMBERS) {
+ phase = Phase.DISBAND;
+ nextTrigger = System.currentTimeMillis() + 500;
+ }
}
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent e) {
+ if (nextTrigger < System.currentTimeMillis() && (phase == Phase.DISBAND || phase == Phase.REPARTY)) {
+ if (phase == Phase.DISBAND) {
+ nextTrigger = System.currentTimeMillis() + 1000;
+ phase = Phase.REPARTY;
+ Minecraft.getMinecraft().thePlayer.sendChatMessage("/p disband");
+ } else {
+ phase = Phase.NOT;
+ nextTrigger = Long.MAX_VALUE;
+ StringBuilder sb = new StringBuilder();
+ sb.append("/p invite");
+ for (String player : players) {
+ sb.append(" ").append(player);
+ }
+ Minecraft.getMinecraft().thePlayer.sendChatMessage(sb.toString());
+ }
+ }
+ }
+ public void requestReparty() {
+ if (phase == Phase.NOT) {
+ phase = Phase.REQUESTED;
+ Minecraft.getMinecraft().thePlayer.sendChatMessage("/pl");
+ }
}
@Override