cofl macro(wip, only can buy)
This commit is contained in:
parent
e0818a27c9
commit
2f18fadd79
4 changed files with 248 additions and 45 deletions
|
@ -2,10 +2,11 @@ package me.night0721.lilase.events;
|
|||
|
||||
import me.night0721.lilase.Lilase;
|
||||
import me.night0721.lilase.config.AHConfig;
|
||||
import me.night0721.lilase.config.ConfigUtils;
|
||||
import me.night0721.lilase.features.flipper.Flipper;
|
||||
import me.night0721.lilase.features.flipper.FlipperState;
|
||||
import me.night0721.lilase.features.sniper.PageFlipperState;
|
||||
import me.night0721.lilase.gui.TextRenderer;
|
||||
import me.night0721.lilase.player.EffectState;
|
||||
import me.night0721.lilase.utils.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
@ -59,26 +60,28 @@ public class SniperFlipperEvents {
|
|||
Matcher boughtMatcher3 = boughtPattern3.matcher(message);
|
||||
if (!message.contains(":")) {
|
||||
if (message.equals("You didn't participate in this auction!")) {
|
||||
Utils.debugLog("[Sniper] Failed to buy item, not fast enough. Closing the menu");
|
||||
Utils.debugLog("Failed to buy item, not fast enough. Closing the menu");
|
||||
InventoryUtils.clickOpenContainerSlot(49);
|
||||
} else if (message.equals("You don't have enough coins to afford this bid!")) {
|
||||
Utils.debugLog("[Sniper] Failed to buy item, not enough money. Closing the menu");
|
||||
Utils.debugLog("Failed to buy item, not enough money. Closing the menu");
|
||||
InventoryUtils.clickOpenContainerSlot(49);
|
||||
} else if (message.contains("Your new API key is")) {
|
||||
Utils.debugLog("[Sniper] Detected new API key, saving it to config");
|
||||
Utils.debugLog("[Sniper] Saved new API key to config");
|
||||
Utils.debugLog("Detected new API key, saving it to config");
|
||||
Utils.debugLog("Saved new API key to config");
|
||||
String apiKey = message.replace("Your new API key is ", "");
|
||||
ConfigUtils.writeStringConfig("main", "APIKey", apiKey);
|
||||
Lilase.configHandler.setString("APIKey", apiKey);
|
||||
} else if ((boughtMatcher.matches() || boughtMatcher2.matches() || boughtMatcher3.matches()) && bought) {
|
||||
new Thread(() -> {
|
||||
bought = false;
|
||||
Utils.debugLog("[Sniper] Bought an item, starting to sell");
|
||||
Utils.debugLog("Bought an item, starting to sell");
|
||||
try {
|
||||
if (SEND_MESSAGE) Lilase.sniper.webhook.execute();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Failed to send webhook");
|
||||
Utils.debugLog("Failed to send webhook");
|
||||
}
|
||||
price = flipper.getItemPrice();
|
||||
if (flipper == null)
|
||||
price = Lilase.cofl.price;
|
||||
else price = flipper.getItemPrice();
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -89,16 +92,16 @@ public class SniperFlipperEvents {
|
|||
} else if (message.equals("Your starting bid must be at least 10 coins!")) {
|
||||
InventoryUtils.clickOpenContainerSlot(13);
|
||||
Lilase.mc.thePlayer.closeScreen();
|
||||
Utils.debugLog("[Flipper] Cannot post item as the cost is too low, stopping fliiper and starting sniper");
|
||||
Utils.debugLog("Cannot post item as the cost is too low, stopping fliiper and starting sniper");
|
||||
Lilase.sniper.toggleAuction();
|
||||
Flipper.state = FlipperState.NONE;
|
||||
} else if (message.contains("Can't create a BIN auction for this item for a PRICE this LOW!")) {
|
||||
Lilase.mc.thePlayer.closeScreen();
|
||||
Utils.debugLog("[Flipper] Cannot post item as the cost is too low, stopping fliiper and starting sniper");
|
||||
Utils.debugLog("Cannot post item as the cost is too low, stopping fliiper and starting sniper");
|
||||
Lilase.sniper.toggleAuction();
|
||||
Flipper.state = FlipperState.NONE;
|
||||
} else if (message.contains("You were spawned in Limbo")) {
|
||||
Utils.sendMessage("Detected in Limbo, stopping everything for 5 minutes");
|
||||
Utils.debugLog("Detected in Limbo, stopping everything for 5 minutes");
|
||||
Utils.addTitle("You got sent to Limbo!");
|
||||
Flipper.state = FlipperState.NONE;
|
||||
if (Lilase.sniper.getOpen()) Lilase.sniper.toggleAuction();
|
||||
|
@ -124,7 +127,7 @@ public class SniperFlipperEvents {
|
|||
boolean timedOut = false;
|
||||
while (BlockUtils.getRelativeBlock(0, 0, 1) != Blocks.spruce_stairs) {
|
||||
if ((System.currentTimeMillis() - timeout) > 10000) {
|
||||
Utils.debugLog("[Sniper] Couldn't find bz, gonna chill here");
|
||||
Utils.debugLog("Couldn't find bz, gonna chill here");
|
||||
timedOut = true;
|
||||
break;
|
||||
}
|
||||
|
@ -170,17 +173,18 @@ public class SniperFlipperEvents {
|
|||
if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
|
||||
if (Flipper.state != FlipperState.NONE) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Utils.debugLog("[Flipper] Interrupting Flipper selling");
|
||||
Thread.sleep(500);
|
||||
Utils.debugLog("Interrupting Flipper selling");
|
||||
Lilase.mc.thePlayer.closeScreen();
|
||||
Flipper.state = FlipperState.NONE;
|
||||
Lilase.sniper.toggleAuction();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
|
||||
} else if (Lilase.pageFlipper.state != PageFlipperState.NONE) {
|
||||
new Thread(() -> {
|
||||
Utils.debugLog("[PageFlipper] Interrupting PageFlipper sniping");
|
||||
Lilase.pageFlipper.toggleAuction();
|
||||
}).start();
|
||||
} else if (Lilase.sniper.getOpen()) {
|
||||
Lilase.sniper.toggleAuction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -204,10 +208,11 @@ public class SniperFlipperEvents {
|
|||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public void onInventoryRendering(GuiScreenEvent.BackgroundDrawnEvent event) {
|
||||
String windowName = InventoryUtils.getInventoryName();
|
||||
if (AHConfig.BED_SPAM) {
|
||||
if (AHConfig.BED_SPAM && (Lilase.sniper.getOpen() || Lilase.pageFlipper.getOpen() || Lilase.cofl.getOpen())) {
|
||||
if ("BIN Auction View".equals(windowName)) {
|
||||
ItemStack is = InventoryUtils.getStackInOpenContainerSlot(31);
|
||||
if (is != null) {
|
||||
System.out.println("Slot 31: " + is.getItem().getRegistryName());
|
||||
buying = true;
|
||||
windowId = Lilase.mc.thePlayer.openContainer.windowId;
|
||||
if (is.getItem() == Items.bed && clock.passed()) {
|
||||
|
@ -218,32 +223,38 @@ public class SniperFlipperEvents {
|
|||
else if (is.getItem() == Items.potato) {
|
||||
buying = false;
|
||||
Lilase.mc.thePlayer.closeScreen();
|
||||
} else if (is.getItem() == Items.feather) {
|
||||
buying = false;
|
||||
Lilase.mc.thePlayer.closeScreen();
|
||||
} else {
|
||||
System.out.println("Not potato, not bed, not nugget, not feather??");
|
||||
buying = false;
|
||||
Lilase.mc.thePlayer.closeScreen();
|
||||
}
|
||||
} else {
|
||||
System.out.println("Not gonna happen");
|
||||
buying = false;
|
||||
Lilase.mc.thePlayer.closeScreen();
|
||||
System.out.println("No item in slot 31, ??");
|
||||
// buying = false;
|
||||
// Lilase.mc.thePlayer.closeScreen();
|
||||
}
|
||||
}
|
||||
if (buying && "Confirm Purchase".equals(windowName)) {
|
||||
System.out.println("Window ID: " + Lilase.mc.thePlayer.openContainer.windowId);
|
||||
Lilase.mc.playerController.windowClick(windowId + 1, 11, 0, 0, Lilase.mc.thePlayer);
|
||||
buying = false;
|
||||
if (Lilase.sniper.buying) bought = true;
|
||||
if (Lilase.sniper.buying || Lilase.cofl.getQueue().isRunning()) bought = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPacketReceive(PacketReceivedEvent event) {
|
||||
if (event.packet instanceof S33PacketUpdateSign && Utils.checkInHub() && Flipper.state.equals(START)) {
|
||||
if (event.packet instanceof S33PacketUpdateSign && (Flipper.state.equals(START) || Lilase.cofl.getQueue().isRunning())) {
|
||||
if (Utils.cookie == EffectState.ON || (Utils.cookie == EffectState.OFF && Utils.checkInHub()))
|
||||
new Thread(() -> {
|
||||
try {
|
||||
S33PacketUpdateSign packetUpdateSign = (S33PacketUpdateSign) event.packet;
|
||||
IChatComponent[] lines = packetUpdateSign.getLines();
|
||||
Utils.debugLog("[Flipper] Item price should be " + price);
|
||||
Utils.debugLog("Item price should be " + price);
|
||||
Thread.sleep(300);
|
||||
lines[0] = IChatComponent.Serializer.jsonToComponent("{\"text\":\"" + price + "\"}");
|
||||
C12PacketUpdateSign packetUpdateSign1 = new C12PacketUpdateSign(packetUpdateSign.getPos(), lines);
|
||||
|
@ -253,13 +264,10 @@ public class SniperFlipperEvents {
|
|||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldChange(WorldEvent.Unload event) {
|
||||
buying = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
116
src/main/java/me/night0721/lilase/features/cofl/Cofl.java
Normal file
116
src/main/java/me/night0721/lilase/features/cofl/Cofl.java
Normal file
|
@ -0,0 +1,116 @@
|
|||
package me.night0721.lilase.features.cofl;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import me.night0721.lilase.Lilase;
|
||||
import me.night0721.lilase.config.AHConfig;
|
||||
import me.night0721.lilase.utils.UngrabUtils;
|
||||
import me.night0721.lilase.utils.Utils;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Cofl {
|
||||
private final Queue queue = new Queue();
|
||||
private boolean open = false;
|
||||
public int price = 0;
|
||||
public Thread thread = new Thread(() -> {
|
||||
while (true) {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException ignore) {
|
||||
}
|
||||
if (getOpen()) {
|
||||
if (!this.queue.isEmpty()) {
|
||||
if (!this.queue.isRunning()) {
|
||||
this.queue.setRunning(true);
|
||||
QueueItem item = this.queue.get();
|
||||
item.openAuction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
public void onOpen() {
|
||||
System.setOut(new PrintStream(System.out) {
|
||||
public void println(String str) {
|
||||
handleMessage(str);
|
||||
super.println(str);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void handleMessage(String str) {
|
||||
if (AHConfig.SNIPER_MODE != 2) return;
|
||||
if (!str.startsWith("Received:")) return;
|
||||
Pattern pattern = Pattern.compile("type[\":]*flip");
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
if (matcher.find()) {
|
||||
Pattern commandPattern = Pattern.compile("/viewauction \\w+");
|
||||
Matcher commandMacther = commandPattern.matcher(str);
|
||||
Pattern pricePattern = Pattern.compile("§7Med: §b(\\d{1,3}(?:,\\d{3})*)");
|
||||
Matcher priceMatcher = pricePattern.matcher(str);
|
||||
String[] split = str.split("Received: ");
|
||||
JsonObject strJson = new JsonParser().parse(split[1]).getAsJsonObject();
|
||||
String data = strJson.get("data").getAsString();
|
||||
String itemName = new JsonParser().parse(data).getAsJsonObject().get("itemName").getAsString();
|
||||
System.out.println(itemName);
|
||||
Pattern namePattern = Pattern.compile("\"itemName\":\"([^\"]+)\"");//Pattern.compile("\"itemName\":\"([^\"]+)\"", Pattern.MULTILINE);
|
||||
Matcher nameMatcher = namePattern.matcher(str);
|
||||
System.out.println("Command: " + commandMacther.find());
|
||||
System.out.println("Price: " + priceMatcher.find());
|
||||
System.out.println("Name: " + nameMatcher.find());
|
||||
if (commandMacther.find() && priceMatcher.find() && nameMatcher.find()) {
|
||||
String command = commandMacther.group();
|
||||
Utils.debugLog("Adding auction to queue: " + command);
|
||||
Utils.debugLog("Price: " + Integer.parseInt(priceMatcher.group(1).replaceAll(",", "")));
|
||||
Utils.debugLog("Name: " + nameMatcher.group(1));
|
||||
price = Integer.parseInt(priceMatcher.group(1).replaceAll(",", ""));
|
||||
getQueue().add(new QueueItem(command,nameMatcher.group(1), price));
|
||||
getQueue().scheduleClear();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleAuction() {
|
||||
if (getOpen()) {
|
||||
Utils.sendMessage("Stopped COFL Sniper");
|
||||
Lilase.mc.thePlayer.closeScreen();
|
||||
if (thread.isAlive()) {
|
||||
queue.clear();
|
||||
queue.setRunning(false);
|
||||
thread.interrupt();
|
||||
}
|
||||
setOpen(false);
|
||||
UngrabUtils.regrabMouse();
|
||||
} else {
|
||||
if (Utils.checkInHub()) {
|
||||
Utils.sendMessage("Started COFL Sniper");
|
||||
setOpen(true);
|
||||
if (thread.isAlive()) {
|
||||
queue.clear();
|
||||
queue.setRunning(false);
|
||||
thread.interrupt();
|
||||
} else {
|
||||
thread.start();
|
||||
}
|
||||
UngrabUtils.ungrabMouse();
|
||||
} else Utils.sendMessage("Detected not in hub, please go to hub to start");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getOpen() {
|
||||
return open;
|
||||
}
|
||||
|
||||
public void setOpen(boolean open) {
|
||||
this.open = open;
|
||||
}
|
||||
|
||||
public Queue getQueue() {
|
||||
return this.queue;
|
||||
}
|
||||
}
|
57
src/main/java/me/night0721/lilase/features/cofl/Queue.java
Normal file
57
src/main/java/me/night0721/lilase/features/cofl/Queue.java
Normal file
|
@ -0,0 +1,57 @@
|
|||
package me.night0721.lilase.features.cofl;
|
||||
|
||||
import me.night0721.lilase.utils.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Queue {
|
||||
private final List<QueueItem> queue = new ArrayList<>();
|
||||
private boolean running = false;
|
||||
|
||||
private boolean clearTaskRunning = false;
|
||||
|
||||
|
||||
public void add(QueueItem item) {
|
||||
this.queue.add(item);
|
||||
}
|
||||
|
||||
public QueueItem get() {
|
||||
QueueItem item = this.queue.get(0);
|
||||
queue.remove(0);
|
||||
return item;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.queue.isEmpty();
|
||||
}
|
||||
|
||||
public void setRunning(boolean isRunning) {
|
||||
this.running = isRunning;
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return this.running;
|
||||
}
|
||||
public void clear() {
|
||||
this.queue.clear();
|
||||
}
|
||||
|
||||
public void scheduleClear() {
|
||||
if (!this.clearTaskRunning) {
|
||||
this.clearTaskRunning = true;
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(30000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.queue.clear();
|
||||
this.setRunning(false);
|
||||
this.clearTaskRunning = false;
|
||||
Utils.debugLog("Cleared queue.");
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package me.night0721.lilase.features.cofl;
|
||||
|
||||
import me.night0721.lilase.features.flipper.Flipper;
|
||||
import me.night0721.lilase.utils.Utils;
|
||||
|
||||
public class QueueItem {
|
||||
private final String command;
|
||||
private final String name;
|
||||
private final int price;
|
||||
|
||||
public QueueItem(String command, String name, int price) {
|
||||
this.command = command;
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public void openAuction() {
|
||||
Utils.debugLog("Executing: " + command);
|
||||
Utils.sendServerMessage(command);
|
||||
new Flipper(name, price);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue