This commit is contained in:
parent
fcb7979820
commit
52a02e29a3
9 changed files with 57 additions and 45 deletions
|
@ -7,6 +7,7 @@ import me.night0721.lilase.config.AHConfig;
|
||||||
import me.night0721.lilase.config.ConfigHandler;
|
import me.night0721.lilase.config.ConfigHandler;
|
||||||
import me.night0721.lilase.events.SniperFlipperEvents;
|
import me.night0721.lilase.events.SniperFlipperEvents;
|
||||||
import me.night0721.lilase.features.cofl.Cofl;
|
import me.night0721.lilase.features.cofl.Cofl;
|
||||||
|
import me.night0721.lilase.features.cofl.QueueItem;
|
||||||
import me.night0721.lilase.features.sniper.PageFlipper;
|
import me.night0721.lilase.features.sniper.PageFlipper;
|
||||||
import me.night0721.lilase.features.sniper.Sniper;
|
import me.night0721.lilase.features.sniper.Sniper;
|
||||||
import me.night0721.lilase.gui.ImageRenderer;
|
import me.night0721.lilase.gui.ImageRenderer;
|
||||||
|
@ -72,7 +73,7 @@ public class Lilase {
|
||||||
if (tickAmount % (20 * 60) == 0) sniper.start();
|
if (tickAmount % (20 * 60) == 0) sniper.start();
|
||||||
if (tickAmount % 2400 == 0) configHandler.checkWebhookAndAPI();
|
if (tickAmount % 2400 == 0) configHandler.checkWebhookAndAPI();
|
||||||
if (pageFlipper != null) pageFlipper.switchStates();
|
if (pageFlipper != null) pageFlipper.switchStates();
|
||||||
if (Sniper.flipper != null) Sniper.flipper.switchStates();
|
if (QueueItem.flipper != null) QueueItem.flipper.switchStates();
|
||||||
if (mc.currentScreen instanceof GuiDisconnected && clock.passed()) {
|
if (mc.currentScreen instanceof GuiDisconnected && clock.passed()) {
|
||||||
clock.schedule(RECONNECT_DELAY * 1000L);
|
clock.schedule(RECONNECT_DELAY * 1000L);
|
||||||
FMLClientHandler.instance().connectToServer(new GuiMultiplayer(new GuiMainMenu()), new ServerData(" ", "mc.hypixel.net", false));
|
FMLClientHandler.instance().connectToServer(new GuiMultiplayer(new GuiMainMenu()), new ServerData(" ", "mc.hypixel.net", false));
|
||||||
|
|
|
@ -71,6 +71,12 @@ public class AHConfig extends Config {
|
||||||
@Checkbox(name = "GUI", category = "GUI", description = "Enable the GUI")
|
@Checkbox(name = "GUI", category = "GUI", description = "Enable the GUI")
|
||||||
public static boolean GUI = true;
|
public static boolean GUI = true;
|
||||||
|
|
||||||
|
@Checkbox(name = "HK No.1", category = "GUI", description = "Enable the string HK No.1")
|
||||||
|
public static boolean HKNO1 = true;
|
||||||
|
|
||||||
|
@Checkbox(name = "Crabby", category = "GUI", description = "Enable the Crabby image")
|
||||||
|
public static boolean CRABBY = true;
|
||||||
|
|
||||||
@Color(name = "GUI Color", category = "GUI")
|
@Color(name = "GUI Color", category = "GUI")
|
||||||
public static OneColor GUI_COLOR = new OneColor(0, 49, 83);
|
public static OneColor GUI_COLOR = new OneColor(0, 49, 83);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package me.night0721.lilase.events;
|
||||||
|
|
||||||
import me.night0721.lilase.Lilase;
|
import me.night0721.lilase.Lilase;
|
||||||
import me.night0721.lilase.config.AHConfig;
|
import me.night0721.lilase.config.AHConfig;
|
||||||
|
import me.night0721.lilase.features.cofl.Cofl;
|
||||||
|
import me.night0721.lilase.features.cofl.QueueItem;
|
||||||
import me.night0721.lilase.features.flipper.Flipper;
|
import me.night0721.lilase.features.flipper.Flipper;
|
||||||
import me.night0721.lilase.features.flipper.FlipperState;
|
import me.night0721.lilase.features.flipper.FlipperState;
|
||||||
import me.night0721.lilase.features.sniper.PageFlipperState;
|
import me.night0721.lilase.features.sniper.PageFlipperState;
|
||||||
|
@ -36,7 +38,6 @@ import static me.night0721.lilase.config.AHConfig.GUI_COLOR;
|
||||||
import static me.night0721.lilase.config.AHConfig.SEND_MESSAGE;
|
import static me.night0721.lilase.config.AHConfig.SEND_MESSAGE;
|
||||||
import static me.night0721.lilase.features.flipper.Flipper.rotation;
|
import static me.night0721.lilase.features.flipper.Flipper.rotation;
|
||||||
import static me.night0721.lilase.features.flipper.FlipperState.START;
|
import static me.night0721.lilase.features.flipper.FlipperState.START;
|
||||||
import static me.night0721.lilase.features.sniper.Sniper.flipper;
|
|
||||||
import static me.night0721.lilase.utils.PlayerUtils.sendPacketWithoutEvent;
|
import static me.night0721.lilase.utils.PlayerUtils.sendPacketWithoutEvent;
|
||||||
|
|
||||||
public class SniperFlipperEvents {
|
public class SniperFlipperEvents {
|
||||||
|
@ -79,15 +80,14 @@ public class SniperFlipperEvents {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Utils.debugLog("Failed to send webhook");
|
Utils.debugLog("Failed to send webhook");
|
||||||
}
|
}
|
||||||
if (flipper == null)
|
Utils.debugLog("Target price " + Cofl.price);
|
||||||
price = Lilase.cofl.price;
|
price = Cofl.price;
|
||||||
else price = flipper.getItemPrice();
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1500);
|
Thread.sleep(1500);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
if (!AHConfig.ONLY_SNIPER) flipper.sellItem();
|
if (!AHConfig.ONLY_SNIPER) QueueItem.flipper.sellItem();
|
||||||
}).start();
|
}).start();
|
||||||
} else if (message.equals("Your starting bid must be at least 10 coins!")) {
|
} else if (message.equals("Your starting bid must be at least 10 coins!")) {
|
||||||
InventoryUtils.clickOpenContainerSlot(13);
|
InventoryUtils.clickOpenContainerSlot(13);
|
||||||
|
@ -177,7 +177,7 @@ public class SniperFlipperEvents {
|
||||||
Utils.debugLog("Interrupting Flipper selling");
|
Utils.debugLog("Interrupting Flipper selling");
|
||||||
Lilase.mc.thePlayer.closeScreen();
|
Lilase.mc.thePlayer.closeScreen();
|
||||||
Flipper.state = FlipperState.NONE;
|
Flipper.state = FlipperState.NONE;
|
||||||
Lilase.sniper.toggleAuction();
|
Lilase.cofl.toggleAuction();
|
||||||
}).start();
|
}).start();
|
||||||
} else if (Lilase.pageFlipper.state != PageFlipperState.NONE) {
|
} else if (Lilase.pageFlipper.state != PageFlipperState.NONE) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
@ -204,10 +204,12 @@ public class SniperFlipperEvents {
|
||||||
TextRenderer.drawString(lines, 0, 0, 0.9, GUI_COLOR.getRGB());
|
TextRenderer.drawString(lines, 0, 0, 0.9, GUI_COLOR.getRGB());
|
||||||
}
|
}
|
||||||
} else if (event.type == RenderGameOverlayEvent.ElementType.CHAT) {
|
} else if (event.type == RenderGameOverlayEvent.ElementType.CHAT) {
|
||||||
|
if (AHConfig.HKNO1) {
|
||||||
TextRenderer.drawGradientString(Lilase.mc.fontRendererObj, "Lilase", 50, 100, 0x00FBAA, 0xFF3EFC);
|
TextRenderer.drawGradientString(Lilase.mc.fontRendererObj, "Lilase", 50, 100, 0x00FBAA, 0xFF3EFC);
|
||||||
TextRenderer.drawAnimatedString(Lilase.mc.fontRendererObj, "Hong Kong No.1", 50, 110, 0x00FBAA, 0xFF3EFC, 0.5f);
|
TextRenderer.drawAnimatedString(Lilase.mc.fontRendererObj, "Hong Kong No.1", 50, 110, 0x00FBAA, 0xFF3EFC, 0.5f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||||
public void onInventoryRendering(GuiScreenEvent.BackgroundDrawnEvent event) {
|
public void onInventoryRendering(GuiScreenEvent.BackgroundDrawnEvent event) {
|
||||||
|
|
|
@ -8,13 +8,12 @@ import me.night0721.lilase.utils.UngrabUtils;
|
||||||
import me.night0721.lilase.utils.Utils;
|
import me.night0721.lilase.utils.Utils;
|
||||||
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Cofl {
|
public class Cofl {
|
||||||
private final Queue queue = new Queue();
|
private final Queue queue = new Queue();
|
||||||
private boolean open = false;
|
private boolean open = false;
|
||||||
public int price = 0;
|
public static int price = 0;
|
||||||
public Thread thread = new Thread(() -> {
|
public Thread thread = new Thread(() -> {
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
|
@ -43,24 +42,22 @@ public class Cofl {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Pattern pattern = Pattern.compile("type[\":]*flip");
|
private final Pattern pattern = Pattern.compile("type[\":]*flip");
|
||||||
private final Pattern commandPattern = Pattern.compile("/viewauction \\w+");
|
|
||||||
private final Pattern pricePattern = Pattern.compile("§7Med: §b(\\d{1,3}(?:,\\d{3})*)");
|
|
||||||
|
|
||||||
public void handleMessage(String str) {
|
public void handleMessage(String str) {
|
||||||
try {
|
try {
|
||||||
if (AHConfig.SNIPER_MODE != 2 || !getOpen() || !str.startsWith("Received:")) return;
|
if (AHConfig.SNIPER_MODE != 2 || !getOpen() || !str.startsWith("Received:")) return;
|
||||||
if (pattern.matcher(str).find()) {
|
if (pattern.matcher(str).find()) {
|
||||||
Matcher commandMacther = commandPattern.matcher(str);
|
|
||||||
Matcher priceMatcher = pricePattern.matcher(str);
|
|
||||||
String[] split = str.split("Received: ");
|
String[] split = str.split("Received: ");
|
||||||
String itemName = new JsonParser().parse(new JsonParser().parse(split[1]).getAsJsonObject().get("data").getAsString()).getAsJsonObject().get("auction").getAsJsonObject().get("itemName").getAsString();
|
JsonObject auction = new JsonParser().parse(new JsonParser().parse(split[1]).getAsJsonObject().get("data").getAsString()).getAsJsonObject();
|
||||||
if (commandMacther.find() && priceMatcher.find() && itemName != null) {
|
String itemName = auction.get("auction").getAsJsonObject().get("itemName").getAsString();
|
||||||
String command = commandMacther.group();
|
String id = auction.get("auction").getAsJsonObject().get("uuid").getAsString();
|
||||||
Utils.debugLog("Adding auction to queue: " + command,
|
price = auction.get("target").getAsInt();
|
||||||
"Price: " + Integer.parseInt(priceMatcher.group(1).replaceAll(",", "")),
|
// Utils.debugLog("Item Name: " + itemName);
|
||||||
"Name: " + itemName);
|
// Utils.debugLog("ID: " + id);
|
||||||
price = Integer.parseInt(priceMatcher.group(1).replaceAll(",", ""));
|
// Utils.debugLog("Price: " + price);
|
||||||
getQueue().add(new QueueItem(command, itemName, price));
|
if (itemName != null && id != null && price != 0) {
|
||||||
|
Utils.debugLog("Adding auction to queue: " + id, "Target Price: " + price, "Name: " + itemName);
|
||||||
|
getQueue().add(new QueueItem(id, itemName, price));
|
||||||
getQueue().scheduleClear();
|
getQueue().scheduleClear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +78,7 @@ public class Cofl {
|
||||||
if (Utils.checkInHub()) {
|
if (Utils.checkInHub()) {
|
||||||
Utils.sendMessage("Started COFL Sniper");
|
Utils.sendMessage("Started COFL Sniper");
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
boolean threadStatus = !thread.isAlive();
|
boolean threadStatus = thread.isAlive();
|
||||||
stopThread();
|
stopThread();
|
||||||
if (!threadStatus) {
|
if (!threadStatus) {
|
||||||
thread.start();
|
thread.start();
|
||||||
|
@ -98,6 +95,7 @@ public class Cofl {
|
||||||
thread.interrupt();
|
thread.interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getOpen() {
|
public boolean getOpen() {
|
||||||
return open;
|
return open;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class Queue {
|
||||||
this.clearTaskRunning = true;
|
this.clearTaskRunning = true;
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(30000);
|
Thread.sleep(3000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import me.night0721.lilase.utils.Utils;
|
||||||
public class QueueItem {
|
public class QueueItem {
|
||||||
private final String command, name;
|
private final String command, name;
|
||||||
private final int price;
|
private final int price;
|
||||||
|
public static Flipper flipper = null;
|
||||||
|
|
||||||
public QueueItem(String command, String name, int price) {
|
public QueueItem(String command, String name, int price) {
|
||||||
this.command = command;
|
this.command = command;
|
||||||
|
@ -16,7 +17,7 @@ public class QueueItem {
|
||||||
|
|
||||||
public void openAuction() {
|
public void openAuction() {
|
||||||
Utils.debugLog("Executing: " + command);
|
Utils.debugLog("Executing: " + command);
|
||||||
Utils.sendServerMessage(command);
|
Utils.sendServerMessage("/viewauction " + command);
|
||||||
new Flipper(name, price);
|
flipper = new Flipper(name, price);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -33,10 +33,12 @@ public class Flipper {
|
||||||
bytedata = data;
|
bytedata = data;
|
||||||
itemprice = price;
|
itemprice = price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Flipper(String name, int price) {
|
public Flipper(String name, int price) {
|
||||||
itemname = name;
|
itemname = name;
|
||||||
itemprice = price;
|
itemprice = price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getItemPrice() {
|
public int getItemPrice() {
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
try {
|
try {
|
||||||
|
@ -57,11 +59,18 @@ public class Flipper {
|
||||||
Lilase.sniper.incrementAuctionsSniped();
|
Lilase.sniper.incrementAuctionsSniped();
|
||||||
Utils.sendMessage("Flipper is running, stopping, will resume when flipper is done");
|
Utils.sendMessage("Flipper is running, stopping, will resume when flipper is done");
|
||||||
if (Lilase.sniper.getOpen()) Lilase.sniper.toggleAuction();
|
if (Lilase.sniper.getOpen()) Lilase.sniper.toggleAuction();
|
||||||
|
if (Lilase.cofl.getOpen()) Lilase.cofl.toggleAuction();
|
||||||
UngrabUtils.ungrabMouse();
|
UngrabUtils.ungrabMouse();
|
||||||
|
Utils.checkFooter();
|
||||||
|
Utils.debugLog("Cookie: " + (Utils.cookie == EffectState.ON ? "ON" : "OFF"));
|
||||||
|
Utils.debugLog("Have screen: " + (Lilase.mc.currentScreen != null ? "Yes" : "No"));
|
||||||
if (Utils.cookie != EffectState.ON) {
|
if (Utils.cookie != EffectState.ON) {
|
||||||
Utils.sendServerMessage("/hub");
|
Utils.sendServerMessage("/hub");
|
||||||
state = FlipperState.WALKING_TO_FIRST_POINT;
|
state = FlipperState.WALKING_TO_FIRST_POINT;
|
||||||
} else state = FlipperState.BUYING;
|
} else {
|
||||||
|
Utils.sendServerMessage("/ah");
|
||||||
|
state = FlipperState.BUYING;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void switchStates() {
|
public void switchStates() {
|
||||||
|
@ -148,7 +157,7 @@ public class Flipper {
|
||||||
buyWait.schedule(500);
|
buyWait.schedule(500);
|
||||||
Utils.sendMessage("Posted item on Auction House, continue sniping now");
|
Utils.sendMessage("Posted item on Auction House, continue sniping now");
|
||||||
state = FlipperState.NONE;
|
state = FlipperState.NONE;
|
||||||
Lilase.sniper.toggleAuction();
|
Lilase.cofl.toggleAuction();
|
||||||
}
|
}
|
||||||
case NONE:
|
case NONE:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package me.night0721.lilase.gui;
|
package me.night0721.lilase.gui;
|
||||||
|
|
||||||
|
import me.night0721.lilase.config.AHConfig;
|
||||||
import net.minecraft.client.gui.Gui;
|
import net.minecraft.client.gui.Gui;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
|
@ -10,7 +11,7 @@ import static me.night0721.lilase.Lilase.mc;
|
||||||
public class ImageRenderer {
|
public class ImageRenderer {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onRender(RenderGameOverlayEvent.Post e) {
|
public void onRender(RenderGameOverlayEvent.Post e) {
|
||||||
if (e.type == RenderGameOverlayEvent.ElementType.ALL) {
|
if (e.type == RenderGameOverlayEvent.ElementType.ALL && AHConfig.CRABBY) {
|
||||||
mc.getTextureManager().bindTexture(new ResourceLocation("lilase:textures/images/crab.png"));
|
mc.getTextureManager().bindTexture(new ResourceLocation("lilase:textures/images/crab.png"));
|
||||||
Gui.drawModalRectWithCustomSizedTexture(100, 0, 0, 0, 100, 100, 100, 100);
|
Gui.drawModalRectWithCustomSizedTexture(100, 0, 0, 0, 100, 100, 100, 100);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,8 @@ import static me.night0721.lilase.Lilase.mc;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
public static IChatComponent header = null, footer = null;
|
public static IChatComponent header = null, footer = null;
|
||||||
private static final Pattern
|
private static final Pattern PATTERN_HUB_LOCATIONS = Pattern.compile("(forest|village|farm|mountain|wilderness|community|graveyard|bazaar|auction)");
|
||||||
PATTERN_ACTIVE_EFFECTS = Pattern.compile("§r§r§7You have a §r§cGod Potion §r§7active! §r§d([0-9]*?:?[0-9]*?:?[0-9]*)§r"),
|
public static EffectState cookie;
|
||||||
PATTERN_HUB_LOCATIONS = Pattern.compile("(forest|village|farm|mountain|wilderness|community|graveyard|bazaar|auction)");
|
|
||||||
public static EffectState cookie, godPot;
|
|
||||||
|
|
||||||
public static String translateAlternateColorCodes(String text) {
|
public static String translateAlternateColorCodes(String text) {
|
||||||
char[] b = text.toCharArray();
|
char[] b = text.toCharArray();
|
||||||
|
@ -35,20 +33,16 @@ public class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkInHub() {
|
public static boolean checkInHub() {
|
||||||
return ScoreboardUtils.getSidebarLines().stream().map(ScoreboardUtils::cleanSB).anyMatch(line -> PATTERN_HUB_LOCATIONS.matcher(line).find());
|
return ScoreboardUtils.getSidebarLines().stream().map(ScoreboardUtils::cleanSB).map(String::toLowerCase).anyMatch(line -> PATTERN_HUB_LOCATIONS.matcher(line).find());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkFooter() {
|
public static void checkFooter() {
|
||||||
if (footer != null) {
|
if (footer != null) {
|
||||||
for (String line : footer.getFormattedText().split("\n")) {
|
for (String line : footer.getFormattedText().split("\n")) {
|
||||||
boolean foundGodPot = PATTERN_ACTIVE_EFFECTS.matcher(line).matches();
|
if (line.contains("Not active! Obtain")) {
|
||||||
godPot = (foundGodPot) ? EffectState.ON : EffectState.OFF;
|
cookie = EffectState.OFF;
|
||||||
if (!foundGodPot) {
|
} else {
|
||||||
cookie = (line.contains("Not active! Obtain")) ? EffectState.OFF : EffectState.ON;
|
cookie = EffectState.ON;
|
||||||
if (!line.contains("Active")) {
|
|
||||||
godPot = EffectState.INDETERMINABLE;
|
|
||||||
cookie = EffectState.INDETERMINABLE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +53,7 @@ public class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debugLog(String message) {
|
public static void debugLog(String message) {
|
||||||
mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "" + "[Lilase] " + message));
|
mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "" + "[Lilase] " + EnumChatFormatting.RESET + EnumChatFormatting.WHITE + message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debugLog(String... messages) {
|
public static void debugLog(String... messages) {
|
||||||
|
|
Loading…
Reference in a new issue