Merge pull request #1 from Gabagooooooooooool/master
Fixes & Improvemenets
This commit is contained in:
commit
fcb7979820
19 changed files with 105 additions and 161 deletions
|
@ -45,19 +45,18 @@ public class Lilase {
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
configHandler = new ConfigHandler();
|
(configHandler = new ConfigHandler()).init();
|
||||||
configHandler.init();
|
|
||||||
KeyBindingManager keyBindingManager = new KeyBindingManager();
|
KeyBindingManager keyBindingManager = new KeyBindingManager();
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
addToEventBus(this, keyBindingManager, new SniperFlipperEvents(), new ImageRenderer());
|
||||||
MinecraftForge.EVENT_BUS.register(keyBindingManager);
|
|
||||||
MinecraftForge.EVENT_BUS.register(new SniperFlipperEvents());
|
|
||||||
MinecraftForge.EVENT_BUS.register(new ImageRenderer());
|
|
||||||
EventManager.INSTANCE.register(this);
|
EventManager.INSTANCE.register(this);
|
||||||
sniper = new Sniper();
|
sniper = new Sniper();
|
||||||
pageFlipper = new PageFlipper();
|
pageFlipper = new PageFlipper();
|
||||||
keyBindingManager.registerKeyBindings();
|
keyBindingManager.registerKeyBindings();
|
||||||
cofl = new Cofl();
|
(cofl = new Cofl()).onOpen();
|
||||||
cofl.onOpen();
|
}
|
||||||
|
|
||||||
|
private void addToEventBus(Object... objects) {
|
||||||
|
for (Object object : objects) MinecraftForge.EVENT_BUS.register(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|
|
@ -19,6 +19,7 @@ public class ConfigHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadConfig() {
|
public void reloadConfig() {
|
||||||
|
// TODO: Fix
|
||||||
if (hasNoKey("APIKey")) setString("APIKey", "");
|
if (hasNoKey("APIKey")) setString("APIKey", "");
|
||||||
if (hasNoKey("SendMessageToWebhook")) setBoolean("SendMessageToWebhook", true);
|
if (hasNoKey("SendMessageToWebhook")) setBoolean("SendMessageToWebhook", true);
|
||||||
if (hasNoKey("Webhook")) setString("Webhook", "");
|
if (hasNoKey("Webhook")) setString("Webhook", "");
|
||||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.network.Packet;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
|
||||||
|
// TODO: Implement Lombok Library for clean code
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public class PacketReceivedEvent extends Event {
|
public class PacketReceivedEvent extends Event {
|
||||||
public final Packet<?> packet;
|
public final Packet<?> packet;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import net.minecraft.network.Packet;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
|
||||||
|
// TODO: Implement Lombok Library for clean code
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public class PacketSentEvent extends Event {
|
public class PacketSentEvent extends Event {
|
||||||
private final Packet<?> packet;
|
private final Packet<?> packet;
|
||||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.scoreboard.ScoreObjective;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
|
||||||
|
// TODO: Implement Lombok Library for clean code
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public class ScoreboardRenderEvent extends Event {
|
public class ScoreboardRenderEvent extends Event {
|
||||||
public ScoreObjective objective;
|
public ScoreObjective objective;
|
||||||
|
|
|
@ -40,24 +40,24 @@ 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 {
|
||||||
private int windowId = 1;
|
private int windowId = 1, price;
|
||||||
private int price;
|
private boolean buying = false, bought = false;
|
||||||
private boolean buying = false;
|
|
||||||
private boolean bought = false;
|
|
||||||
private final Clock clock = new Clock();
|
private final Clock clock = new Clock();
|
||||||
private final Pattern auctionSoldPattern = Pattern.compile("^(.*?) bought (.*?) for ([\\d,]+) coins CLICK$");
|
private final Pattern
|
||||||
private final Pattern boughtPattern = Pattern.compile("You purchased (\\w+(?:\\s+\\w+)*) for ([\\d,]+)\\s*(\\w+)!");
|
AUCTION_SOLD_PATTERN = Pattern.compile("^(.*?) bought (.*?) for ([\\d,]+) coins CLICK$"),
|
||||||
private final Pattern boughtPattern2 = Pattern.compile("You claimed (.+?) from (.+?)'s auction!");
|
BOUGHT_PATTERN = Pattern.compile("You purchased (\\w+(?:\\s+\\w+)*) for ([\\d,]+)\\s*(\\w+)!"),
|
||||||
private final Pattern boughtPattern3 = Pattern.compile("You (purchased|claimed)( (\\\\d+x))? ([^\\\\s]+(\\\\s+[^\\\\d,]+)*)((,| for) (\\\\d+,?)+ coins?(!)?)?");
|
BOUGHT_PATTERN_2 = Pattern.compile("You claimed (.+?) from (.+?)'s auction!"),
|
||||||
|
BOUGHT_PATTERN_3 = Pattern.compile("You (purchased|claimed)( (\\\\d+x))? ([^\\\\s]+(\\\\s+[^\\\\d,]+)*)((,| for) (\\\\d+,?)+ coins?(!)?)?");
|
||||||
|
// TODO: Split into one pattern
|
||||||
public static final List<String> postedNames = new ArrayList<>();
|
public static final List<String> postedNames = new ArrayList<>();
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onChat(ClientChatReceivedEvent event) throws InterruptedException {
|
public void onChat(ClientChatReceivedEvent event) throws InterruptedException {
|
||||||
String message = event.message.getUnformattedText();
|
String message = event.message.getUnformattedText();
|
||||||
Matcher matcher = auctionSoldPattern.matcher(message);
|
Matcher matcher = AUCTION_SOLD_PATTERN.matcher(message);
|
||||||
Matcher boughtMatcher = boughtPattern.matcher(message);
|
Matcher boughtMatcher = BOUGHT_PATTERN.matcher(message);
|
||||||
Matcher boughtMatcher2 = boughtPattern2.matcher(message);
|
Matcher boughtMatcher2 = BOUGHT_PATTERN_2.matcher(message);
|
||||||
Matcher boughtMatcher3 = boughtPattern3.matcher(message);
|
Matcher boughtMatcher3 = BOUGHT_PATTERN_3.matcher(message);
|
||||||
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!")) {
|
||||||
Utils.debugLog("Failed to buy item, not fast enough. Closing the menu");
|
Utils.debugLog("Failed to buy item, not fast enough. Closing the menu");
|
||||||
|
@ -148,6 +148,7 @@ public class SniperFlipperEvents {
|
||||||
Thread.sleep(3000);
|
Thread.sleep(3000);
|
||||||
InventoryUtils.clickOpenContainerSlot(10);
|
InventoryUtils.clickOpenContainerSlot(10);
|
||||||
Thread.sleep(3000);
|
Thread.sleep(3000);
|
||||||
|
// TODO: Remove duplication
|
||||||
Lilase.mc.thePlayer.closeScreen();
|
Lilase.mc.thePlayer.closeScreen();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -42,27 +42,23 @@ public class Cofl {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Pattern pattern = Pattern.compile("type[\":]*flip");
|
private final Pattern pattern = Pattern.compile("type[\":]*flip");
|
||||||
Pattern commandPattern = Pattern.compile("/viewauction \\w+");
|
private final Pattern commandPattern = Pattern.compile("/viewauction \\w+");
|
||||||
Pattern pricePattern = Pattern.compile("§7Med: §b(\\d{1,3}(?:,\\d{3})*)");
|
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) return;
|
if (AHConfig.SNIPER_MODE != 2 || !getOpen() || !str.startsWith("Received:")) return;
|
||||||
if (!getOpen()) return;
|
if (pattern.matcher(str).find()) {
|
||||||
if (!str.startsWith("Received:")) return;
|
|
||||||
Matcher matcher = pattern.matcher(str);
|
|
||||||
if (matcher.find()) {
|
|
||||||
Matcher commandMacther = commandPattern.matcher(str);
|
Matcher commandMacther = commandPattern.matcher(str);
|
||||||
Matcher priceMatcher = pricePattern.matcher(str);
|
Matcher priceMatcher = pricePattern.matcher(str);
|
||||||
String[] split = str.split("Received: ");
|
String[] split = str.split("Received: ");
|
||||||
JsonObject strJson = new JsonParser().parse(split[1]).getAsJsonObject();
|
String itemName = new JsonParser().parse(new JsonParser().parse(split[1]).getAsJsonObject().get("data").getAsString()).getAsJsonObject().get("auction").getAsJsonObject().get("itemName").getAsString();
|
||||||
String itemName = new JsonParser().parse(strJson.get("data").getAsString()).getAsJsonObject().get("auction").getAsJsonObject().get("itemName").getAsString();
|
|
||||||
if (commandMacther.find() && priceMatcher.find() && itemName != null) {
|
if (commandMacther.find() && priceMatcher.find() && itemName != null) {
|
||||||
String command = commandMacther.group();
|
String command = commandMacther.group();
|
||||||
Utils.debugLog("Adding auction to queue: " + command);
|
Utils.debugLog("Adding auction to queue: " + command,
|
||||||
Utils.debugLog("Price: " + Integer.parseInt(priceMatcher.group(1).replaceAll(",", "")));
|
"Price: " + Integer.parseInt(priceMatcher.group(1).replaceAll(",", "")),
|
||||||
Utils.debugLog("Name: " + itemName);
|
"Name: " + itemName);
|
||||||
price = Integer.parseInt(priceMatcher.group(1).replaceAll(",", ""));
|
price = Integer.parseInt(priceMatcher.group(1).replaceAll(",", ""));
|
||||||
getQueue().add(new QueueItem(command, itemName, price));
|
getQueue().add(new QueueItem(command, itemName, price));
|
||||||
getQueue().scheduleClear();
|
getQueue().scheduleClear();
|
||||||
|
@ -78,22 +74,16 @@ public class Cofl {
|
||||||
if (getOpen()) {
|
if (getOpen()) {
|
||||||
Utils.sendMessage("Stopped COFL Sniper");
|
Utils.sendMessage("Stopped COFL Sniper");
|
||||||
Lilase.mc.thePlayer.closeScreen();
|
Lilase.mc.thePlayer.closeScreen();
|
||||||
if (thread.isAlive()) {
|
stopThread();
|
||||||
queue.clear();
|
|
||||||
queue.setRunning(false);
|
|
||||||
thread.interrupt();
|
|
||||||
}
|
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
UngrabUtils.regrabMouse();
|
UngrabUtils.regrabMouse();
|
||||||
} else {
|
} else {
|
||||||
if (Utils.checkInHub()) {
|
if (Utils.checkInHub()) {
|
||||||
Utils.sendMessage("Started COFL Sniper");
|
Utils.sendMessage("Started COFL Sniper");
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
if (thread.isAlive()) {
|
boolean threadStatus = !thread.isAlive();
|
||||||
queue.clear();
|
stopThread();
|
||||||
queue.setRunning(false);
|
if (!threadStatus) {
|
||||||
thread.interrupt();
|
|
||||||
} else {
|
|
||||||
thread.start();
|
thread.start();
|
||||||
}
|
}
|
||||||
UngrabUtils.ungrabMouse();
|
UngrabUtils.ungrabMouse();
|
||||||
|
@ -101,6 +91,13 @@ public class Cofl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void stopThread() {
|
||||||
|
if (thread.isAlive()) {
|
||||||
|
queue.clear();
|
||||||
|
queue.setRunning(false);
|
||||||
|
thread.interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
public boolean getOpen() {
|
public boolean getOpen() {
|
||||||
return open;
|
return open;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,7 @@ import java.util.List;
|
||||||
|
|
||||||
public class Queue {
|
public class Queue {
|
||||||
private final List<QueueItem> queue = new ArrayList<>();
|
private final List<QueueItem> queue = new ArrayList<>();
|
||||||
private boolean running = false;
|
private boolean running = false, clearTaskRunning = false;
|
||||||
|
|
||||||
private boolean clearTaskRunning = false;
|
|
||||||
|
|
||||||
|
|
||||||
public void add(QueueItem item) {
|
public void add(QueueItem item) {
|
||||||
this.queue.add(item);
|
this.queue.add(item);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +36,6 @@ public class Queue {
|
||||||
public void scheduleClear() {
|
public void scheduleClear() {
|
||||||
if (!this.clearTaskRunning) {
|
if (!this.clearTaskRunning) {
|
||||||
this.clearTaskRunning = true;
|
this.clearTaskRunning = true;
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(30000);
|
Thread.sleep(30000);
|
||||||
|
|
|
@ -3,9 +3,9 @@ package me.night0721.lilase.features.cofl;
|
||||||
import me.night0721.lilase.features.flipper.Flipper;
|
import me.night0721.lilase.features.flipper.Flipper;
|
||||||
import me.night0721.lilase.utils.Utils;
|
import me.night0721.lilase.utils.Utils;
|
||||||
|
|
||||||
|
// TODO: Implement Lombok Library for clean code
|
||||||
public class QueueItem {
|
public class QueueItem {
|
||||||
private final String command;
|
private final String command, name;
|
||||||
private final String name;
|
|
||||||
private final int price;
|
private final int price;
|
||||||
|
|
||||||
public QueueItem(String command, String name, int price) {
|
public QueueItem(String command, String name, int price) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.io.InputStreamReader;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
|
// TODO: Fix repeating code (I will do it soon)
|
||||||
public class Flipper {
|
public class Flipper {
|
||||||
private final String itemname;
|
private final String itemname;
|
||||||
private static String bytedata;
|
private static String bytedata;
|
||||||
|
@ -100,13 +100,13 @@ public class Flipper {
|
||||||
case BUYING:
|
case BUYING:
|
||||||
if (Utils.cookie != EffectState.ON && Lilase.mc.currentScreen == null && buyWait.passed()) {
|
if (Utils.cookie != EffectState.ON && Lilase.mc.currentScreen == null && buyWait.passed()) {
|
||||||
final Entity auctionMaster = getAuctionMaster();
|
final Entity auctionMaster = getAuctionMaster();
|
||||||
if (auctionMaster == null) {
|
boolean auctionMasterExists = auctionMaster != null;
|
||||||
Utils.debugLog("Cannot find shop NPC, retrying");
|
if (auctionMasterExists) {
|
||||||
buyWait.schedule(500);
|
|
||||||
} else {
|
|
||||||
Lilase.mc.playerController.interactWithEntitySendPacket(Lilase.mc.thePlayer, auctionMaster);
|
Lilase.mc.playerController.interactWithEntitySendPacket(Lilase.mc.thePlayer, auctionMaster);
|
||||||
buyWait.schedule(1500);
|
} else {
|
||||||
|
Utils.debugLog("Cannot find shop NPC, retrying");
|
||||||
}
|
}
|
||||||
|
buyWait.schedule(auctionMasterExists ? 1500 : 500);
|
||||||
} else if (InventoryUtils.inventoryNameContains("Auction House") && buyWait.passed()) {
|
} else if (InventoryUtils.inventoryNameContains("Auction House") && buyWait.passed()) {
|
||||||
InventoryUtils.clickOpenContainerSlot(15);
|
InventoryUtils.clickOpenContainerSlot(15);
|
||||||
buyWait.schedule(1500);
|
buyWait.schedule(1500);
|
||||||
|
@ -127,7 +127,7 @@ public class Flipper {
|
||||||
} else if (!InventoryUtils.isStoneButton() && !InventoryUtils.isToAuctionItem(itemname) && buyWait.passed()) {
|
} else if (!InventoryUtils.isStoneButton() && !InventoryUtils.isToAuctionItem(itemname) && buyWait.passed()) {
|
||||||
InventoryUtils.clickOpenContainerSlot(13);
|
InventoryUtils.clickOpenContainerSlot(13);
|
||||||
buyWait.schedule(1000);
|
buyWait.schedule(1000);
|
||||||
}
|
} // TODO: Ternary Expression
|
||||||
} else if (InventoryUtils.inventoryNameContains("Manage Auction") && buyWait.passed()) {
|
} else if (InventoryUtils.inventoryNameContains("Manage Auction") && buyWait.passed()) {
|
||||||
InventoryUtils.clickOpenContainerSlot(24);
|
InventoryUtils.clickOpenContainerSlot(24);
|
||||||
buyWait.schedule(1500);
|
buyWait.schedule(1500);
|
||||||
|
@ -167,14 +167,13 @@ public class Flipper {
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
String inputLine;
|
String inputLine;
|
||||||
StringBuilder content = new StringBuilder();
|
StringBuilder content = new StringBuilder();
|
||||||
while ((inputLine = in.readLine()) != null) {
|
while ((inputLine = in.readLine()) != null)
|
||||||
content.append(inputLine);
|
content.append(inputLine);
|
||||||
}
|
|
||||||
in.close();
|
in.close();
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
object = (JsonObject) new JsonParser().parse(content.toString());
|
object = (JsonObject) new JsonParser().parse(content.toString());
|
||||||
System.out.println("Price" + object.get("price"));
|
System.out.println("Price" + object.get("price"));
|
||||||
return (JsonObject) new JsonParser().parse(content.toString());
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float distanceToFirstPoint() {
|
public static float distanceToFirstPoint() {
|
||||||
|
@ -186,15 +185,7 @@ public class Flipper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entity getAuctionMaster() {
|
public static Entity getAuctionMaster() {
|
||||||
for (final Entity e : Lilase.mc.theWorld.loadedEntityList) {
|
return Lilase.mc.theWorld.loadedEntityList.stream().filter(e -> e instanceof EntityArmorStand && StringUtils.stripControlCodes(e.getDisplayName().getUnformattedText()).startsWith("Auction Master")).findFirst().orElse(null);
|
||||||
if (e instanceof EntityArmorStand) {
|
|
||||||
final String name = StringUtils.stripControlCodes(e.getDisplayName().getUnformattedText());
|
|
||||||
if (name.startsWith("Auction Master")) {
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,15 +8,11 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import static me.night0721.lilase.Lilase.mc;
|
import static me.night0721.lilase.Lilase.mc;
|
||||||
|
|
||||||
public class ImageRenderer {
|
public class ImageRenderer {
|
||||||
public void draw() {
|
|
||||||
mc.getTextureManager().bindTexture(new ResourceLocation("lilase:textures/images/crab.png"));
|
|
||||||
Gui.drawModalRectWithCustomSizedTexture(100, 0, 0, 0, 100, 100, 100, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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) {
|
||||||
draw();
|
mc.getTextureManager().bindTexture(new ResourceLocation("lilase:textures/images/crab.png"));
|
||||||
|
Gui.drawModalRectWithCustomSizedTexture(100, 0, 0, 0, 100, 100, 100, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.client.gui.FontRenderer;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
// TODO: Generify repeating code.
|
||||||
public class TextRenderer {
|
public class TextRenderer {
|
||||||
public static void drawString(String text, int x, int y, double scale) {
|
public static void drawString(String text, int x, int y, double scale) {
|
||||||
double scaleReset = Math.pow(scale, -1);
|
double scaleReset = Math.pow(scale, -1);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package me.night0721.lilase.mixins;
|
||||||
import me.night0721.lilase.utils.Utils;
|
import me.night0721.lilase.utils.Utils;
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||||
import net.minecraft.network.play.server.S47PacketPlayerListHeaderFooter;
|
import net.minecraft.network.play.server.S47PacketPlayerListHeaderFooter;
|
||||||
|
import net.minecraft.util.IChatComponent;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
@ -12,7 +13,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
public class MixinNetHandlerPlayClient {
|
public class MixinNetHandlerPlayClient {
|
||||||
@Inject(method = "handlePlayerListHeaderFooter", at = @At("HEAD"))
|
@Inject(method = "handlePlayerListHeaderFooter", at = @At("HEAD"))
|
||||||
public void handlePlayerListHeaderFooter(S47PacketPlayerListHeaderFooter packetIn, CallbackInfo ci) {
|
public void handlePlayerListHeaderFooter(S47PacketPlayerListHeaderFooter packetIn, CallbackInfo ci) {
|
||||||
Utils.header = packetIn.getHeader().getFormattedText().length() == 0 ? null : packetIn.getHeader();
|
Utils.header = nullIfEmpty(packetIn.getHeader());
|
||||||
Utils.footer = packetIn.getFooter().getFormattedText().length() == 0 ? null : packetIn.getFooter();
|
Utils.footer = nullIfEmpty(packetIn.getFooter());
|
||||||
|
}
|
||||||
|
|
||||||
|
private IChatComponent nullIfEmpty(IChatComponent element){
|
||||||
|
return (element.getFormattedText().length() == 0) ? null : element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,19 +16,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
public class MixinNetworkManager {
|
public class MixinNetworkManager {
|
||||||
@Inject(method = {"channelRead0*"}, at = {@At(value = "HEAD")}, cancellable = true)
|
@Inject(method = {"channelRead0*"}, at = {@At(value = "HEAD")}, cancellable = true)
|
||||||
private void read(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
|
private void read(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
|
||||||
if (MinecraftForge.EVENT_BUS.post(new PacketReceivedEvent(packet, context))) {
|
if (MinecraftForge.EVENT_BUS.post(new PacketReceivedEvent(packet, context)))
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = {"sendPacket(Lnet/minecraft/network/Packet;)V"}, at = {@At(value = "HEAD")}, cancellable = true)
|
@Inject(method = {"sendPacket(Lnet/minecraft/network/Packet;)V"}, at = {@At(value = "HEAD")}, cancellable = true)
|
||||||
private void onSendPacket(Packet<?> packet, CallbackInfo ci) {
|
private void onSendPacket(Packet<?> packet, CallbackInfo ci) {
|
||||||
if (!PlayerUtils.packets.contains(packet)) {
|
if (!PlayerUtils.packets.remove(packet)) {
|
||||||
if (MinecraftForge.EVENT_BUS.post(new PacketSentEvent(packet))) {
|
if (MinecraftForge.EVENT_BUS.post(new PacketSentEvent(packet)))
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
PlayerUtils.packets.remove(packet);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.awt.*;
|
||||||
* @author Gabagooooooooooool (ily)
|
* @author Gabagooooooooooool (ily)
|
||||||
* @version 1.1
|
* @version 1.1
|
||||||
* Basic utility for aurora theming engine.
|
* Basic utility for aurora theming engine.
|
||||||
|
* <3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CurrentColor {
|
public class CurrentColor {
|
||||||
|
@ -31,24 +32,6 @@ public class CurrentColor {
|
||||||
return Color.WHITE.getRGB();
|
return Color.WHITE.getRGB();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getFloatValue(float offset, int color) {
|
|
||||||
Color tempC = new Color(CurrentColor.currentColorGet(offset));
|
|
||||||
int tempC_ = 0;
|
|
||||||
switch (color) {
|
|
||||||
case 0:
|
|
||||||
tempC_ = tempC.getRed();
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
tempC_ = tempC.getGreen();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
tempC_ = tempC.getBlue();
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
return (((float) tempC_) / 255F);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Following method has been circulating in Minecraft Hacking Community for a while, making it impossible to trace original author.
|
* Following method has been circulating in Minecraft Hacking Community for a while, making it impossible to trace original author.
|
||||||
*/
|
*/
|
||||||
|
@ -69,7 +52,6 @@ public class CurrentColor {
|
||||||
* Following method has been circulating in Minecraft Hacking Community for a while, making it impossible to trace original author.
|
* Following method has been circulating in Minecraft Hacking Community for a while, making it impossible to trace original author.
|
||||||
*/
|
*/
|
||||||
protected static Color getRainbow(final int speed, final int offset) {
|
protected static Color getRainbow(final int speed, final int offset) {
|
||||||
float hue = (System.currentTimeMillis() + offset) % speed;
|
return Color.getHSBColor(((System.currentTimeMillis() + offset) % speed) / speed, 0.9f, 1f);
|
||||||
return Color.getHSBColor(hue / speed, 0.9f, 1f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -135,6 +135,7 @@ public class DiscordWebhook {
|
||||||
this.embeds.clear();
|
this.embeds.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Lombok! I'm gonna add it soon. The code looks bad right now :/
|
||||||
public static class EmbedObject {
|
public static class EmbedObject {
|
||||||
private String title;
|
private String title;
|
||||||
private String description;
|
private String description;
|
||||||
|
|
|
@ -14,14 +14,13 @@ public class KeyBindingManager {
|
||||||
public void registerKeyBindings() {
|
public void registerKeyBindings() {
|
||||||
keyBindings[0] = new KeyBinding("Sniper Toggle", Keyboard.KEY_END, Lilase.MOD_NAME);
|
keyBindings[0] = new KeyBinding("Sniper Toggle", Keyboard.KEY_END, Lilase.MOD_NAME);
|
||||||
keyBindings[1] = new KeyBinding("Config", Keyboard.KEY_MULTIPLY, Lilase.MOD_NAME);
|
keyBindings[1] = new KeyBinding("Config", Keyboard.KEY_MULTIPLY, Lilase.MOD_NAME);
|
||||||
for (KeyBinding keyBinding : keyBindings) {
|
for (KeyBinding keyBinding : keyBindings) ClientRegistry.registerKeyBinding(keyBinding);
|
||||||
ClientRegistry.registerKeyBinding(keyBinding);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onKeyPress(InputEvent.KeyInputEvent event) {
|
public void onKeyPress(InputEvent.KeyInputEvent event) {
|
||||||
if (keyBindings[0].isPressed()) {
|
if (keyBindings[0].isPressed()) {
|
||||||
|
// TODO: Add sniper interface and use nested switch loop to prevent .toggleAuction(); repeating
|
||||||
switch (AHConfig.SNIPER_MODE) {
|
switch (AHConfig.SNIPER_MODE) {
|
||||||
case 0:
|
case 0:
|
||||||
Lilase.sniper.toggleAuction();
|
Lilase.sniper.toggleAuction();
|
||||||
|
@ -34,10 +33,9 @@ public class KeyBindingManager {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (keyBindings[1].isPressed()) {
|
if (keyBindings[1].isPressed())
|
||||||
Lilase.config.openGui();
|
Lilase.config.openGui();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void rightClick() {
|
public static void rightClick() {
|
||||||
if (!ReflectionUtils.invoke(Lilase.mc, "func_147121_ag")) {
|
if (!ReflectionUtils.invoke(Lilase.mc, "func_147121_ag")) {
|
||||||
|
@ -68,6 +66,8 @@ public class KeyBindingManager {
|
||||||
KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindAttack.getKeyCode(), attack);
|
KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindAttack.getKeyCode(), attack);
|
||||||
KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindSneak.getKeyCode(), crouch);
|
KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindSneak.getKeyCode(), crouch);
|
||||||
KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindJump.getKeyCode(), space);
|
KeyBinding.setKeyBindState(Lilase.mc.gameSettings.keyBindJump.getKeyCode(), space);
|
||||||
|
|
||||||
|
// TODO: Will fix it. Just give time.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stopMovement() {
|
public static void stopMovement() {
|
||||||
|
|
|
@ -5,9 +5,8 @@ import net.minecraft.util.MouseHelper;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
public class UngrabUtils {
|
public class UngrabUtils {
|
||||||
public static boolean isUngrabbed = false;
|
public static boolean doesGameWantUngrabbed, isUngrabbed = false;
|
||||||
private static MouseHelper oldMouseHelper;
|
private static MouseHelper oldMouseHelper;
|
||||||
private static boolean doesGameWantUngrabbed;
|
|
||||||
|
|
||||||
public static void ungrabMouse() {
|
public static void ungrabMouse() {
|
||||||
Minecraft m = Minecraft.getMinecraft();
|
Minecraft m = Minecraft.getMinecraft();
|
||||||
|
|
|
@ -7,18 +7,16 @@ import net.minecraft.util.ChatComponentText;
|
||||||
import net.minecraft.util.EnumChatFormatting;
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
import net.minecraft.util.IChatComponent;
|
import net.minecraft.util.IChatComponent;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static me.night0721.lilase.Lilase.mc;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
public static boolean inHub = false;
|
public static IChatComponent header = null, footer = null;
|
||||||
public static IChatComponent header = null;
|
private static final Pattern
|
||||||
public static IChatComponent footer = null;
|
PATTERN_ACTIVE_EFFECTS = Pattern.compile("§r§r§7You have a §r§cGod Potion §r§7active! §r§d([0-9]*?:?[0-9]*?:?[0-9]*)§r"),
|
||||||
private static final Pattern PATTERN_ACTIVE_EFFECTS = Pattern.compile(
|
PATTERN_HUB_LOCATIONS = Pattern.compile("(forest|village|farm|mountain|wilderness|community|graveyard|bazaar|auction)");
|
||||||
"§r§r§7You have a §r§cGod Potion §r§7active! §r§d([0-9]*?:?[0-9]*?:?[0-9]*)§r");
|
public static EffectState cookie, godPot;
|
||||||
public static EffectState cookie;
|
|
||||||
public static EffectState godPot;
|
|
||||||
|
|
||||||
public static String translateAlternateColorCodes(String text) {
|
public static String translateAlternateColorCodes(String text) {
|
||||||
char[] b = text.toCharArray();
|
char[] b = text.toCharArray();
|
||||||
|
@ -32,65 +30,44 @@ public class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addTitle(String title) {
|
public static void addTitle(String title) {
|
||||||
S45PacketTitle p1 = new S45PacketTitle(0, 20, 0);
|
Lilase.mc.thePlayer.sendQueue.handleTitle(new S45PacketTitle(0, 20, 0));
|
||||||
S45PacketTitle p2 = new S45PacketTitle(S45PacketTitle.Type.TITLE, new ChatComponentText(Utils.translateAlternateColorCodes(title)));
|
Lilase.mc.thePlayer.sendQueue.handleTitle(new S45PacketTitle(S45PacketTitle.Type.TITLE, new ChatComponentText(Utils.translateAlternateColorCodes(title))));
|
||||||
Lilase.mc.thePlayer.sendQueue.handleTitle(p1);
|
|
||||||
Lilase.mc.thePlayer.sendQueue.handleTitle(p2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkInHub() {
|
public static boolean checkInHub() {
|
||||||
List<String> scoreboard = ScoreboardUtils.getSidebarLines();
|
return ScoreboardUtils.getSidebarLines().stream().map(ScoreboardUtils::cleanSB).anyMatch(line -> PATTERN_HUB_LOCATIONS.matcher(line).find());
|
||||||
for (String s : scoreboard) {
|
|
||||||
String sCleaned = ScoreboardUtils.cleanSB(s);
|
|
||||||
if (sCleaned.contains("Forest") || sCleaned.contains("Village") || sCleaned.contains("Farm") || sCleaned.contains("Mountain") || sCleaned.contains("Wilderness") || sCleaned.contains("Community") || sCleaned.contains("Graveyard") || sCleaned.contains("Bazaar") || sCleaned.contains("Auction"))
|
|
||||||
inHub = true;
|
|
||||||
}
|
|
||||||
return inHub;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkFooter() {
|
public static void checkFooter() {
|
||||||
//
|
|
||||||
boolean foundGodPot = false;
|
|
||||||
boolean foundCookieText = false;
|
|
||||||
boolean loaded = false;
|
|
||||||
|
|
||||||
if (footer != null) {
|
if (footer != null) {
|
||||||
String formatted = footer.getFormattedText();
|
for (String line : footer.getFormattedText().split("\n")) {
|
||||||
for (String line : formatted.split("\n")) {
|
boolean foundGodPot = PATTERN_ACTIVE_EFFECTS.matcher(line).matches();
|
||||||
Matcher activeEffectsMatcher = PATTERN_ACTIVE_EFFECTS.matcher(line);
|
godPot = (foundGodPot) ? EffectState.ON : EffectState.OFF;
|
||||||
if (activeEffectsMatcher.matches()) {
|
if (!foundGodPot) {
|
||||||
foundGodPot = true;
|
cookie = (line.contains("Not active! Obtain")) ? EffectState.OFF : EffectState.ON;
|
||||||
} else if (line.contains("§d§lCookie Buff")) {
|
if (!line.contains("Active")) {
|
||||||
foundCookieText = true;
|
|
||||||
} else if (foundCookieText && line.contains("Not active! Obtain")) {
|
|
||||||
foundCookieText = false;
|
|
||||||
cookie = EffectState.OFF;
|
|
||||||
} else if (foundCookieText) {
|
|
||||||
foundCookieText = false;
|
|
||||||
cookie = EffectState.ON;
|
|
||||||
}
|
|
||||||
if (line.contains("Active")) {
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
godPot = foundGodPot ? EffectState.ON : EffectState.OFF;
|
|
||||||
if (!loaded) {
|
|
||||||
godPot = EffectState.INDETERMINABLE;
|
godPot = EffectState.INDETERMINABLE;
|
||||||
cookie = EffectState.INDETERMINABLE;
|
cookie = EffectState.INDETERMINABLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void sendMessage(String message) {
|
public static void sendMessage(String message) {
|
||||||
Lilase.mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "" + EnumChatFormatting.BOLD + "[Lilase] " + EnumChatFormatting.RESET + EnumChatFormatting.GREEN + EnumChatFormatting.BOLD + message));
|
mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "" + EnumChatFormatting.BOLD + "[Lilase] " + EnumChatFormatting.RESET + EnumChatFormatting.GREEN + EnumChatFormatting.BOLD + message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debugLog(String message) {
|
public static void debugLog(String message) {
|
||||||
Lilase.mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "" + "[Lilase] " + message));
|
mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "" + "[Lilase] " + message));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void debugLog(String... messages){
|
||||||
|
for (String message : messages) debugLog(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendServerMessage(String message) {
|
public static void sendServerMessage(String message) {
|
||||||
Lilase.mc.thePlayer.sendChatMessage(message);
|
mc.thePlayer.sendChatMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue