improvements

This commit is contained in:
NK 2023-02-20 13:45:37 +00:00
parent 5d7f53ce68
commit 32992a720e
4 changed files with 15 additions and 9 deletions

View file

@ -2,6 +2,7 @@ package me.night0721.lilase;
import com.mojang.realmsclient.gui.ChatFormatting; import com.mojang.realmsclient.gui.ChatFormatting;
import me.night0721.lilase.events.PacketReceivedEvent; import me.night0721.lilase.events.PacketReceivedEvent;
import me.night0721.lilase.features.ah.States;
import me.night0721.lilase.utils.AuctionHouse; import me.night0721.lilase.utils.AuctionHouse;
import me.night0721.lilase.utils.ConfigUtils; import me.night0721.lilase.utils.ConfigUtils;
import me.night0721.lilase.utils.Utils; import me.night0721.lilase.utils.Utils;
@ -76,7 +77,11 @@ public class Main {
String message = event.message.getUnformattedText(); String message = event.message.getUnformattedText();
if (!message.contains(":")) { if (!message.contains(":")) {
if (message.equals("You didn't participate in this auction!")) { 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 mc.playerController.windowClick(mc.thePlayer.openContainer.windowId, 49, 0, 0, mc.thePlayer); // Close the window as could not buy
} }
} }

View file

@ -0,0 +1,5 @@
package me.night0721.lilase.features.ah;
public enum States {
OPEN, NONE, CLICK, CONFIRM, STOP
}

View file

@ -1,5 +1,6 @@
package me.night0721.lilase.utils; package me.night0721.lilase.utils;
import me.night0721.lilase.features.ah.States;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
@ -24,7 +25,7 @@ public class AuctionHouse {
private static String uuid; private static String uuid;
private static String message_toSend; private static String message_toSend;
private static long lastAction; private static long lastAction;
private Thread thread; private static Thread thread;
private Boolean open = false; private Boolean open = false;
private final DiscordWebhook webhook; private final DiscordWebhook webhook;
private final List<Item> items = new ArrayList<>(); private final List<Item> items = new ArrayList<>();
@ -117,8 +118,6 @@ public class AuctionHouse {
Pattern pattern = Pattern.compile("§[0-9a-z]", Pattern.MULTILINE); Pattern pattern = Pattern.compile("§[0-9a-z]", Pattern.MULTILINE);
Matcher matcher = pattern.matcher(auction.getString("item_lore")); Matcher matcher = pattern.matcher(auction.getString("item_lore"));
String updated = matcher.replaceAll(""); String updated = matcher.replaceAll("");
System.out.println(updated);
webhook.addEmbed( webhook.addEmbed(
new DiscordWebhook.EmbedObject() new DiscordWebhook.EmbedObject()
.setTitle("Item Is On Low Price") .setTitle("Item Is On Low Price")
@ -205,7 +204,6 @@ public class AuctionHouse {
open = true; open = true;
} }
} }
public static void switchStates() { public static void switchStates() {
switch (clickState) { switch (clickState) {
case CLICK: case CLICK:
@ -223,15 +221,14 @@ public class AuctionHouse {
AuctionHouse.sendAuction(); AuctionHouse.sendAuction();
lastAction = System.currentTimeMillis(); lastAction = System.currentTimeMillis();
clickState = States.CLICK; clickState = States.CLICK;
case STOP:
thread = null;
case NONE: case NONE:
break; break;
} }
} }
} }
enum States {
OPEN, NONE, CLICK, CONFIRM
}
enum ItemTier { enum ItemTier {
ANY, COMMON, UNCOMMON, RARE, EPIC, LEGENDARY, MYTHIC, DIVINE, SPECIAL, VERY_SPECIAL, ANY, COMMON, UNCOMMON, RARE, EPIC, LEGENDARY, MYTHIC, DIVINE, SPECIAL, VERY_SPECIAL,

View file

@ -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.addRequestProperty("User-Agent", "Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11");
connection.setDoOutput(true); connection.setDoOutput(true);
connection.setRequestMethod("POST"); connection.setRequestMethod("POST");
System.out.println(json);
OutputStream stream = connection.getOutputStream(); OutputStream stream = connection.getOutputStream();
stream.write(json.toString().getBytes(StandardCharsets.UTF_8)); stream.write(json.toString().getBytes(StandardCharsets.UTF_8));
stream.flush(); stream.flush();