still doesn't send, but can auto buy now

This commit is contained in:
NK 2023-02-20 11:01:20 +00:00
parent 9a39c4cd26
commit ac3dd01f06
4 changed files with 25 additions and 19 deletions

View file

@ -30,9 +30,9 @@ public class Main {
public static final String VERSION = "1.0.0";
static int tickAmount;
private AuctionHouse auctionHouse;
static Minecraft mc = Minecraft.getMinecraft();
static KeyBinding[] keyBindings = new KeyBinding[3];
static ArrayList<Block> interactables = new ArrayList<>(Arrays.asList(Blocks.acacia_door, Blocks.anvil, Blocks.beacon, Blocks.bed, Blocks.birch_door, Blocks.brewing_stand, Blocks.command_block, Blocks.crafting_table, Blocks.chest, Blocks.dark_oak_door, Blocks.daylight_detector, Blocks.daylight_detector_inverted, Blocks.dispenser, Blocks.dropper, Blocks.enchanting_table, Blocks.ender_chest, Blocks.furnace, Blocks.hopper, Blocks.jungle_door, Blocks.lever, Blocks.noteblock, Blocks.powered_comparator, Blocks.unpowered_comparator, Blocks.powered_repeater, Blocks.unpowered_repeater, Blocks.standing_sign, Blocks.wall_sign, Blocks.trapdoor, Blocks.trapped_chest, Blocks.wooden_button, Blocks.stone_button, Blocks.oak_door, Blocks.skull));
static final Minecraft mc = Minecraft.getMinecraft();
static final KeyBinding[] keyBindings = new KeyBinding[3];
static final ArrayList<Block> interactables = new ArrayList<>(Arrays.asList(Blocks.acacia_door, Blocks.anvil, Blocks.beacon, Blocks.bed, Blocks.birch_door, Blocks.brewing_stand, Blocks.command_block, Blocks.crafting_table, Blocks.chest, Blocks.dark_oak_door, Blocks.daylight_detector, Blocks.daylight_detector_inverted, Blocks.dispenser, Blocks.dropper, Blocks.enchanting_table, Blocks.ender_chest, Blocks.furnace, Blocks.hopper, Blocks.jungle_door, Blocks.lever, Blocks.noteblock, Blocks.powered_comparator, Blocks.unpowered_comparator, Blocks.powered_repeater, Blocks.unpowered_repeater, Blocks.standing_sign, Blocks.wall_sign, Blocks.trapdoor, Blocks.trapped_chest, Blocks.wooden_button, Blocks.stone_button, Blocks.oak_door, Blocks.skull));
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
@ -75,8 +75,9 @@ public class Main {
public void onChat(ClientChatReceivedEvent event) {
String message = event.message.getUnformattedText();
if (!message.contains(":")) {
if (message.equals("Claiming BIN auction...")) {
Utils.addTitle("&aBought BIN Auction");
if (message.equals("You didn't participate in this auction!")) {
System.out.println("Failed to buy item, closing the menu");
mc.playerController.windowClick(mc.thePlayer.openContainer.windowId, 49, 0, 0, mc.thePlayer); // Close the window as could not buy
}
}
}

View file

@ -26,7 +26,7 @@ public class AuctionHouse {
private static long lastAction;
private Thread thread;
private Boolean open = false;
private DiscordWebhook webhook;
private final DiscordWebhook webhook;
private final List<Item> items = new ArrayList<>();
private final List<String> posted = new ArrayList<>();
public static States clickState = States.NONE;
@ -50,7 +50,7 @@ public class AuctionHouse {
connection.setReadTimeout(5000);
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
StringBuilder content = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
@ -69,7 +69,7 @@ public class AuctionHouse {
int status = connection.getResponseCode();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
StringBuilder content = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
@ -117,6 +117,7 @@ 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")
@ -186,7 +187,7 @@ public class AuctionHouse {
public void toggleAuction() {
if (open) {
Utils.sendMessage("Stopped Auction House");
thread.stop();
thread.interrupt();
open = false;
} else {
Utils.sendMessage("Started Auction House");
@ -199,7 +200,7 @@ public class AuctionHouse {
}
}
});
thread.run(); //You didn't participate in this auction!
thread.start();
open = true;
}
}
@ -250,10 +251,10 @@ enum ItemType {
}
class Item {
public String query;
public ItemType type;
public Integer price;
public ItemTier tier;
public final String query;
public final ItemType type;
public final Integer price;
public final ItemTier tier;
public Item(String query, ItemType type, Integer price, ItemTier tier) {
this.query = query;

View file

@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Array;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.*;
@ -139,12 +140,12 @@ public class DiscordWebhook {
URL url = new URL(this.url);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.addRequestProperty("Content-Type", "application/json");
connection.addRequestProperty("User-Agent", "Java-DiscordWebhook-BY-Gelox_");
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());
stream.write(json.toString().getBytes(StandardCharsets.UTF_8));
stream.flush();
stream.close();

View file

@ -10,6 +10,7 @@ import java.util.List;
public class Utils {
public static boolean inDungeon;
public static boolean inHub;
public static String translateAlternateColorCodes(String text) {
char[] b = text.toCharArray();
@ -46,16 +47,18 @@ public class Utils {
List<String> scoreboard = ScoreboardUtils.getSidebarLines();
for (String s : scoreboard) {
String sCleaned = ScoreboardUtils.cleanSB(s);
if (sCleaned.contains("Hub")) {
inDungeon = false;
if (sCleaned.contains("Forest") || sCleaned.contains("Village") || sCleaned.contains("Farm") || sCleaned.contains("Mountain") || sCleaned.contains("Wilderness") || sCleaned.contains("Community Center") || sCleaned.contains("Graveyard")) {
inHub = true;
return;
}
}
inDungeon = true;
}
public static void sendMessage(String message) {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "" + EnumChatFormatting.BOLD + "Liliase" + EnumChatFormatting.RESET + EnumChatFormatting.DARK_GRAY + " » " + EnumChatFormatting.RESET + EnumChatFormatting.GREEN + EnumChatFormatting.BOLD + message));
}
public static void sendServerMessage(String message) {
Minecraft.getMinecraft().thePlayer.sendChatMessage(message);
}