v2.0.1!
Some checks failed
build-ci / build (push) Has been cancelled

This commit is contained in:
NK 2023-05-15 21:22:01 +02:00
parent 44d80afc58
commit a06cc35c0e
17 changed files with 246 additions and 626 deletions

View file

@ -37,3 +37,8 @@
- Added a config for disabling words and crabby - Added a config for disabling words and crabby
- Fixing cofl macro cannot open issue - Fixing cofl macro cannot open issue
- Adding auto sell to cofl macro - Adding auto sell to cofl macro
- v2.0.1
- Fix webhook issues, now it would send when soneone bought your item
- Remove sniper option, only cofl macro exist now
- Added purse to webhook
- Added many more stuff to debug

42
.github/README.md vendored
View file

@ -1,6 +1,6 @@
<h1> Auction House Flipper - Lilase</h1> <h1> Auction House Flipper - Lilase</h1>
<div style="text-align: center;"> <div style="text-align: center;">
<img align="center" src="https://cdn.discordapp.com/attachments/842014909264953354/1082373275038003210/lilase.png" width="300" /> <img align="center" src="https://cdn.discordapp.com/attachments/842014909264953354/1082373275038003210/lilase.png" width="300" alt="icon"/>
</div> </div>
# Introduction: # Introduction:
@ -9,11 +9,9 @@ If you have any questions please join [Discord Server](https://night0721.me/disc
For how to use, see **[here](https://github.com/night0721/lilase#how-to-use)** For how to use, see **[here](https://github.com/night0721/lilase#how-to-use)**
# Features: # Features:
- Auto buy any item you want, with query customised by yourself
- Auto walk to the auction house - Auto walk to the auction house
- Auto sell after buying with profit check, so profit is ensured - Auto sell after buying with profit check, so profit is ensured
- Can customise fetch time (the faster, the higher chance to get the item you want) - Webhook system to send you that an item has been bought, sold, flipped
- Webhook system to send you that an item has been bought
- Failsafe in Limbo - Failsafe in Limbo
- Auto reconnect to server when disconnected - Auto reconnect to server when disconnected
- Auto skip confirmation screen - Auto skip confirmation screen
@ -25,6 +23,7 @@ For how to use, see **[here](https://github.com/night0721/lilase#how-to-use)**
- Modules toggleable in game - Modules toggleable in game
- Check maximum profit percentage before buying so duped items won't be bought - Check maximum profit percentage before buying so duped items won't be bought
- COFL macro - COFL macro
- auto sell to cofl macro
- Server ID on scoreboard hider - Server ID on scoreboard hider
- page flipper [WIP] - page flipper [WIP]
@ -39,57 +38,24 @@ For how to use, see **[here](https://github.com/night0721/lilase#how-to-use)**
8. save the file and press END key to start auction house sniper(or change it in control settings) 8. save the file and press END key to start auction house sniper(or change it in control settings)
9. For example configuration, see [here](https://github.com/night0721/Lilase#example-config) 9. For example configuration, see [here](https://github.com/night0721/Lilase#example-config)
# **IMPORTANT INFO**
List of things you can put in Tier section
```
ANY, COMMON, UNCOMMON, RARE, EPIC, LEGENDARY, MYTHIC, DIVINE, SPECIAL, VERY_SPECIAL
```
List of things you can put in Type section
```
ANY, WEAPON, ARMOR, ACCESSORIES, CONSUMABLES, BLOCKS, MISC
```
# Changelog: # Changelog:
[ChangeLog](https://github.com/night0721/Lilase/blob/master/.github/CHANGELOG.md) [ChangeLog](https://github.com/night0721/Lilase/blob/master/.github/CHANGELOG.md)
# To Do Features: # To Do Features:
- Console client?? - Console client??
- Page flipper for specific items(query) - Page flipper for specific items(query)
- Wither Impact in lore check
- Blue omelette in lore check
- pre api? - pre api?
# Example Config: # Example Config:
```cfg ```json
{ {
"APIKey": "",
"SendMessageToWebhook": true, "SendMessageToWebhook": true,
"Webhook": "", "Webhook": "",
"ReconnectDelay": 20, "ReconnectDelay": 20,
"AuctionHouseDelay": 8,
"BedSpamDelay": 100, "BedSpamDelay": 100,
"OnlySniper": false, "OnlySniper": false,
"checkMaximumProfitPercentageBeforeBuy": false,
"MaximumProfitPercentage": 1000,
"MinimumProfitPercentage": 400,
"items": [
{"Name": " ", "Type": "ANY", "Price": 1000, "Tier": "ANY"},
{
"Name": "Livid Dagger",
"Type": "WEAPON",
"Price": 5000000,
"Tier": "LEGENDARY"
},
{"Name": "", "Type": "", "Price": 0, "Tier": ""}
],
"blacklist": [
{"Name": "Rune", "Type": "ANY", "Price": 1, "Tier": "ANY"},
{"Name": "", "Type": "", "Price": 0, "Tier": ""},
{"Name": "", "Type": "", "Price": 0, "Tier": ""}
],
"BedSpam": true, "BedSpam": true,
"GUI": true, "GUI": true,
"checkProfitPercentageBeforeBuy": false,
"GUI_COLOR": -1, "GUI_COLOR": -1,
"SniperMode": true "SniperMode": true
} }

View file

@ -1,6 +1,6 @@
mod_name = Lilase mod_name = Lilase
mod_id = lilase mod_id = lilase
mod_version = 2.0 mod_version = 2.0.1
essential.defaults.loom=0 essential.defaults.loom=0

View file

@ -26,15 +26,13 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.io.IOException;
import static me.night0721.lilase.config.AHConfig.RECONNECT_DELAY; import static me.night0721.lilase.config.AHConfig.RECONNECT_DELAY;
@Mod(modid = Lilase.MODID, name = Lilase.MOD_NAME, version = Lilase.VERSION, acceptedMinecraftVersions = "[1.8.9]") @Mod(modid = Lilase.MODID, name = Lilase.MOD_NAME, version = Lilase.VERSION, acceptedMinecraftVersions = "[1.8.9]")
public class Lilase { public class Lilase {
public static final String MOD_NAME = "Lilase"; public static final String MOD_NAME = "Lilase";
public static final String MODID = "Lilase"; public static final String MODID = "Lilase";
public static final String VERSION = "2.0"; public static final String VERSION = "2.0.1";
public static final Minecraft mc = Minecraft.getMinecraft(); public static final Minecraft mc = Minecraft.getMinecraft();
public static Sniper sniper; public static Sniper sniper;
public static PageFlipper pageFlipper; public static PageFlipper pageFlipper;
@ -66,11 +64,10 @@ public class Lilase {
} }
@SubscribeEvent @SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) throws IOException { public void onTick(TickEvent.ClientTickEvent event) {
if (mc.thePlayer == null || event.phase != TickEvent.Phase.START) return; if (mc.thePlayer == null || event.phase != TickEvent.Phase.START) return;
tickAmount++; tickAmount++;
if (tickAmount % 20 == 0) Utils.checkFooter(); if (tickAmount % 20 == 0) Utils.checkFooter();
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 (QueueItem.flipper != null) QueueItem.flipper.switchStates(); if (QueueItem.flipper != null) QueueItem.flipper.switchStates();

View file

@ -15,15 +15,9 @@ public class AHConfig extends Config {
addListener("SEND_MESSAGE", () -> Lilase.configHandler.setBoolean("SendMessageToWebhook", SEND_MESSAGE)); addListener("SEND_MESSAGE", () -> Lilase.configHandler.setBoolean("SendMessageToWebhook", SEND_MESSAGE));
addListener("WEBHOOK", () -> Lilase.configHandler.setString("Webhook", WEBHOOK)); addListener("WEBHOOK", () -> Lilase.configHandler.setString("Webhook", WEBHOOK));
addListener("RECONNECT_DELAY", () -> Lilase.configHandler.setInt("ReconnectDelay", Math.round(RECONNECT_DELAY))); addListener("RECONNECT_DELAY", () -> Lilase.configHandler.setInt("ReconnectDelay", Math.round(RECONNECT_DELAY)));
addListener("AUCTION_HOUSE_DELAY", () -> Lilase.configHandler.setInt("AuctionHouseDelay", Math.round(AUCTION_HOUSE_DELAY)));
addListener("SNIPER_MODE", () -> Lilase.configHandler.setInt("SniperMode", SNIPER_MODE));
addListener("BED_SPAM", () -> Lilase.configHandler.setBoolean("BedSpam", BED_SPAM)); addListener("BED_SPAM", () -> Lilase.configHandler.setBoolean("BedSpam", BED_SPAM));
addListener("BED_SPAM_DELAY", () -> Lilase.configHandler.setInt("BedSpamDelay", Math.round(BED_SPAM_DELAY))); addListener("BED_SPAM_DELAY", () -> Lilase.configHandler.setInt("BedSpamDelay", Math.round(BED_SPAM_DELAY)));
addListener("ONLY_SNIPER", () -> Lilase.configHandler.setBoolean("OnlySniper", ONLY_SNIPER)); addListener("ONLY_SNIPER", () -> Lilase.configHandler.setBoolean("OnlySniper", ONLY_SNIPER));
addListener("CHECK_PERCENTAGE", () -> Lilase.configHandler.setBoolean("checkProfitPercentageBeforeBuy", CHECK_PERCENTAGE));
addListener("MINIMUM_PROFIT_PERCENTAGE", () -> Lilase.configHandler.setInt("MinimumProfitPercentage", Math.round(MINIMUM_PROFIT_PERCENTAGE)));
addListener("CHECK_MAXIMUM_PROFIT", () -> Lilase.configHandler.setBoolean("checkMaxiumProfitPercentageBeforeBuy", CHECK_MAXIMUM_PROFIT));
addListener("MAXIMUM_PROFIT_PERCENTAGE", () -> Lilase.configHandler.setInt("MaximumProfitPercentage", MAXIMUM_PROFIT_PERCENTAGE));
addListener("GUI", () -> Lilase.configHandler.setBoolean("GUI", GUI)); addListener("GUI", () -> Lilase.configHandler.setBoolean("GUI", GUI));
addListener("GUI_COLOR", () -> Lilase.configHandler.setInt("GUI_COLOR", GUI_COLOR.getRGB())); addListener("GUI_COLOR", () -> Lilase.configHandler.setInt("GUI_COLOR", GUI_COLOR.getRGB()));
addDependency("WEBHOOK", "SEND_MESSAGE"); addDependency("WEBHOOK", "SEND_MESSAGE");
@ -32,12 +26,6 @@ public class AHConfig extends Config {
addDependency("GUI_COLOR", "GUI"); addDependency("GUI_COLOR", "GUI");
} }
@Slider(name = "Time per fetch (seconds)", min = 5, max = 15, step = 1, category = "Auction House", subcategory = "Sniper", description = "Time between each fetch of the auction house, the faster the fetch, the more likely you will snipe the item")
public static int AUCTION_HOUSE_DELAY = 8;
@Dropdown(name = "Sniper Mode", category = "Auction House", subcategory = "Sniper", options = {"API", "Page Flipper[WIP]", "COFL"})
public static int SNIPER_MODE = 2;
@Switch(name = "Bed Spam & Skip Confirm", category = "Auction House", subcategory = "Sniper", description = "Spam the bed to buy the item just after the grace period ends and skips the confirmation of buying the item") @Switch(name = "Bed Spam & Skip Confirm", category = "Auction House", subcategory = "Sniper", description = "Spam the bed to buy the item just after the grace period ends and skips the confirmation of buying the item")
public static boolean BED_SPAM = true; public static boolean BED_SPAM = true;
@ -56,18 +44,6 @@ public class AHConfig extends Config {
@Number(name = "Reconnect Delay", min = 5, max = 20, category = "Failsafe", description = "Delay between each reconnect attempt to the server") @Number(name = "Reconnect Delay", min = 5, max = 20, category = "Failsafe", description = "Delay between each reconnect attempt to the server")
public static int RECONNECT_DELAY = 20; public static int RECONNECT_DELAY = 20;
@Switch(name = "Check Profit Percentage Before Buying", category = "Flipper", description = "Check the profit percentage before buying the item, if the profit percentage is too low, it will not buy the item")
public static boolean CHECK_PERCENTAGE = false;
@Number(name = "Minimum Profit Percentage", min = 100, max = 5000, step = 50, category = "Flipper", description = "Profit percentage to check before buying the item, if the profit percentage is too low, it will not buy the item")
public static int MINIMUM_PROFIT_PERCENTAGE = 400;
@Switch(name = "Check Maximum Profit Before Buying", category = "Flipper", description = "Check the maximal profit before buying the item, if the maximal profit is too high, it will not buy the item (Can prevent duped items)")
public static boolean CHECK_MAXIMUM_PROFIT = false;
@Number(name = "Maximum Profit Percentage", min = 1000, max = 10000, step = 1000, category = "Flipper", description = "Maximum profit to check before buying the item, if the maximal profit is too high, it will not buy the item (Can prevent duped items)")
public static int MAXIMUM_PROFIT_PERCENTAGE = 1000;
@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;

View file

@ -1,7 +1,6 @@
package me.night0721.lilase.config; package me.night0721.lilase.config;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import me.night0721.lilase.utils.Utils; import me.night0721.lilase.utils.Utils;
@ -10,7 +9,7 @@ import java.io.*;
public class ConfigHandler { public class ConfigHandler {
private final Gson gson = new Gson(); private final Gson gson = new Gson();
String path = "/config/Lilase.json"; private final String path = "/config/Lilase.json";
private JsonObject config; private JsonObject config;
public void init() { public void init() {
@ -20,7 +19,6 @@ public class ConfigHandler {
public void reloadConfig() { public void reloadConfig() {
// TODO: Fix // TODO: Fix
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", "");
if (hasNoKey("ReconnectDelay")) setInt("ReconnectDelay", 20); if (hasNoKey("ReconnectDelay")) setInt("ReconnectDelay", 20);
@ -29,27 +27,8 @@ public class ConfigHandler {
if (hasNoKey("BedSpam")) setBoolean("BedSpam", true); if (hasNoKey("BedSpam")) setBoolean("BedSpam", true);
if (hasNoKey("BedSpamDelay")) setInt("BedSpamDelay", 100); if (hasNoKey("BedSpamDelay")) setInt("BedSpamDelay", 100);
if (hasNoKey("OnlySniper")) setBoolean("OnlySniper", false); if (hasNoKey("OnlySniper")) setBoolean("OnlySniper", false);
if (hasNoKey("checkProfitPercentageBeforeBuy")) setBoolean("checkProfitPercentageBeforeBuy", false);
if (hasNoKey("checkMaximumProfitPercentageBeforeBuy"))
setBoolean("checkMaximumProfitPercentageBeforeBuy", false);
if (hasNoKey("MaximumProfitPercentage")) setInt("MaximumProfitPercentage", 1000); //1000%
if (hasNoKey("MinimumProfitPercentage")) setInt("MinimumProfitPercentage", 400); //400%
if (hasNoKey("GUI")) setBoolean("GUI", true); if (hasNoKey("GUI")) setBoolean("GUI", true);
if (hasNoKey("GUI_COLOR")) setInt("GUI_COLOR", 0x003153); if (hasNoKey("GUI_COLOR")) setInt("GUI_COLOR", 0x003153);
if (hasNoKey("items")) setArray("items", new JsonObject[]{});
if (hasNoKey("blacklist")) setArray("blacklist", new JsonObject[]{});
for (int i = 1; i <= 3; i++) {
if (hasNoItemKey(i, "Name")) setItems(i, "Name", "");
if (hasNoItemKey(i, "Type")) setItems(i, "Type", "");
if (hasNoItemKey(i, "Price")) setItems(i, "Price", 0);
if (hasNoItemKey(i, "Tier")) setItems(i, "Tier", "");
}
for (int i = 1; i <= 3; i++) {
if (hasNoBlacklistKey(i, "Name")) setBlacklists(i, "Name", "");
if (hasNoBlacklistKey(i, "Type")) setBlacklists(i, "Type", "");
if (hasNoBlacklistKey(i, "Price")) setBlacklists(i, "Price", 0);
if (hasNoBlacklistKey(i, "Tier")) setBlacklists(i, "Tier", "");
}
} }
public void checkWebhookAndAPI() { public void checkWebhookAndAPI() {
@ -80,63 +59,12 @@ public class ConfigHandler {
return config.get(key) == null; return config.get(key) == null;
} }
public boolean hasNoItemKey(int i, String key) {
config = readConfigFile();
try {
if (config.getAsJsonArray("items").get(i - 1) == null) return true;
} catch (Exception e) {
return true;
}
return config.getAsJsonArray("items").get(i - 1).getAsJsonObject().get(key) == null;
}
public boolean hasNoBlacklistKey(int i, String key) {
config = readConfigFile();
try {
if (config.getAsJsonArray("blacklist").get(i - 1) == null) return true;
} catch (Exception e) {
return true;
}
return config.getAsJsonArray("blacklist").get(i - 1).getAsJsonObject().get(key) == null;
}
public boolean getBoolean(String key) {
config = readConfigFile();
if (config.get(key) != null) return config.get(key).getAsBoolean();
return false;
}
public int getInt(String key) {
config = readConfigFile();
if (config.get(key) != null) return config.get(key).getAsInt();
return 0;
}
public String getString(String key) { public String getString(String key) {
config = readConfigFile(); config = readConfigFile();
if (config.get(key) != null) return config.get(key).getAsString(); if (config.get(key) != null) return config.get(key).getAsString();
return null; return null;
} }
public String getString(int item, String key) {
config = readConfigFile();
try {
if (config.getAsJsonArray("items").get(item - 1).getAsJsonObject().get(key) != null)
return config.getAsJsonArray("items").get(item - 1).getAsJsonObject().get(key).getAsString();
} catch (Exception ignore) {
}
return "";
}
public int getInt(int item, String key) {
config = readConfigFile();
try {
if (config.getAsJsonArray("items").get(item - 1).getAsJsonObject().get(key) != null)
return config.getAsJsonArray("items").get(item - 1).getAsJsonObject().get(key).getAsInt();
} catch (Exception ignore) {
}
return 0;
}
public void setBoolean(String key, boolean value) { public void setBoolean(String key, boolean value) {
config = readConfigFile(); config = readConfigFile();
@ -159,61 +87,6 @@ public class ConfigHandler {
writeJsonToFile(config); writeJsonToFile(config);
} }
public void setArray(String key, JsonObject[] value) {
config = readConfigFile();
if (config.get(key) != null) config.remove(key);
JsonArray array = new JsonArray();
for (JsonObject object : value) {
array.add(object);
}
config.add(key, array);
writeJsonToFile(config);
}
public void setItems(int item, String key, Object value) {
config = readConfigFile();
try {
if (config.getAsJsonArray("items").get(item - 1).getAsJsonObject().get(key) != null)
config.getAsJsonArray("items").get(item - 1).getAsJsonObject().remove(key);
} catch (Exception e) {
JsonObject object = new JsonObject();
object.addProperty("Name", "");
object.addProperty("Type", "");
object.addProperty("Price", 0);
object.addProperty("Tier", "");
config.getAsJsonArray("items").add(object);
}
if (value instanceof Integer)
config.getAsJsonArray("items").get(item - 1).getAsJsonObject().addProperty(key, (Integer) value);
else if (value instanceof String)
config.getAsJsonArray("items").get(item - 1).getAsJsonObject().addProperty(key, (String) value);
else if (value instanceof Boolean)
config.getAsJsonArray("items").get(item - 1).getAsJsonObject().addProperty(key, (Boolean) value);
writeJsonToFile(config);
}
public void setBlacklists(int item, String key, Object value) {
config = readConfigFile();
try {
if (config.getAsJsonArray("blacklist").get(item - 1).getAsJsonObject().get(key) != null)
config.getAsJsonArray("blacklist").get(item - 1).getAsJsonObject().remove(key);
} catch (Exception e) {
JsonObject object = new JsonObject();
object.addProperty("Name", "");
object.addProperty("Type", "");
object.addProperty("Price", 0);
object.addProperty("Tier", "");
config.getAsJsonArray("blacklist").add(object);
}
if (value instanceof Integer)
config.getAsJsonArray("blacklist").get(item - 1).getAsJsonObject().addProperty(key, (Integer) value);
else if (value instanceof String)
config.getAsJsonArray("blacklist").get(item - 1).getAsJsonObject().addProperty(key, (String) value);
else if (value instanceof Boolean)
config.getAsJsonArray("blacklist").get(item - 1).getAsJsonObject().addProperty(key, (Boolean) value);
writeJsonToFile(config);
}
public void writeJsonToFile(JsonObject jsonObject) { public void writeJsonToFile(JsonObject jsonObject) {
try { try {
BufferedWriter writer = new BufferedWriter(new FileWriter(System.getProperty("user.dir") + path)); BufferedWriter writer = new BufferedWriter(new FileWriter(System.getProperty("user.dir") + path));

View file

@ -8,8 +8,8 @@ import net.minecraftforge.fml.common.eventhandler.Event;
// TODO: Implement Lombok Library for clean code // TODO: Implement Lombok Library for clean code
@Cancelable @Cancelable
public class ScoreboardRenderEvent extends Event { public class ScoreboardRenderEvent extends Event {
public ScoreObjective objective; public final ScoreObjective objective;
public ScaledResolution resolution; public final ScaledResolution resolution;
public ScoreboardRenderEvent(ScoreObjective objective, ScaledResolution resolution) { public ScoreboardRenderEvent(ScoreObjective objective, ScaledResolution resolution) {
this.objective = objective; this.objective = objective;

View file

@ -27,6 +27,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent; import net.minecraftforge.fml.common.gameevent.InputEvent;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
@ -36,7 +37,7 @@ import java.util.regex.Pattern;
import static me.night0721.lilase.config.AHConfig.GUI_COLOR; 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.*;
import static me.night0721.lilase.features.flipper.FlipperState.START; import static me.night0721.lilase.features.flipper.FlipperState.START;
import static me.night0721.lilase.utils.PlayerUtils.sendPacketWithoutEvent; import static me.night0721.lilase.utils.PlayerUtils.sendPacketWithoutEvent;
@ -44,21 +45,39 @@ public class SniperFlipperEvents {
private int windowId = 1, price; private int windowId = 1, price;
private boolean buying = false, bought = false; private boolean buying = false, bought = false;
private final Clock clock = new Clock(); private final Clock clock = new Clock();
private final Pattern private final Pattern AUCTION_SOLD_PATTERN = Pattern.compile("^(.*?) bought (.*?) for ([\\d,]+) coins CLICK$"),
AUCTION_SOLD_PATTERN = Pattern.compile("^(.*?) bought (.*?) for ([\\d,]+) coins CLICK$"), pattern = Pattern.compile("You purchased (\\w+(?:\\s+\\w+)*) for ([\\d,]+)\\s*(\\w+)|You claimed (.+?) from (.+?)'s auction!|(You (purchased|claimed)( (\\\\d+x))? ([^\\\\s]+(\\\\s+[^\\\\d,]+)*)((,| for) (\\\\d+,?)+ coins?(!)?))?");
BOUGHT_PATTERN = Pattern.compile("You purchased (\\w+(?:\\s+\\w+)*) for ([\\d,]+)\\s*(\\w+)!"),
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 = AUCTION_SOLD_PATTERN.matcher(message); if (message.startsWith("§6[Auction]")) {
Matcher boughtMatcher = BOUGHT_PATTERN.matcher(message); Matcher matcher = AUCTION_SOLD_PATTERN.matcher(ScoreboardUtils.cleanSB(message));
Matcher boughtMatcher2 = BOUGHT_PATTERN_2.matcher(message); if (matcher.matches()) {
Matcher boughtMatcher3 = BOUGHT_PATTERN_3.matcher(message); try {
webhook.setUsername("Lilase");
webhook.setAvatarUrl(icon);
webhook.addEmbed(new DiscordWebhook.EmbedObject()
.setTitle("Someone bought an item!")
.setFooter("Purse: " + format.format(Utils.getPurse()), icon)
.addField("Item:", matcher.group(2), true)
.addField("Price:", matcher.group(3), true)
.addField("Purchaser:", matcher.group(1).split("[Auction] ")[1], true)
.setColor(Color.decode("#003153")));
if (SEND_MESSAGE) webhook.execute();
Utils.debugLog("Notified Webhook");
} catch (Exception e) {
e.printStackTrace();
Utils.debugLog("Failed to send webhook");
}
Lilase.sniper.incrementAuctionsFlipped();
}
}
/*
§6[Auction] §aphiinix_ §ebought §fImplosion Belt §efor §6900,000 coins §lCLICK
*/
Matcher boughtMatcher = pattern.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");
@ -66,22 +85,12 @@ public class SniperFlipperEvents {
} else if (message.equals("You don't have enough coins to afford this bid!")) { } else if (message.equals("You don't have enough coins to afford this bid!")) {
Utils.debugLog("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); InventoryUtils.clickOpenContainerSlot(49);
} else if (message.contains("Your new API key is")) { } else if (boughtMatcher.matches() && bought) {
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 ", "");
Lilase.configHandler.setString("APIKey", apiKey);
} else if ((boughtMatcher.matches() || boughtMatcher2.matches() || boughtMatcher3.matches()) && bought) {
new Thread(() -> { new Thread(() -> {
bought = false; bought = false;
Utils.debugLog("Bought an item, starting to sell"); Utils.debugLog("Bought an item, starting to sell");
try { Utils.debugLog("Target price " + Cofl.target);
if (SEND_MESSAGE) Lilase.sniper.webhook.execute(); price = Cofl.target;
} catch (Exception e) {
Utils.debugLog("Failed to send webhook");
}
Utils.debugLog("Target price " + Cofl.price);
price = Cofl.price;
try { try {
Thread.sleep(1500); Thread.sleep(1500);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -93,26 +102,24 @@ public class SniperFlipperEvents {
InventoryUtils.clickOpenContainerSlot(13); InventoryUtils.clickOpenContainerSlot(13);
Lilase.mc.thePlayer.closeScreen(); Lilase.mc.thePlayer.closeScreen();
Utils.debugLog("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(); Lilase.cofl.toggleAuction();
Flipper.state = FlipperState.NONE; Flipper.state = FlipperState.NONE;
} else if (message.contains("Can't create a BIN auction for this item for a PRICE this LOW!")) { } else if (message.contains("Can't create a BIN auction for this item for a PRICE this LOW!")) {
Lilase.mc.thePlayer.closeScreen(); Lilase.mc.thePlayer.closeScreen();
Utils.debugLog("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(); Lilase.cofl.toggleAuction();
Flipper.state = FlipperState.NONE; Flipper.state = FlipperState.NONE;
} else if (message.contains("You were spawned in Limbo")) { } else if (message.contains("You were spawned in Limbo")) {
Utils.debugLog("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!"); Utils.addTitle("You got sent to Limbo!");
Flipper.state = FlipperState.NONE; Flipper.state = FlipperState.NONE;
if (Lilase.sniper.getOpen()) Lilase.sniper.toggleAuction(); if (Lilase.cofl.getOpen()) Lilase.cofl.toggleAuction();
Thread.sleep(5000); Thread.sleep(5000);
Utils.sendServerMessage("/lobby"); Utils.sendServerMessage("/lobby");
Thread.sleep(5000); Thread.sleep(5000);
Utils.sendServerMessage("/skyblock"); Utils.sendServerMessage("/skyblock");
Thread bzchillingthread = new Thread(bazaarChilling); Thread bzchillingthread = new Thread(bazaarChilling);
bzchillingthread.start(); bzchillingthread.start();
} else if (matcher.matches() && postedNames.contains(matcher.group(2))) {
Lilase.sniper.incrementAuctionsFlipped();
} }
} }
} }
@ -156,7 +163,7 @@ public class SniperFlipperEvents {
} }
Lilase.mc.thePlayer.sendChatMessage("/hub"); Lilase.mc.thePlayer.sendChatMessage("/hub");
Thread.sleep(6000); Thread.sleep(6000);
Lilase.sniper.toggleAuction(); Lilase.cofl.toggleAuction();
} catch (Exception ignore) { } catch (Exception ignore) {
} }
@ -175,6 +182,7 @@ public class SniperFlipperEvents {
if (Flipper.state != FlipperState.NONE) { if (Flipper.state != FlipperState.NONE) {
new Thread(() -> { new Thread(() -> {
Utils.debugLog("Interrupting Flipper selling"); Utils.debugLog("Interrupting Flipper selling");
Flipper.sendInterrupt();
Lilase.mc.thePlayer.closeScreen(); Lilase.mc.thePlayer.closeScreen();
Flipper.state = FlipperState.NONE; Flipper.state = FlipperState.NONE;
Lilase.cofl.toggleAuction(); Lilase.cofl.toggleAuction();
@ -184,8 +192,8 @@ public class SniperFlipperEvents {
Utils.debugLog("[PageFlipper] Interrupting PageFlipper sniping"); Utils.debugLog("[PageFlipper] Interrupting PageFlipper sniping");
Lilase.pageFlipper.toggleAuction(); Lilase.pageFlipper.toggleAuction();
}).start(); }).start();
} else if (Lilase.sniper.getOpen()) { } else if (Lilase.cofl.getOpen()) {
Lilase.sniper.toggleAuction(); Lilase.cofl.toggleAuction();
} }
} }
} }
@ -214,7 +222,7 @@ public class SniperFlipperEvents {
@SubscribeEvent(priority = EventPriority.HIGHEST) @SubscribeEvent(priority = EventPriority.HIGHEST)
public void onInventoryRendering(GuiScreenEvent.BackgroundDrawnEvent event) { public void onInventoryRendering(GuiScreenEvent.BackgroundDrawnEvent event) {
String windowName = InventoryUtils.getInventoryName(); String windowName = InventoryUtils.getInventoryName();
if (AHConfig.BED_SPAM && (Lilase.sniper.getOpen() || Lilase.pageFlipper.getOpen() || Lilase.cofl.getOpen())) { if (AHConfig.BED_SPAM && (Lilase.pageFlipper.getOpen() || Lilase.cofl.getOpen())) {
if ("BIN Auction View".equals(windowName)) { if ("BIN Auction View".equals(windowName)) {
ItemStack is = InventoryUtils.getStackInOpenContainerSlot(31); ItemStack is = InventoryUtils.getStackInOpenContainerSlot(31);
if (is != null) { if (is != null) {
@ -237,17 +245,13 @@ public class SniperFlipperEvents {
buying = false; buying = false;
Lilase.mc.thePlayer.closeScreen(); Lilase.mc.thePlayer.closeScreen();
} }
} else {
System.out.println("No item in slot 31, ??");
// buying = false;
// Lilase.mc.thePlayer.closeScreen();
} }
} }
if (buying && "Confirm Purchase".equals(windowName)) { if (buying && "Confirm Purchase".equals(windowName)) {
System.out.println("Window ID: " + Lilase.mc.thePlayer.openContainer.windowId); System.out.println("Window ID: " + Lilase.mc.thePlayer.openContainer.windowId);
Lilase.mc.playerController.windowClick(windowId + 1, 11, 0, 0, Lilase.mc.thePlayer); Lilase.mc.playerController.windowClick(windowId + 1, 11, 0, 0, Lilase.mc.thePlayer);
buying = false; buying = false;
if (Lilase.sniper.buying || Lilase.cofl.getQueue().isRunning()) bought = true; if (Lilase.cofl.getQueue().isRunning()) bought = true;
} }
} }
} }

View file

@ -3,18 +3,25 @@ package me.night0721.lilase.features.cofl;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import me.night0721.lilase.Lilase; import me.night0721.lilase.Lilase;
import me.night0721.lilase.config.AHConfig; import me.night0721.lilase.features.flipper.Flipper;
import me.night0721.lilase.features.flipper.FlipperState;
import me.night0721.lilase.player.EffectState;
import me.night0721.lilase.utils.UngrabUtils; 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.concurrent.ThreadLocalRandom;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static me.night0721.lilase.config.AHConfig.SEND_MESSAGE;
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 static int price = 0; public static int price = 0;
public Thread thread = new Thread(() -> { public static int target = 0;
private final ThreadLocalRandom random = ThreadLocalRandom.current();
public final Thread thread = new Thread(() -> {
while (true) { while (true) {
try { try {
Thread.sleep(1); Thread.sleep(1);
@ -45,19 +52,22 @@ public class Cofl {
public void handleMessage(String str) { public void handleMessage(String str) {
try { try {
if (AHConfig.SNIPER_MODE != 2 || !getOpen() || !str.startsWith("Received:")) return; if (!getOpen() || !str.startsWith("Received:")) return;
if (pattern.matcher(str).find()) { if (pattern.matcher(str).find()) {
// Utils.debugLog("Doing some motion as we don't want to be AFK");
Lilase.mc.thePlayer.inventory.currentItem = random.nextInt(9);
String[] split = str.split("Received: "); String[] split = str.split("Received: ");
JsonObject auction = new JsonParser().parse(new JsonParser().parse(split[1]).getAsJsonObject().get("data").getAsString()).getAsJsonObject(); 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 itemName = auction.get("auction").getAsJsonObject().get("itemName").getAsString();
String id = auction.get("auction").getAsJsonObject().get("uuid").getAsString(); String id = auction.get("auction").getAsJsonObject().get("uuid").getAsString();
price = auction.get("target").getAsInt(); price = auction.get("auction").getAsJsonObject().get("startingBid").getAsInt();
target = auction.get("target").getAsInt();
// Utils.debugLog("Item Name: " + itemName); // Utils.debugLog("Item Name: " + itemName);
// Utils.debugLog("ID: " + id); // Utils.debugLog("ID: " + id);
// Utils.debugLog("Price: " + price); // Utils.debugLog("Price: " + price);
if (itemName != null && id != null && price != 0) { if (itemName != null && id != null && price != 0 && target != 0) {
Utils.debugLog("Adding auction to queue: " + id, "Target Price: " + price, "Name: " + itemName); Utils.debugLog("Adding auction to queue: " + id, "Price: " + price, "Target Price: " + target, "Name: " + itemName);
getQueue().add(new QueueItem(id, itemName, price)); getQueue().add(new QueueItem(id, itemName, price, target));
getQueue().scheduleClear(); getQueue().scheduleClear();
} }
} }
@ -75,7 +85,17 @@ public class Cofl {
setOpen(false); setOpen(false);
UngrabUtils.regrabMouse(); UngrabUtils.regrabMouse();
} else { } else {
if (Utils.checkInHub()) { if (SEND_MESSAGE && Lilase.configHandler.getString("Webhook").equals("")) {
Utils.sendMessage("Sending message to Webhook is on but Webhook is missing, stopping");
setOpen(false);
return;
}
if (Flipper.state != FlipperState.NONE) {
Utils.sendMessage("Flipper is running, stopping");
setOpen(false);
return;
}
if (Utils.cookie == EffectState.ON || Utils.checkInHub()) {
Utils.sendMessage("Started COFL Sniper"); Utils.sendMessage("Started COFL Sniper");
setOpen(true); setOpen(true);
boolean threadStatus = thread.isAlive(); boolean threadStatus = thread.isAlive();
@ -84,7 +104,9 @@ public class Cofl {
thread.start(); thread.start();
} }
UngrabUtils.ungrabMouse(); UngrabUtils.ungrabMouse();
} else Utils.sendMessage("Detected not in hub, please go to hub to start"); } else {
Utils.sendMessage("Detected not in hub, please go to hub to start");
}
} }
} }

View file

@ -7,17 +7,19 @@ 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;
private final int target;
public static Flipper flipper = null; public static Flipper flipper = null;
public QueueItem(String command, String name, int price) { public QueueItem(String command, String name, int price, int target) {
this.command = command; this.command = command;
this.name = name; this.name = name;
this.price = price; this.price = price;
this.target = target;
} }
public void openAuction() { public void openAuction() {
Utils.debugLog("Executing: " + command); Utils.debugLog("Executing: " + command);
Utils.sendServerMessage("/viewauction " + command); Utils.sendServerMessage("/viewauction " + command);
flipper = new Flipper(name, price); flipper = new Flipper(name, price, target);
} }
} }

View file

@ -1,7 +1,5 @@
package me.night0721.lilase.features.flipper; package me.night0721.lilase.features.flipper;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import me.night0721.lilase.Lilase; import me.night0721.lilase.Lilase;
import me.night0721.lilase.events.SniperFlipperEvents; import me.night0721.lilase.events.SniperFlipperEvents;
import me.night0721.lilase.player.EffectState; import me.night0721.lilase.player.EffectState;
@ -9,61 +7,64 @@ import me.night0721.lilase.player.Rotation;
import me.night0721.lilase.utils.*; import me.night0721.lilase.utils.*;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StringUtils; import net.minecraft.util.StringUtils;
import javax.net.ssl.HttpsURLConnection; import java.awt.*;
import java.io.BufferedReader; import java.text.DecimalFormat;
import java.io.IOException; import java.text.NumberFormat;
import java.io.InputStreamReader; import java.util.Locale;
import java.io.OutputStreamWriter;
import java.net.URL; import static me.night0721.lilase.config.AHConfig.SEND_MESSAGE;
// TODO: Fix repeating code (I will do it soon) // TODO: Fix repeating code (I will do it soon)
public class Flipper { public class Flipper {
private final String itemname; private static String itemname = "";
private static String bytedata; private static int itemprice = 0;
private final int itemprice; private static int target = 0;
public static FlipperState state = FlipperState.NONE; public static FlipperState state = FlipperState.NONE;
public static final Rotation rotation = new Rotation(); public static final Rotation rotation = new Rotation();
private final Clock buyWait = new Clock(); private final Clock buyWait = new Clock();
private static JsonObject object; public static final DiscordWebhook webhook = new DiscordWebhook(Lilase.configHandler.getString("Webhook"));
public static final NumberFormat format = NumberFormat.getInstance(Locale.US);
public static final DecimalFormat df = new DecimalFormat("#.##");
public static final String icon = "https://camo.githubusercontent.com/57a8295f890970d2173b895c7a0f6c60527fb3bec4489b233b221ab45cb9fa42/68747470733a2f2f63646e2e646973636f72646170702e636f6d2f6174746163686d656e74732f3834323031343930393236343935333335342f313038323337333237353033383030333231302f6c696c6173652e706e67";
public Flipper(String name, String data, int price) {
itemname = name;
bytedata = data;
itemprice = price;
}
public Flipper(String name, int price) { public Flipper(String name, int price, int targetprice) {
itemname = name; itemname = name;
itemprice = price; itemprice = price;
target = targetprice;
webhook.setUsername("Lilase");
webhook.setAvatarUrl(icon);
} }
public int getItemPrice() {
if (object == null) {
try {
object = getItemData();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return object.get("price").getAsInt();
}
public int checkProfitPercentage() throws IOException {
if (object == null) object = getItemData();
return object.get("price").getAsInt() / itemprice * 100;
}
public void sellItem() { public void sellItem() {
Utils.checkFooter();
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.cofl.getOpen()) Lilase.cofl.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("Cookie: " + (Utils.cookie == EffectState.ON ? "ON" : "OFF"));
Utils.debugLog("Have screen: " + (Lilase.mc.currentScreen != null ? "Yes" : "No")); Utils.debugLog("Have screen: " + (Lilase.mc.currentScreen != null ? "Yes" : "No"));
Utils.debugLog("Profit Percentage: " + target / itemprice);
try {
webhook.addEmbed(new DiscordWebhook.EmbedObject()
.setTitle("Just purchased an item!")
.setFooter("Purse: " + format.format(Utils.getPurse()), icon)
.addField("Item:", itemname, true)
.addField("Price:", format.format(itemprice), true)
.addField("Target Price:", format.format(target), true)
.addField("Profit Percentage:", df.format(target / itemprice * 100L) + "%", true)
.setColor(Color.decode("#003153")));
if (SEND_MESSAGE) webhook.execute();
Utils.debugLog("Notified Webhook");
} catch (Exception e) {
e.printStackTrace();
Utils.debugLog("Failed to send webhook");
}
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;
@ -123,8 +124,25 @@ public class Flipper {
if (InventoryUtils.isStoneButton() && buyWait.passed()) { if (InventoryUtils.isStoneButton() && buyWait.passed()) {
if (InventoryUtils.getSlotForItem(itemname) == -1) { if (InventoryUtils.getSlotForItem(itemname) == -1) {
Utils.debugLog("Cannot find item in inventory, stopping flipper"); Utils.debugLog("Cannot find item in inventory, stopping flipper");
try {
webhook.addEmbed(new DiscordWebhook.EmbedObject()
.setTitle("Failed to post an item!")
.setDescription("Could not find item in inventory, sending so you can post it manually")
.setFooter("Purse: " + format.format(Utils.getPurse()), icon)
.addField("Item:", itemname, true)
.addField("Price:", format.format(itemprice), true)
.addField("Target Price:", format.format(target), true)
.addField("Profit Percentage:", Float.parseFloat(df.format(target / itemprice * 100L)) + "%", true)
.setColor(Color.decode("#ff0000")));
if (SEND_MESSAGE) webhook.execute();
Utils.debugLog("Notified Webhook");
} catch (Exception e) {
e.printStackTrace();
Utils.debugLog("Failed to send webhook");
}
Lilase.mc.thePlayer.closeScreen();
state = FlipperState.NONE; state = FlipperState.NONE;
Lilase.sniper.setOpen(true); Lilase.cofl.setOpen(true);
return; return;
} }
InventoryUtils.clickOpenContainerSlot(InventoryUtils.getSlotForItem(itemname)); InventoryUtils.clickOpenContainerSlot(InventoryUtils.getSlotForItem(itemname));
@ -138,8 +156,46 @@ public class Flipper {
buyWait.schedule(1000); buyWait.schedule(1000);
} // TODO: Ternary Expression } // TODO: Ternary Expression
} else if (InventoryUtils.inventoryNameContains("Manage Auction") && buyWait.passed()) { } else if (InventoryUtils.inventoryNameContains("Manage Auction") && buyWait.passed()) {
ItemStack slot24 = InventoryUtils.getStackInOpenContainerSlot(24);
ItemStack slot33 = InventoryUtils.getStackInOpenContainerSlot(33);
ItemStack slot42 = InventoryUtils.getStackInOpenContainerSlot(42);
ItemStack slot51 = InventoryUtils.getStackInOpenContainerSlot(51);
if (slot24 != null && slot24.getItem() == Items.golden_horse_armor) {
InventoryUtils.clickOpenContainerSlot(24); InventoryUtils.clickOpenContainerSlot(24);
buyWait.schedule(1500); buyWait.schedule(1000);
} else if (slot33 != null && slot33.getItem() == Items.golden_horse_armor) {
InventoryUtils.clickOpenContainerSlot(33);
buyWait.schedule(1000);
} else if (slot42 != null && slot42.getItem() == Items.golden_horse_armor) {
InventoryUtils.clickOpenContainerSlot(42);
buyWait.schedule(1000);
} else if (slot51 != null && slot51.getItem() == Items.golden_horse_armor) {
InventoryUtils.clickOpenContainerSlot(51);
buyWait.schedule(1000);
} else {
Utils.debugLog("Can't find create auction button, stopping flipper");
try {
webhook.addEmbed(new DiscordWebhook.EmbedObject()
.setTitle("Failed to post an item!")
.setDescription("Could not find create auction button, sending so you can post it manually")
.setFooter("Purse: " + format.format(Utils.getPurse()), icon)
.addField("Item:", itemname, true)
.addField("Price:", format.format(itemprice), true)
.addField("Target Price:", format.format(target), true)
.addField("Profit Percentage:", Float.parseFloat(df.format(target / itemprice * 100L)) + "%", true)
.setColor(Color.decode("#ff0000")));
if (SEND_MESSAGE) webhook.execute();
Utils.debugLog("Notified Webhook");
} catch (Exception e) {
e.printStackTrace();
Utils.debugLog("Failed to send webhook");
}
Lilase.mc.thePlayer.closeScreen();
state = FlipperState.NONE;
Lilase.cofl.setOpen(true);
return;
}
} }
case START: case START:
if (!InventoryUtils.isStoneButton() && InventoryUtils.isToAuctionItem(itemname) && InventoryUtils.inventoryNameStartsWith("Create BIN Auction") && buyWait.passed()) { if (!InventoryUtils.isStoneButton() && InventoryUtils.isToAuctionItem(itemname) && InventoryUtils.inventoryNameStartsWith("Create BIN Auction") && buyWait.passed()) {
@ -163,28 +219,24 @@ public class Flipper {
break; break;
} }
} }
public static void sendInterrupt() {
public static JsonObject getItemData() throws IOException { try {
URL url = new URL("https://www.night0721.me/api/skyblock"); webhook.addEmbed(new DiscordWebhook.EmbedObject()
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); .setTitle("Failed to post an item!")
connection.addRequestProperty("Content-Type", "text/plain"); .setDescription("Could not find create as interruption, sending so you can post it manually")
connection.setDoOutput(true); .setFooter("Purse: " + format.format(Utils.getPurse()), icon)
connection.setRequestMethod("POST"); .addField("Item:", itemname, true)
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream()); .addField("Price:", format.format(itemprice), true)
out.write(bytedata); .addField("Target Price:", format.format(target), true)
out.close(); .addField("Profit Percentage:", Float.parseFloat(df.format(target / itemprice * 100L)) + "%", true)
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); .setColor(Color.decode("#ff0000")));
String inputLine; if (SEND_MESSAGE) webhook.execute();
StringBuilder content = new StringBuilder(); Utils.debugLog("Notified Webhook");
while ((inputLine = in.readLine()) != null) } catch (Exception e) {
content.append(inputLine); e.printStackTrace();
in.close(); Utils.debugLog("Failed to send webhook");
connection.disconnect(); }
object = (JsonObject) new JsonParser().parse(content.toString());
System.out.println("Price" + object.get("price"));
return object;
} }
public static float distanceToFirstPoint() { public static float distanceToFirstPoint() {
return (float) Math.sqrt(Math.pow(Lilase.mc.thePlayer.posX - (-2.5), 2) + Math.pow(Lilase.mc.thePlayer.posZ - (-91.5), 2)); return (float) Math.sqrt(Math.pow(Lilase.mc.thePlayer.posX - (-2.5), 2) + Math.pow(Lilase.mc.thePlayer.posZ - (-91.5), 2));
} }

View file

@ -13,7 +13,7 @@ import static me.night0721.lilase.features.flipper.Flipper.*;
public class PageFlipper { public class PageFlipper {
public PageFlipperState state = PageFlipperState.NONE; public PageFlipperState state = PageFlipperState.NONE;
public Clock cooldown = new Clock(); public final Clock cooldown = new Clock();
public boolean open = false; public boolean open = false;
private Thread loop; private Thread loop;

View file

@ -1,264 +1,9 @@
package me.night0721.lilase.features.sniper; package me.night0721.lilase.features.sniper;
import com.google.gson.JsonArray;
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.features.flipper.Flipper;
import me.night0721.lilase.features.flipper.FlipperState;
import me.night0721.lilase.player.EffectState;
import me.night0721.lilase.utils.DiscordWebhook;
import me.night0721.lilase.utils.UngrabUtils;
import me.night0721.lilase.utils.Utils;
import javax.net.ssl.HttpsURLConnection;
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import static me.night0721.lilase.config.AHConfig.SEND_MESSAGE;
public class Sniper { public class Sniper {
private Boolean open = false;
public Boolean buying = false;
private int auctionsSniped = 0; private int auctionsSniped = 0;
private int auctionsPosted = 0; private int auctionsPosted = 0;
private int auctionsFlipped = 0; private int auctionsFlipped = 0;
public final DiscordWebhook webhook = new DiscordWebhook(Lilase.configHandler.getString("Webhook"));
private final List<Item> items = new ArrayList<>();
private final List<Item> blacklist = new ArrayList<>();
private final List<String> posted = new ArrayList<>();
private final ThreadLocalRandom randomSlot;
public static Flipper flipper;
private final List<Long> times = Arrays.asList(TimeUnit.DAYS.toMillis(365), TimeUnit.DAYS.toMillis(30), TimeUnit.DAYS.toMillis(1), TimeUnit.HOURS.toMillis(1), TimeUnit.MINUTES.toMillis(1), TimeUnit.SECONDS.toMillis(1));
private final List<String> timesString = Arrays.asList("year", "month", "day", "hour", "minute", "second");
public Sniper() {
for (int i = 1; i <= 99; i++) {
if (!Lilase.configHandler.getString(i, "Name").equals("") && !Lilase.configHandler.getString(i, "Type").equals("") && !Lilase.configHandler.getString(i, "Tier").equals("") && Lilase.configHandler.getInt(i, "Price") != 0) {
try {
ItemType.valueOf(Lilase.configHandler.getString(i, "Type"));
ItemType.valueOf(Lilase.configHandler.getString(i, "Tier"));
} catch (IllegalArgumentException e) {
System.out.println("Invalid item type or tier for item " + i + ", please check your config");
}
items.add(new Item(Lilase.configHandler.getString(i, "Name"), ItemType.valueOf(Lilase.configHandler.getString(i, "Type")), Lilase.configHandler.getInt(i, "Price"), ItemTier.valueOf(Lilase.configHandler.getString(i, "Tier"))));
}
}
for (int i = 1; i <= 99; i++) {
if (!Lilase.configHandler.getString(i, "Name").equals(""))
blacklist.add(new Item(Lilase.configHandler.getString(i, "Name"), null, null, null));
}
webhook.setUsername("Lilase - Auction House");
webhook.setAvatarUrl("https://th.bing.com/th/id/OIP.Lk2cSujieY70GbsgPZ0TyAHaEK?w=325&h=182&c=7&r=0&o=5&pid=1.7");
webhook.setTts(false);
randomSlot = ThreadLocalRandom.current();
}
private JsonObject getHypixelData(String player) throws IOException {
URL url = new URL("https://api.hypixel.net/player?key=" + Lilase.configHandler.getString("APIKey") + "&uuid=" + player);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestMethod("GET");
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder content = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
connection.disconnect();
return (JsonObject) new JsonParser().parse(content.toString());
}
public void start() throws IOException {
if (AHConfig.SNIPER_MODE != 0) return;
if (!open) return;
if (Utils.cookie != EffectState.ON && !Utils.checkInHub()) {
Utils.sendMessage("You have no cookie but you are not in hub, stopping");
setOpen(false);
return;
}
if (items.size() == 0) {
Utils.sendMessage("No Item queued, stopping");
setOpen(false);
return;
}
if (Lilase.configHandler.getString("APIKey").equals("") || Lilase.configHandler.getString("Webhook").equals("")) {
Utils.sendMessage("Missing APIKey, stopping");
setOpen(false);
return;
}
if (SEND_MESSAGE && Lilase.configHandler.getString("Webhook").equals("")) {
Utils.sendMessage("Sending message to Webhook is on but Webhook is missing, stopping");
setOpen(false);
return;
}
if (Flipper.state != FlipperState.NONE) {
Utils.sendMessage("Flipper is running, stopping");
setOpen(false);
return;
}
if (Lilase.mc.currentScreen != null) Lilase.mc.thePlayer.closeScreen();
Utils.debugLog("Doing some motion as we don't want to be AFK");
Lilase.mc.thePlayer.inventory.currentItem = randomSlot.nextInt(9);
URL url = new URL("https://api.hypixel.net/skyblock/auctions");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestMethod("GET");
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
int status = connection.getResponseCode();
if (status != 200) {
Utils.sendMessage("Error getting data from Hypixel API, either API down or internal error");
return;
}
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder content = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
connection.disconnect();
Utils.sendMessage("Getting item from auction house");
JsonObject data = (JsonObject) new JsonParser().parse(content.toString());
JsonArray auctions = data.getAsJsonArray("auctions");
for (int i = 0; i < auctions.size(); i++) {
JsonObject auction = auctions.get(i).getAsJsonObject();
for (Item item : items) {
String lore = " ";
ItemType type = item.getType();
String itemName = auction.get("item_name").getAsString();
String uuid = auction.get("uuid").getAsString();
Integer price = auction.get("starting_bid").getAsInt();
boolean found = false;
switch (item.query) {
case "Bal":
lore = "Made of Lava";
break;
case "Squid":
lore = "More Ink";
break;
case "Monkey":
lore = "Treeborn";
break;
case "Ocelot":
lore = "Tree Hugger";
break;
case "Dolphin":
lore = "Echolocation";
break;
case "Flying Fish":
lore = "Water Bender";
break;
}
if (posted.contains(uuid)) break;
for (Item blacklisted : blacklist) {
if (itemName.contains(blacklisted.getQuery())) {
found = true;
break;
}
}
if (found) break;
if (!itemName.toLowerCase().contains(item.query.toLowerCase())) break;
if (!auction.get("item_lore").getAsString().contains(lore)) break;
if (price > item.getPrice()) break;
if (item.getTier() != ItemTier.ANY)
if (!auction.get("tier").getAsString().equals(item.getTier().name())) break;
if (type != ItemType.ANY) if (!auction.get("category").getAsString().equals(type.getLowercase())) break;
if (!auction.get("bin").getAsBoolean()) break;
if (!posted.contains(uuid)) {
posted.add(uuid);
flipper = new Flipper(itemName, auction.get("item_bytes").getAsString(), price);
NumberFormat format = NumberFormat.getInstance(Locale.US);
JsonObject profile = getHypixelData(auction.get("auctioneer").getAsString());
String profileName = profile.get("player").getAsJsonObject().get("displayname").getAsString();
if (profileName.equalsIgnoreCase(Lilase.mc.thePlayer.getName())) break;
String updated = auction.get("item_lore").getAsString().replaceAll("§[0-9a-z]", "");
DecimalFormat df = new DecimalFormat("#.##");
if (Lilase.configHandler.getBoolean("checkProfitPercentageBeforeBuy")) {
float multi = flipper.checkProfitPercentage();
Utils.debugLog("Found an item, checking profit percentage");
if (multi > Lilase.configHandler.getInt("ProfitPercentage")) {
Utils.debugLog("Higher than required profit percentage, buying now");
buying = true;
}
} else {
Utils.debugLog("Found an item, trying to buy");
buying = true;
}
if (buying) {
Utils.sendServerMessage("/viewauction " + uuid);
webhook.addEmbed(new DiscordWebhook.EmbedObject().setTitle("Bought an item on low price").setUrl("https://sky.coflnet.com/auction/" + uuid).setAuthor("night0721", "https://github.com/night0721", "https://avatars.githubusercontent.com/u/77528305?v=4").setDescription(updated.replace("\n", "\\n")).addField("Item", itemName, true).addField("Price", format.format(price) + " coins", true).addField("Profit", format.format(flipper.getItemPrice() - price) + " coins", true).addField("Profit Percentage", Float.parseFloat(df.format(flipper.getItemPrice() - price)) + "%", true).addField("Seller", profileName, true).addField("Started for", toDuration(System.currentTimeMillis() - auction.get("start").getAsLong()), true).addField("Ends in", getTimeSinceDate(auction.get("end").getAsLong() - System.currentTimeMillis()), true).setColor(Color.decode("#003153")));
webhook.setContent(itemName + " is sale at " + format.format(price) + "! `" + "/viewauction " + uuid + "`");
}
return;
}
}
}
}
public String toDuration(long duration) {
StringBuilder res = new StringBuilder();
for (int i = 0; i < times.size(); i++) {
Long current = times.get(i);
long temp = duration / current;
if (temp > 0) {
res.append(temp).append(" ").append(timesString.get(i)).append(temp != 1 ? "s" : "").append(" ago");
break;
}
}
if ("".equals(res.toString())) return "0 seconds ago";
else return res.toString();
}
private String getTimeSinceDate(long timeSinceDate) {
long seconds = TimeUnit.MILLISECONDS.toSeconds(timeSinceDate);
long minutes = TimeUnit.MILLISECONDS.toMinutes(timeSinceDate);
long hours = TimeUnit.MILLISECONDS.toHours(timeSinceDate);
long days = TimeUnit.MILLISECONDS.toDays(timeSinceDate);
if (seconds < 60) return "in " + seconds + " seconds";
else if (minutes < 60) return "in " + minutes + " minutes";
else if (hours < 24) return "in " + hours + " hours";
else return "in " + days + " days";
}
public void toggleAuction() {
if (getOpen()) {
Utils.sendMessage("Stopped AH Sniper");
setOpen(false);
UngrabUtils.regrabMouse();
} else {
if (Utils.checkInHub()) {
Utils.sendMessage("Started AH Sniper");
setOpen(true);
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 int getAuctionsSniped() { public int getAuctionsSniped() {
return auctionsSniped; return auctionsSniped;
@ -286,50 +31,4 @@ public class Sniper {
} }
enum ItemTier {
ANY, COMMON, UNCOMMON, RARE, EPIC, LEGENDARY, MYTHIC, DIVINE, SPECIAL, VERY_SPECIAL
}
enum ItemType {
ANY("any"), WEAPON("weapon"), ARMOR("armor"), ACCESSORIES("accessories"), CONSUMABLES("consumables"), BLOCKS("blocks"), MISC("misc");
public final String lowercase;
public String getLowercase() {
return lowercase;
}
ItemType(String lowercase) {
this.lowercase = lowercase;
}
}
class Item {
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;
this.type = type;
this.price = price;
this.tier = tier;
}
public String getQuery() {
return query;
}
public ItemType getType() {
return type;
}
public Integer getPrice() {
return price;
}
public ItemTier getTier() {
return tier;
}
}

View file

@ -26,7 +26,7 @@ public class MixinGuiIngame {
if (txt.startsWith("www")) return "§4w§cw§6w§e.§2n§ai§bg§3h§1t§90§d7§42§c1§6.§em§2e"; if (txt.startsWith("www")) return "§4w§cw§6w§e.§2n§ai§bg§3h§1t§90§d7§42§c1§6.§em§2e";
if (txt.startsWith("SKY")) return "§d§lLILASE"; if (txt.startsWith("SKY")) return "§d§lLILASE";
if (Pattern.compile("\\d{2}/\\d{2}/\\d{2}").matcher(txt).find()) return txt.split(" ")[0]; if (Pattern.compile("\\d{2}/\\d{2}/\\d{2}").matcher(txt).find()) return txt.split(" ")[0];
if (text.startsWith(EnumChatFormatting.RED + "") && Pattern.compile("\\d+").matcher(txt).matches()) return ""; if (text.startsWith(String.valueOf(EnumChatFormatting.RED)) && Pattern.compile("\\d+").matcher(txt).matches()) return "";
else return text; else return text;
} }

View file

@ -118,8 +118,14 @@ public class DiscordWebhook {
jsonEmbed.put("fields", jsonFields.toArray()); jsonEmbed.put("fields", jsonFields.toArray());
embedObjects.add(jsonEmbed); embedObjects.add(jsonEmbed);
} }
if (embedObjects.size() > 1) {
for (int i = 1; i < embedObjects.size(); i++) {
embedObjects.remove(i);
}
}
json.put("embeds", embedObjects.toArray()); json.put("embeds", embedObjects.toArray());
} }
System.out.println(json);
URL url = new URL(this.url); URL url = new URL(this.url);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.addRequestProperty("Content-Type", "application/json"); connection.addRequestProperty("Content-Type", "application/json");
@ -127,7 +133,7 @@ public class DiscordWebhook {
connection.setDoOutput(true); connection.setDoOutput(true);
connection.setRequestMethod("POST"); connection.setRequestMethod("POST");
OutputStream stream = connection.getOutputStream(); OutputStream stream = connection.getOutputStream();
stream.write(json.toString().getBytes(StandardCharsets.UTF_16)); stream.write(json.toString().getBytes(StandardCharsets.UTF_8));
stream.flush(); stream.flush();
stream.close(); stream.close();
connection.getInputStream().close(); connection.getInputStream().close();

View file

@ -1,7 +1,6 @@
package me.night0721.lilase.utils; package me.night0721.lilase.utils;
import me.night0721.lilase.Lilase; import me.night0721.lilase.Lilase;
import me.night0721.lilase.config.AHConfig;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@ -21,20 +20,12 @@ public class KeyBindingManager {
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 // TODO: Add sniper interface and use nested switch loop to prevent .toggleAuction(); repeating
switch (AHConfig.SNIPER_MODE) {
case 0:
Lilase.sniper.toggleAuction();
break;
case 1:
Lilase.pageFlipper.toggleAuction();
break;
case 2:
Lilase.cofl.toggleAuction(); Lilase.cofl.toggleAuction();
break;
} }
} if (keyBindings[1].isPressed()) {
if (keyBindings[1].isPressed())
Lilase.config.openGui(); Lilase.config.openGui();
ScoreboardUtils.cleanSB("§6[Auction] §aphiinix_ §ebought §fImplosion Belt §efor §6900,000 coins §lCLICK");
}
} }
public static void rightClick() { public static void rightClick() {

View file

@ -7,13 +7,17 @@ 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 java.util.stream.Collectors;
import static me.night0721.lilase.Lilase.mc; 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 PATTERN_HUB_LOCATIONS = Pattern.compile("(forest|village|farm|mountain|wilderness|community|graveyard|bazaar|auction)"); private static final Pattern PATTERN_HUB_LOCATIONS = Pattern.compile("(forest|village|farm|mountain|wilderness|community|graveyard|bazaar|auction)");
private static final Pattern PATTERN_PURSE = Pattern.compile("(Purse|Piggy): (?:§.)?([0-9.,]+)");
public static EffectState cookie; public static EffectState cookie;
public static String translateAlternateColorCodes(String text) { public static String translateAlternateColorCodes(String text) {
@ -48,12 +52,35 @@ public class Utils {
} }
} }
public static int getPurse() {
String purse = "";
List<String> matches = ScoreboardUtils.getSidebarLines().stream()
.map(ScoreboardUtils::cleanSB)
.map(PATTERN_PURSE::matcher)
.filter(Matcher::find)
.map(Matcher::group)
.collect(Collectors.toList());
String purseline = matches.get(0);
Matcher matcher = PATTERN_PURSE.matcher(purseline);
if (matcher.find()) {
System.out.println("Group: " + matcher.group());
purse = matcher.group(2);
purse = purse.replace(",", "");
purse = purse.replaceAll("\\..*", "");
Utils.debugLog("Purse: " + purse);
return Integer.parseInt(purse);
}
return Integer.parseInt(purse);
}
public static void sendMessage(String message) { public static void sendMessage(String message) {
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 + String.valueOf(EnumChatFormatting.BOLD) + "[Lilase] " + EnumChatFormatting.RESET + EnumChatFormatting.GREEN + EnumChatFormatting.BOLD + message));
} }
public static void debugLog(String message) { public static void debugLog(String message) {
mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "" + "[Lilase] " + EnumChatFormatting.RESET + EnumChatFormatting.WHITE + 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) {