diff --git a/src/main/java/me/night0721/lilase/Main.java b/src/main/java/me/night0721/lilase/Main.java index 428697f..a1c2832 100644 --- a/src/main/java/me/night0721/lilase/Main.java +++ b/src/main/java/me/night0721/lilase/Main.java @@ -2,6 +2,7 @@ package me.night0721.lilase; import com.mojang.realmsclient.gui.ChatFormatting; import me.night0721.lilase.events.PacketReceivedEvent; +import me.night0721.lilase.features.ah.States; import me.night0721.lilase.utils.AuctionHouse; import me.night0721.lilase.utils.ConfigUtils; import me.night0721.lilase.utils.Utils; @@ -76,7 +77,11 @@ public class Main { String message = event.message.getUnformattedText(); if (!message.contains(":")) { if (message.equals("You didn't participate in this auction!")) { - System.out.println("Failed to buy item, closing the menu"); + System.out.println("Failed to buy item, not fast enough. Closing the menu"); + mc.playerController.windowClick(mc.thePlayer.openContainer.windowId, 49, 0, 0, mc.thePlayer); // Close the window as could not buy + } else if (message.equals("You don't have enough coins to afford this bid!")) { + System.out.println("Failed to buy item, not enough money. Closing the menu"); + AuctionHouse.clickState = States.STOP; mc.playerController.windowClick(mc.thePlayer.openContainer.windowId, 49, 0, 0, mc.thePlayer); // Close the window as could not buy } } diff --git a/src/main/java/me/night0721/lilase/features/ah/States.java b/src/main/java/me/night0721/lilase/features/ah/States.java new file mode 100644 index 0000000..6fb818d --- /dev/null +++ b/src/main/java/me/night0721/lilase/features/ah/States.java @@ -0,0 +1,5 @@ +package me.night0721.lilase.features.ah; + +public enum States { + OPEN, NONE, CLICK, CONFIRM, STOP +} \ No newline at end of file diff --git a/src/main/java/me/night0721/lilase/utils/AuctionHouse.java b/src/main/java/me/night0721/lilase/utils/AuctionHouse.java index a0f02b3..d5d5078 100644 --- a/src/main/java/me/night0721/lilase/utils/AuctionHouse.java +++ b/src/main/java/me/night0721/lilase/utils/AuctionHouse.java @@ -1,5 +1,6 @@ package me.night0721.lilase.utils; +import me.night0721.lilase.features.ah.States; import net.minecraft.client.Minecraft; import org.json.JSONArray; import org.json.JSONException; @@ -24,7 +25,7 @@ public class AuctionHouse { private static String uuid; private static String message_toSend; private static long lastAction; - private Thread thread; + private static Thread thread; private Boolean open = false; private final DiscordWebhook webhook; private final List items = new ArrayList<>(); @@ -117,8 +118,6 @@ public class AuctionHouse { Pattern pattern = Pattern.compile("ยง[0-9a-z]", Pattern.MULTILINE); Matcher matcher = pattern.matcher(auction.getString("item_lore")); String updated = matcher.replaceAll(""); - System.out.println(updated); - webhook.addEmbed( new DiscordWebhook.EmbedObject() .setTitle("Item Is On Low Price") @@ -205,7 +204,6 @@ public class AuctionHouse { open = true; } } - public static void switchStates() { switch (clickState) { case CLICK: @@ -223,15 +221,14 @@ public class AuctionHouse { AuctionHouse.sendAuction(); lastAction = System.currentTimeMillis(); clickState = States.CLICK; + case STOP: + thread = null; case NONE: break; } } } -enum States { - OPEN, NONE, CLICK, CONFIRM -} enum ItemTier { ANY, COMMON, UNCOMMON, RARE, EPIC, LEGENDARY, MYTHIC, DIVINE, SPECIAL, VERY_SPECIAL, diff --git a/src/main/java/me/night0721/lilase/utils/DiscordWebhook.java b/src/main/java/me/night0721/lilase/utils/DiscordWebhook.java index 5f71859..a05016b 100644 --- a/src/main/java/me/night0721/lilase/utils/DiscordWebhook.java +++ b/src/main/java/me/night0721/lilase/utils/DiscordWebhook.java @@ -143,7 +143,6 @@ public class DiscordWebhook { connection.addRequestProperty("User-Agent", "Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"); connection.setDoOutput(true); connection.setRequestMethod("POST"); - System.out.println(json); OutputStream stream = connection.getOutputStream(); stream.write(json.toString().getBytes(StandardCharsets.UTF_8)); stream.flush();