aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker
diff options
context:
space:
mode:
authorSychic <Sychic@github.com>2021-01-05 22:50:33 -0500
committerSychic <Sychic@github.com>2021-01-05 22:50:33 -0500
commit320dab0e8050e4d771c339c3c836035a0a8df990 (patch)
treeff5464464b7edb37a9acf1b6637d15d5efdcad24 /src/main/java/me/Danker
parent9fa3405d2ac107488634af3fc7302954d90f4b17 (diff)
downloadSkyblockMod-320dab0e8050e4d771c339c3c836035a0a8df990.tar.gz
SkyblockMod-320dab0e8050e4d771c339c3c836035a0a8df990.tar.bz2
SkyblockMod-320dab0e8050e4d771c339c3c836035a0a8df990.zip
Reparty Edits: Change message cancelling and reparty fail handling. (also add a miscellanous logger for debugging)
Diffstat (limited to 'src/main/java/me/Danker')
-rw-r--r--src/main/java/me/Danker/DankersSkyblockMod.java160
-rw-r--r--src/main/java/me/Danker/commands/RepartyCommand.java105
2 files changed, 202 insertions, 63 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java
index 0bcecba..8285bec 100644
--- a/src/main/java/me/Danker/DankersSkyblockMod.java
+++ b/src/main/java/me/Danker/DankersSkyblockMod.java
@@ -63,6 +63,7 @@ import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent;
import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion;
import org.apache.commons.lang3.time.StopWatch;
+import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -79,6 +80,7 @@ import java.util.regex.Pattern;
public class DankersSkyblockMod {
public static final String MODID = "Danker's Skyblock Mod";
public static final String VERSION = "1.8.5-beta8";
+ public static Logger DSMLogger;
static double checkItemsNow = 0;
static double itemsChecked = 0;
public static Map<String, String> t6Enchants = new HashMap<>();
@@ -108,8 +110,9 @@ public class DankersSkyblockMod {
public static final ResourceLocation CAKE_ICON = new ResourceLocation("dsm", "icons/cake.png");
public static final ResourceLocation BONZO_ICON = new ResourceLocation("dsm", "icons/bonzo.png");
+ public static final ResourceLocation LOGO = new ResourceLocation("dsm", "icons/dsm.png");
- static String[] riddleSolutions = {"The reward is not in my chest!", "At least one of them is lying, and the reward is not in",
+ static String[] riddleSolutions = {"The reward is not in my chest!", "At least one of them is lying, and the reward is not in",
"My chest doesn't have the reward. We are all telling the truth", "My chest has the reward and I'm telling the truth",
"The reward isn't in any of our chests", "Both of them are telling the truth."};
static Map<String, String[]> triviaSolutions = new HashMap<>();
@@ -285,6 +288,7 @@ public class DankersSkyblockMod {
@EventHandler
public void preInit(final FMLPreInitializationEvent event) {
+ DSMLogger = event.getModLog();
ClientCommandHandler.instance.registerCommand(new ToggleCommand());
ClientCommandHandler.instance.registerCommand(new SetkeyCommand());
ClientCommandHandler.instance.registerCommand(new GetkeyCommand());
@@ -315,6 +319,7 @@ public class DankersSkyblockMod {
public void postInit(final FMLPostInitializationEvent event) {
Package[] packages = Package.getPackages();
for(Package p : packages){
+ DSMLogger.info(p);
if(p.getName().startsWith("com.spiderfrog.gadgets") || p.getName().startsWith("com.spiderfrog.oldanimations")){
usingOAM = true;
break;
@@ -426,38 +431,125 @@ public class DankersSkyblockMod {
}
// Reparty command
- if (System.currentTimeMillis() / 1000 - RepartyCommand.callTime <= 5) {
- if (!(message.contains("----") || message.contains("disbanded") || message.contains("seconds to accept") || message.contains("●") || message.contains("Party Members") || message.contains("Couldn't find a player") || message.contains("cannot invite that player") || message.length() == 0)) {
- return;
- }
-
- 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."));
- }
- else if (leader.matches() && !(leader.group(1).equals(player.getName()))) {
- player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "You are not party leader."));
- }
- else if (message.contains("Couldn't find a player") || message.contains("You cannot invite that player")) {
- RepartyCommand.repartyFailList.add(RepartyCommand.currentMember);
- }
- else {
- while (members.find()) {
- String partyMember = members.group(1);
- if (!partyMember.equals(player.getName())) {
- RepartyCommand.party.add(partyMember);
- }
- }
- }
- event.setCanceled(true);
+ // 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("-----")) {
+ if (RepartyCommand.Delimiter >= RepartyCommand.party.size() * 2 - 1) {
+ event.setCanceled(true);
+ RepartyCommand.Delimiter = 0;
+ System.out.println("Done Inviting!");
+ RepartyCommand.inviting = false;
+ return;
+ } else {
+ 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("-----")) {
+ if (RepartyCommand.Delimiter >= RepartyCommand.repartyFailList.size() * 2 - 1) {
+ event.setCanceled(true);
+ RepartyCommand.Delimiter = 0;
+ System.out.println("Done Inviting!");
+ RepartyCommand.inviting = false;
+ return;
+ } else {
+ 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;
+ }
}
if (!Utils.inSkyblock) return;
@@ -689,7 +781,7 @@ public class DankersSkyblockMod {
return;
}
}
-
+
if (ToggleCommand.oruoToggled && Utils.inDungeons) {
if (message.contains("What SkyBlock year is it?")) {
double currentTime = System.currentTimeMillis() /1000L;
diff --git a/src/main/java/me/Danker/commands/RepartyCommand.java b/src/main/java/me/Danker/commands/RepartyCommand.java
index d3bf9e4..92836c5 100644
--- a/src/main/java/me/Danker/commands/RepartyCommand.java
+++ b/src/main/java/me/Danker/commands/RepartyCommand.java
@@ -1,9 +1,9 @@
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.client.gui.GuiNewChat;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommand;
@@ -13,6 +13,7 @@ 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.ObfuscationReflectionHelper;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -25,10 +26,16 @@ import java.util.regex.Pattern;
public class RepartyCommand extends CommandBase implements ICommand {
public static double callTime = 0;
- public static boolean inviteFailed = false;
+ public static boolean gettingParty = false;
+ public static int Delimiter = 0;
+ public static boolean disbanding = false;
+ public static boolean inviting = false;
+ public static boolean failInviting = false;
public static String currentMember;
public static List<String> party = new ArrayList<>();
public static List<String> repartyFailList = new ArrayList<>();
+ public static List<String> joinList = new ArrayList<>();
+ public static Thread partyThread = null;
@Override
public String getCommandName() {
@@ -52,47 +59,87 @@ public class RepartyCommand extends CommandBase implements ICommand {
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ if (args.length > 0 && (args[0].startsWith("fail") || args[0].equals("f"))) {
+ partyThread = new Thread(() -> {
+ EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ RepartyCommand.callTime = (double) System.currentTimeMillis() / 1000;
+ GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI();
+
+
+ try {
+ player.sendChatMessage("/p " + String.join(" ", repartyFailList));
+ String members = String.join(EnumChatFormatting.WHITE + "\n- " + EnumChatFormatting.YELLOW, repartyFailList);
+ player.addChatMessage(new ChatComponentText(DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------\n" +
+ DankersSkyblockMod.MAIN_COLOUR + "Partying:" + EnumChatFormatting.WHITE + "\n- " +
+ EnumChatFormatting.YELLOW + members + "\n" +
+ DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------"));
+ failInviting = true;
+ while (failInviting) {
+ Thread.sleep(10);
+ }
+ if (repartyFailList.size() > 0) {
+ String repartyFails = String.join("\n- " + EnumChatFormatting.RED, repartyFailList);
+ player.addChatMessage(new ChatComponentText(DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------\n" +
+ DankersSkyblockMod.MAIN_COLOUR + "Failed to invite:" + EnumChatFormatting.WHITE + "\n- " +
+ EnumChatFormatting.RED + repartyFails + "\n" +
+ DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------"));
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ });
+
+ partyThread.start();
+
+ return;
+ }
+
+
party.clear();
repartyFailList.clear();
// MULTI THREAD DRIFTING
- new Thread(() -> {
+ partyThread = new Thread(() -> {
EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
RepartyCommand.callTime = (double) System.currentTimeMillis() / 1000;
-
+ GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI();
+
+
try {
- Thread.sleep(210);
- player.sendChatMessage("/p list");
- System.out.println("Grabbing the party members...");
- Thread.sleep(550);
- if (RepartyCommand.party.size() == 0) return;
-
+ player.sendChatMessage("/pl");
+ gettingParty = true;
+ while (gettingParty) {
+ Thread.sleep(10);
+ }
+ if (party.size() == 0) return;
player.sendChatMessage("/p disband");
- Thread.sleep(210);
-
- String members = String.join(EnumChatFormatting.WHITE + "\n- " + EnumChatFormatting.GOLD, RepartyCommand.party);
+ disbanding = true;
+ while (disbanding) {
+ Thread.sleep(10);
+ }
+ player.sendChatMessage("/p " + String.join(" ", party));
+ String members = String.join(EnumChatFormatting.WHITE + "\n- " + EnumChatFormatting.YELLOW, 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);
+ DankersSkyblockMod.MAIN_COLOUR + "Repartying:" + EnumChatFormatting.WHITE + "\n- " +
+ EnumChatFormatting.YELLOW + members + "\n" +
+ DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------"));
+ inviting = true;
+ repartyFailList = new ArrayList<>(party);
+ while (inviting) {
+ Thread.sleep(10);
}
-
- if (RepartyCommand.repartyFailList.size() > 0) {
- Thread.sleep(300);
- String failedMembers = String.join(EnumChatFormatting.WHITE + "\n- " + EnumChatFormatting.GOLD, RepartyCommand.repartyFailList);
+ if (repartyFailList.size() > 0) {
+ String repartyFails = String.join("\n- " + EnumChatFormatting.RED, 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"));
+ DankersSkyblockMod.MAIN_COLOUR + "Failed to invite:" + EnumChatFormatting.WHITE + "\n- " +
+ EnumChatFormatting.RED + repartyFails + "\n" +
+ DankersSkyblockMod.DELIMITER_COLOUR + "-----------------------------"));
}
} catch (InterruptedException e) {
e.printStackTrace();
}
- }).start();
+ });
+
+ partyThread.start();
}
} \ No newline at end of file