big fix on everything
Some checks failed
build-ci / build (push) Has been cancelled

This commit is contained in:
NK 2023-05-13 02:57:55 +02:00
parent fcb7979820
commit 52a02e29a3
9 changed files with 57 additions and 45 deletions

View file

@ -7,6 +7,7 @@ import me.night0721.lilase.config.AHConfig;
import me.night0721.lilase.config.ConfigHandler;
import me.night0721.lilase.events.SniperFlipperEvents;
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.Sniper;
import me.night0721.lilase.gui.ImageRenderer;
@ -72,7 +73,7 @@ public class Lilase {
if (tickAmount % (20 * 60) == 0) sniper.start();
if (tickAmount % 2400 == 0) configHandler.checkWebhookAndAPI();
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()) {
clock.schedule(RECONNECT_DELAY * 1000L);
FMLClientHandler.instance().connectToServer(new GuiMultiplayer(new GuiMainMenu()), new ServerData(" ", "mc.hypixel.net", false));

View file

@ -71,6 +71,12 @@ public class AHConfig extends Config {
@Checkbox(name = "GUI", category = "GUI", description = "Enable the GUI")
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")
public static OneColor GUI_COLOR = new OneColor(0, 49, 83);
}

View file

@ -2,6 +2,8 @@ package me.night0721.lilase.events;
import me.night0721.lilase.Lilase;
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.FlipperState;
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.features.flipper.Flipper.rotation;
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;
public class SniperFlipperEvents {
@ -79,15 +80,14 @@ public class SniperFlipperEvents {
} catch (Exception e) {
Utils.debugLog("Failed to send webhook");
}
if (flipper == null)
price = Lilase.cofl.price;
else price = flipper.getItemPrice();
Utils.debugLog("Target price " + Cofl.price);
price = Cofl.price;
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if (!AHConfig.ONLY_SNIPER) flipper.sellItem();
if (!AHConfig.ONLY_SNIPER) QueueItem.flipper.sellItem();
}).start();
} else if (message.equals("Your starting bid must be at least 10 coins!")) {
InventoryUtils.clickOpenContainerSlot(13);
@ -177,7 +177,7 @@ public class SniperFlipperEvents {
Utils.debugLog("Interrupting Flipper selling");
Lilase.mc.thePlayer.closeScreen();
Flipper.state = FlipperState.NONE;
Lilase.sniper.toggleAuction();
Lilase.cofl.toggleAuction();
}).start();
} else if (Lilase.pageFlipper.state != PageFlipperState.NONE) {
new Thread(() -> {
@ -204,8 +204,10 @@ public class SniperFlipperEvents {
TextRenderer.drawString(lines, 0, 0, 0.9, GUI_COLOR.getRGB());
}
} else if (event.type == RenderGameOverlayEvent.ElementType.CHAT) {
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);
if (AHConfig.HKNO1) {
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);
}
}
}

View file

@ -8,13 +8,12 @@ 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 static int price = 0;
public Thread thread = new Thread(() -> {
while (true) {
try {
@ -43,24 +42,22 @@ public class Cofl {
}
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) {
try {
if (AHConfig.SNIPER_MODE != 2 || !getOpen() || !str.startsWith("Received:")) return;
if (pattern.matcher(str).find()) {
Matcher commandMacther = commandPattern.matcher(str);
Matcher priceMatcher = pricePattern.matcher(str);
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();
if (commandMacther.find() && priceMatcher.find() && itemName != null) {
String command = commandMacther.group();
Utils.debugLog("Adding auction to queue: " + command,
"Price: " + Integer.parseInt(priceMatcher.group(1).replaceAll(",", "")),
"Name: " + itemName);
price = Integer.parseInt(priceMatcher.group(1).replaceAll(",", ""));
getQueue().add(new QueueItem(command, itemName, price));
JsonObject auction = new JsonParser().parse(new JsonParser().parse(split[1]).getAsJsonObject().get("data").getAsString()).getAsJsonObject();
String itemName = auction.get("auction").getAsJsonObject().get("itemName").getAsString();
String id = auction.get("auction").getAsJsonObject().get("uuid").getAsString();
price = auction.get("target").getAsInt();
// Utils.debugLog("Item Name: " + itemName);
// Utils.debugLog("ID: " + id);
// Utils.debugLog("Price: " + 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();
}
}
@ -81,7 +78,7 @@ public class Cofl {
if (Utils.checkInHub()) {
Utils.sendMessage("Started COFL Sniper");
setOpen(true);
boolean threadStatus = !thread.isAlive();
boolean threadStatus = thread.isAlive();
stopThread();
if (!threadStatus) {
thread.start();
@ -98,6 +95,7 @@ public class Cofl {
thread.interrupt();
}
}
public boolean getOpen() {
return open;
}

View file

@ -38,7 +38,7 @@ public class Queue {
this.clearTaskRunning = true;
new Thread(() -> {
try {
Thread.sleep(30000);
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}

View file

@ -7,6 +7,7 @@ import me.night0721.lilase.utils.Utils;
public class QueueItem {
private final String command, name;
private final int price;
public static Flipper flipper = null;
public QueueItem(String command, String name, int price) {
this.command = command;
@ -16,7 +17,7 @@ public class QueueItem {
public void openAuction() {
Utils.debugLog("Executing: " + command);
Utils.sendServerMessage(command);
new Flipper(name, price);
Utils.sendServerMessage("/viewauction " + command);
flipper = new Flipper(name, price);
}
}

View file

@ -33,10 +33,12 @@ public class Flipper {
bytedata = data;
itemprice = price;
}
public Flipper(String name, int price) {
itemname = name;
itemprice = price;
}
public int getItemPrice() {
if (object == null) {
try {
@ -57,11 +59,18 @@ public class Flipper {
Lilase.sniper.incrementAuctionsSniped();
Utils.sendMessage("Flipper is running, stopping, will resume when flipper is done");
if (Lilase.sniper.getOpen()) Lilase.sniper.toggleAuction();
if (Lilase.cofl.getOpen()) Lilase.cofl.toggleAuction();
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) {
Utils.sendServerMessage("/hub");
state = FlipperState.WALKING_TO_FIRST_POINT;
} else state = FlipperState.BUYING;
} else {
Utils.sendServerMessage("/ah");
state = FlipperState.BUYING;
}
}
public void switchStates() {
@ -148,7 +157,7 @@ public class Flipper {
buyWait.schedule(500);
Utils.sendMessage("Posted item on Auction House, continue sniping now");
state = FlipperState.NONE;
Lilase.sniper.toggleAuction();
Lilase.cofl.toggleAuction();
}
case NONE:
break;

View file

@ -1,5 +1,6 @@
package me.night0721.lilase.gui;
import me.night0721.lilase.config.AHConfig;
import net.minecraft.client.gui.Gui;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
@ -10,7 +11,7 @@ import static me.night0721.lilase.Lilase.mc;
public class ImageRenderer {
@SubscribeEvent
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"));
Gui.drawModalRectWithCustomSizedTexture(100, 0, 0, 0, 100, 100, 100, 100);
}

View file

@ -13,10 +13,8 @@ import static me.night0721.lilase.Lilase.mc;
public class Utils {
public static IChatComponent header = null, footer = null;
private static final Pattern
PATTERN_ACTIVE_EFFECTS = Pattern.compile("§r§r§7You have a §r§cGod Potion §r§7active! §r§d([0-9]*?:?[0-9]*?:?[0-9]*)§r"),
PATTERN_HUB_LOCATIONS = Pattern.compile("(forest|village|farm|mountain|wilderness|community|graveyard|bazaar|auction)");
public static EffectState cookie, godPot;
private static final Pattern PATTERN_HUB_LOCATIONS = Pattern.compile("(forest|village|farm|mountain|wilderness|community|graveyard|bazaar|auction)");
public static EffectState cookie;
public static String translateAlternateColorCodes(String text) {
char[] b = text.toCharArray();
@ -35,20 +33,16 @@ public class Utils {
}
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() {
if (footer != null) {
for (String line : footer.getFormattedText().split("\n")) {
boolean foundGodPot = PATTERN_ACTIVE_EFFECTS.matcher(line).matches();
godPot = (foundGodPot) ? EffectState.ON : EffectState.OFF;
if (!foundGodPot) {
cookie = (line.contains("Not active! Obtain")) ? EffectState.OFF : EffectState.ON;
if (!line.contains("Active")) {
godPot = EffectState.INDETERMINABLE;
cookie = EffectState.INDETERMINABLE;
}
if (line.contains("Not active! Obtain")) {
cookie = EffectState.OFF;
} else {
cookie = EffectState.ON;
}
}
}
@ -59,10 +53,10 @@ public class Utils {
}
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) {
for (String message : messages) debugLog(message);
}