aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyeyoung <cyoung06@naver.com>2021-11-27 23:31:50 +0900
committersyeyoung <cyoung06@naver.com>2021-11-27 23:31:50 +0900
commit3b1a4bce80b9634d05b519a74db8e5f12970a853 (patch)
treeefed3a91f334f3f1416e9b0bd01c66c7e79f3641 /src
parentd239ae4d4748fc4867ab45a5cc7d42bfb5ac547c (diff)
downloadSkyblock-Dungeons-Guide-3b1a4bce80b9634d05b519a74db8e5f12970a853.tar.gz
Skyblock-Dungeons-Guide-3b1a4bce80b9634d05b519a74db8e5f12970a853.tar.bz2
Skyblock-Dungeons-Guide-3b1a4bce80b9634d05b519a74db8e5f12970a853.zip
- New Reparty using new PartyManager
Diffstat (limited to 'src')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/commands/CommandReparty.java105
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureAutoReparty.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureAutoAcceptReparty.java4
4 files changed, 52 insertions, 63 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java
index 914ca8e8..d7bee24f 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java
@@ -145,7 +145,9 @@ public class CommandDungeonsGuide extends CommandBase {
String serverBrand = Minecraft.getMinecraft().thePlayer.getClientBrand();
sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e" + serverBrand));
} else if (args[0].equalsIgnoreCase("reparty")) {
- DungeonsGuide.getDungeonsGuide().getCommandReparty().requestReparty();
+ if (!DungeonsGuide.getDungeonsGuide().getCommandReparty().requestReparty(false)) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §cCurrently Repartying"));
+ }
} else if (args[0].equalsIgnoreCase("gui")) {
openConfig = true;
} else if (args[0].equalsIgnoreCase("info")) {
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandReparty.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandReparty.java
index 26f8cfd0..8df85529 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandReparty.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandReparty.java
@@ -18,17 +18,22 @@
package kr.syeyoung.dungeonsguide.commands;
+import kr.syeyoung.dungeonsguide.chat.ChatProcessor;
+import kr.syeyoung.dungeonsguide.chat.PartyManager;
import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
import kr.syeyoung.dungeonsguide.utils.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
+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 java.util.ArrayList;
import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
public class CommandReparty extends CommandBase {
private String command;
@@ -49,73 +54,53 @@ public class CommandReparty extends CommandBase {
@Override
public void processCommand(ICommandSender sender, String[] args) {
- requestReparty();
+ if (!requestReparty(false)) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §cCurrently Repartying"));
+ }
}
- public enum Phase {
- NOT,
- REQUESTED,
- RECEIVE_PARTYMEMBERS,
- DISBAND,
- REPARTY
- }
+ private boolean reparting = false;
- private final 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]);
- String myname = Minecraft.getMinecraft().getSession().getUsername();
- for (String s : playerNames.split(" ")) {
- if (s.isEmpty()) continue;
- if (s.equals("●")) continue;
- if (s.startsWith("[")) continue;
- if (s.equalsIgnoreCase(myname)) continue;
- players.add(s);
- }
- }
- if (e.message.getFormattedText().equals("§9§m-----------------------------§r") && phase == Phase.RECEIVE_PARTYMEMBERS) {
- phase = Phase.DISBAND;
- nextTrigger = System.currentTimeMillis() + 500;
+
+ public boolean requestReparty(boolean noerror) {
+ if (reparting) {
+ return false;
}
- }
+ reparting = true;
- @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());
+ PartyManager.INSTANCE.requestPartyList(pc -> {
+ if (pc == null) {
+ if (!noerror)
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §cNot in Party"));
+ reparting = false;
+ return;
}
- }
- }
+ if (!pc.hasLeader(Minecraft.getMinecraft().getSession().getUsername())) {
+ if (!noerror)
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §cYou're not leader"));
+ reparting = false;
+ return;
+ }
+ if (pc.isSelfSolo()) {
+ if (!noerror)
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §cYou can not reparty yourself"));
+ reparting = false;
+ return;
+ }
+ String members = pc.getPartyRawMembers().stream().filter(a -> !a.equalsIgnoreCase(Minecraft.getMinecraft().getSession().getUsername())).collect(Collectors.joining(" "));
+ String command = "/p invite "+members;
- public void requestReparty() {
- if (phase == Phase.NOT) {
- phase = Phase.REQUESTED;
- Minecraft.getMinecraft().thePlayer.sendChatMessage("/pl");
- }
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §eDisbanding Party..."));
+ ChatProcessor.INSTANCE.addToChatQueue("/p disband", () -> {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §eRunning invite command §f"+command));
+ ChatProcessor.INSTANCE.addToChatQueue(command, () -> {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §eSuccessfully repartied!§f"));
+
+ reparting = false;
+ }, false);
+ }, false);
+ });
+ return true;
}
@Override
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureAutoReparty.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureAutoReparty.java
index 67254ff1..ad6b7200 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureAutoReparty.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureAutoReparty.java
@@ -29,6 +29,6 @@ public class FeatureAutoReparty extends SimpleFeature implements DungeonQuitList
@Override
public void onDungeonQuit() {
- if (isEnabled()) DungeonsGuide.getDungeonsGuide().getCommandReparty().requestReparty();
+ if (isEnabled()) DungeonsGuide.getDungeonsGuide().getCommandReparty().requestReparty(true);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureAutoAcceptReparty.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureAutoAcceptReparty.java
index 84c22353..3a469793 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureAutoAcceptReparty.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureAutoAcceptReparty.java
@@ -20,7 +20,9 @@ package kr.syeyoung.dungeonsguide.features.impl.etc;
import kr.syeyoung.dungeonsguide.SkyblockStatus;
import kr.syeyoung.dungeonsguide.DungeonsGuide;
+import kr.syeyoung.dungeonsguide.chat.ChatProcessor;
import kr.syeyoung.dungeonsguide.features.SimpleFeature;
+import kr.syeyoung.dungeonsguide.features.impl.party.api.ApiFetchur;
import kr.syeyoung.dungeonsguide.features.listener.ChatListener;
import kr.syeyoung.dungeonsguide.utils.TextUtils;
import net.minecraft.client.Minecraft;
@@ -60,7 +62,7 @@ public class FeatureAutoAcceptReparty extends SimpleFeature implements ChatListe
}
if (equals && isEnabled()) {
- Minecraft.getMinecraft().thePlayer.sendChatMessage("/p join "+lastDisband);
+ ChatProcessor.INSTANCE.addToChatQueue("/p accept " + lastDisband, () -> {}, true);
lastDisband = null;
}
}