fix
This commit is contained in:
parent
f710cd083e
commit
1017da9fb1
8 changed files with 279 additions and 10 deletions
10
build.gradle
10
build.gradle
|
@ -40,10 +40,16 @@ configurations {
|
||||||
dependencies {
|
dependencies {
|
||||||
packageLib("gg.essential:loader-launchwrapper:1.1.3")
|
packageLib("gg.essential:loader-launchwrapper:1.1.3")
|
||||||
implementation("gg.essential:essential-1.8.9-forge:2581")
|
implementation("gg.essential:essential-1.8.9-forge:2581")
|
||||||
|
implementation("com.squareup.okhttp3:okhttp:4.10.0")
|
||||||
|
implementation("org.json:json:20220924")
|
||||||
annotationProcessor('org.spongepowered:mixin:0.7.11-SNAPSHOT')
|
annotationProcessor('org.spongepowered:mixin:0.7.11-SNAPSHOT')
|
||||||
implementation('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
|
implementation('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
|
shadow "org.json:json:20220924"
|
||||||
|
shadow "com.squareup.okhttp3:okhttp:4.10.0"
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mixin {
|
mixin {
|
||||||
|
@ -70,12 +76,12 @@ jar {
|
||||||
shadowJar {
|
shadowJar {
|
||||||
archiveFileName = jar.archiveFileName
|
archiveFileName = jar.archiveFileName
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
configurations = [project.configurations.packageLib]
|
configurations = [project.configurations.runtimeClasspath]
|
||||||
}
|
}
|
||||||
|
|
||||||
reobf {
|
reobf {
|
||||||
shadowJar {
|
shadowJar {
|
||||||
classpath = sourceSets.main.compileClasspath
|
classpath = project.configurations.compileClasspath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package me.night0721.lilase;
|
||||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||||
import me.night0721.lilase.events.PacketReceivedEvent;
|
import me.night0721.lilase.events.PacketReceivedEvent;
|
||||||
import me.night0721.lilase.utils.Utils;
|
import me.night0721.lilase.utils.Utils;
|
||||||
|
import me.night0721.lilase.utils.ah.AuctionHouse;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
|
@ -31,7 +32,7 @@ public class Main {
|
||||||
|
|
||||||
static int tickAmount;
|
static int tickAmount;
|
||||||
static Minecraft mc = Minecraft.getMinecraft();
|
static Minecraft mc = Minecraft.getMinecraft();
|
||||||
static KeyBinding[] keyBindings = new KeyBinding[2];
|
static KeyBinding[] keyBindings = new KeyBinding[3];
|
||||||
static ArrayList<Block> interactables = new ArrayList<>(Arrays.asList(Blocks.acacia_door, Blocks.anvil, Blocks.beacon, Blocks.bed, Blocks.birch_door, Blocks.brewing_stand, Blocks.command_block, Blocks.crafting_table, Blocks.chest, Blocks.dark_oak_door,
|
static ArrayList<Block> interactables = new ArrayList<>(Arrays.asList(Blocks.acacia_door, Blocks.anvil, Blocks.beacon, Blocks.bed, Blocks.birch_door, Blocks.brewing_stand, Blocks.command_block, Blocks.crafting_table, Blocks.chest, Blocks.dark_oak_door,
|
||||||
Blocks.daylight_detector, Blocks.daylight_detector_inverted, Blocks.dispenser, Blocks.dropper, Blocks.enchanting_table, Blocks.ender_chest, Blocks.furnace, Blocks.hopper, Blocks.jungle_door, Blocks.lever,
|
Blocks.daylight_detector, Blocks.daylight_detector_inverted, Blocks.dispenser, Blocks.dropper, Blocks.enchanting_table, Blocks.ender_chest, Blocks.furnace, Blocks.hopper, Blocks.jungle_door, Blocks.lever,
|
||||||
Blocks.noteblock, Blocks.powered_comparator, Blocks.unpowered_comparator, Blocks.powered_repeater, Blocks.unpowered_repeater, Blocks.standing_sign, Blocks.wall_sign, Blocks.trapdoor, Blocks.trapped_chest, Blocks.wooden_button,
|
Blocks.noteblock, Blocks.powered_comparator, Blocks.unpowered_comparator, Blocks.powered_repeater, Blocks.unpowered_repeater, Blocks.standing_sign, Blocks.wall_sign, Blocks.trapdoor, Blocks.trapped_chest, Blocks.wooden_button,
|
||||||
|
@ -43,7 +44,7 @@ public class Main {
|
||||||
|
|
||||||
keyBindings[0] = new KeyBinding("Ghost Block Bind", Keyboard.KEY_G, "Lilase");
|
keyBindings[0] = new KeyBinding("Ghost Block Bind", Keyboard.KEY_G, "Lilase");
|
||||||
keyBindings[1] = new KeyBinding("Hub", Keyboard.KEY_DIVIDE, "Lilase");
|
keyBindings[1] = new KeyBinding("Hub", Keyboard.KEY_DIVIDE, "Lilase");
|
||||||
|
keyBindings[2] = new KeyBinding("Auction House", Keyboard.KEY_END, "Lilase");
|
||||||
for (KeyBinding keyBinding : keyBindings) {
|
for (KeyBinding keyBinding : keyBindings) {
|
||||||
ClientRegistry.registerKeyBinding(keyBinding);
|
ClientRegistry.registerKeyBinding(keyBinding);
|
||||||
}
|
}
|
||||||
|
@ -64,6 +65,9 @@ public class Main {
|
||||||
if (keyBindings[1].isKeyDown()) {
|
if (keyBindings[1].isKeyDown()) {
|
||||||
mc.thePlayer.sendChatMessage("/hub");
|
mc.thePlayer.sendChatMessage("/hub");
|
||||||
}
|
}
|
||||||
|
if (keyBindings[2].isPressed()) {
|
||||||
|
new AuctionHouse();
|
||||||
|
}
|
||||||
if (tickAmount % 20 == 0) {
|
if (tickAmount % 20 == 0) {
|
||||||
Utils.checkForDungeon();
|
Utils.checkForDungeon();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
package me.night0721.lilase.utils;
|
|
||||||
|
|
||||||
public class AuctionHouse {
|
|
||||||
}
|
|
|
@ -3,6 +3,7 @@ package me.night0721.lilase.utils;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.network.play.server.S45PacketTitle;
|
import net.minecraft.network.play.server.S45PacketTitle;
|
||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -38,7 +39,9 @@ public class Utils {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inDungeon = false;
|
inDungeon = false;
|
||||||
}
|
}
|
||||||
|
public static void sendMessage(String message) {
|
||||||
|
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "" + EnumChatFormatting.BOLD + "Liliase" + EnumChatFormatting.RESET + EnumChatFormatting.DARK_GRAY + " » " + EnumChatFormatting.RESET + EnumChatFormatting.GREEN + EnumChatFormatting.BOLD + message));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
212
src/main/java/me/night0721/lilase/utils/ah/AuctionHouse.java
Normal file
212
src/main/java/me/night0721/lilase/utils/ah/AuctionHouse.java
Normal file
|
@ -0,0 +1,212 @@
|
||||||
|
package me.night0721.lilase.utils.ah;
|
||||||
|
|
||||||
|
import me.night0721.lilase.utils.Utils;
|
||||||
|
import okhttp3.*;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
||||||
|
public class AuctionHouse {
|
||||||
|
private final OkHttpClient client;
|
||||||
|
private final List<Item> items = new ArrayList<>();
|
||||||
|
private final List<String> posted = new ArrayList<>();
|
||||||
|
|
||||||
|
public AuctionHouse() {
|
||||||
|
client = new OkHttpClient();
|
||||||
|
items.add(new Item("Livid Dagger", ItemType.WEAPON, 8000000, ItemTier.LEGENDARY));
|
||||||
|
items.add(new Item("Aspect of the Void", ItemType.WEAPON, 8000000, ItemTier.EPIC));
|
||||||
|
items.add(new Item("Bal", ItemType.MISC, 10000000, ItemTier.EPIC));
|
||||||
|
Utils.sendMessage("AuctionHouse is now running");
|
||||||
|
// run getItem every 8 seconds=
|
||||||
|
new Thread(() -> {
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
getItem();
|
||||||
|
TimeUnit.SECONDS.sleep(8);
|
||||||
|
} catch (IOException | JSONException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private JSONObject getHypixelData(String player) throws IOException, JSONException {
|
||||||
|
String API_KEY = "d800be32-3abc-49bd-83a7-188573853d49";
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url("https://api.hypixel.net/player?key=" + API_KEY + "&uuid=" + player)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Response response = client.newCall(request).execute();
|
||||||
|
if (response.code() == 200 && response.body() != null)
|
||||||
|
return new JSONObject(response.body().string());
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getItem() throws IOException, JSONException {
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url("https://api.hypixel.net/skyblock/auctions")
|
||||||
|
.build();
|
||||||
|
Response response = client.newCall(request).execute();
|
||||||
|
if (response.code() != 200 || response.body() == null) return;
|
||||||
|
JSONObject data = new JSONObject(response.body().string());
|
||||||
|
JSONArray auctions = data.getJSONArray("auctions");
|
||||||
|
for (int i = 0; i < auctions.length(); i++) {
|
||||||
|
JSONObject auction = auctions.getJSONObject(i);
|
||||||
|
for (Item item : items) {
|
||||||
|
String lore = " ";
|
||||||
|
ItemType type = item.type;
|
||||||
|
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 (!auction.getString("item_name").toLowerCase().contains(item.query.toLowerCase())) break;
|
||||||
|
if (!auction.getString("item_lore").contains(lore)) break;
|
||||||
|
if (!auction.getString("tier").equals(item.tier.name())) break;
|
||||||
|
if (auction.getInt("starting_bid") > item.price) break;
|
||||||
|
if (!auction.getString("category").equals(type.lowercase)) break;
|
||||||
|
if (!auction.getBoolean("bin")) break;
|
||||||
|
if (!posted.contains(auction.getString("item_uuid"))) {
|
||||||
|
posted.add(auction.getString("item_uuid"));
|
||||||
|
NumberFormat format = NumberFormat.getInstance(Locale.US);
|
||||||
|
JSONObject profile = getHypixelData(auction.getString("auctioneer"));
|
||||||
|
Pattern pattern = Pattern.compile("§[0-9a-z]", Pattern.MULTILINE);
|
||||||
|
Matcher matcher = pattern.matcher(auction.getString("item_lore"));
|
||||||
|
String updated = matcher.replaceAll("");
|
||||||
|
JSONObject message = new JSONObject();
|
||||||
|
JSONObject embed = new JSONObject();
|
||||||
|
JSONObject author = new JSONObject();
|
||||||
|
JSONObject footer = new JSONObject();
|
||||||
|
JSONArray fields = new JSONArray();
|
||||||
|
JSONObject item_field = new JSONObject();
|
||||||
|
JSONObject price_field = new JSONObject();
|
||||||
|
JSONObject seller_field = new JSONObject();
|
||||||
|
JSONObject started_field = new JSONObject();
|
||||||
|
JSONObject ends_field = new JSONObject();
|
||||||
|
|
||||||
|
author.put("name", "Ń1ght#4004");
|
||||||
|
author.put("url", "https://github.com/night0721");
|
||||||
|
author.put("icon_url", "https://avatars.githubusercontent.com/u/77528305?v=4");
|
||||||
|
footer.put("text", "Made by Ń1ght#4004");
|
||||||
|
footer.put("icon_url", "https://avatars.githubusercontent.com/u/77528305?v=4");
|
||||||
|
item_field.put("name", "Item");
|
||||||
|
item_field.put("value", auction.getString("item_name"));
|
||||||
|
item_field.put("inline", true);
|
||||||
|
price_field.put("name", "Price");
|
||||||
|
price_field.put("value", format.format(auction.getInt("starting_bid")));
|
||||||
|
price_field.put("inline", true);
|
||||||
|
seller_field.put("name", "Seller");
|
||||||
|
assert profile != null;
|
||||||
|
seller_field.put("value", profile.getJSONObject("player").getString("displayname"));
|
||||||
|
seller_field.put("inline", true);
|
||||||
|
started_field.put("name", "Started for");
|
||||||
|
started_field.put("value", toDuration(System.currentTimeMillis() - auction.getLong("start")));
|
||||||
|
started_field.put("inline", true);
|
||||||
|
ends_field.put("name", "Ends in");
|
||||||
|
ends_field.put("value", getTimeSinceDate(auction.getLong("end") - System.currentTimeMillis()));
|
||||||
|
ends_field.put("inline", true);
|
||||||
|
fields.put(item_field);
|
||||||
|
fields.put(price_field);
|
||||||
|
fields.put(seller_field);
|
||||||
|
fields.put(started_field);
|
||||||
|
fields.put(ends_field);
|
||||||
|
embed.put("color", 0x003153);
|
||||||
|
embed.put("title", "Item Is On Low Price");
|
||||||
|
embed.put("url", "https://www.brandonfowler.me/skyblockah/?uuid=" + auction.getString("uuid"));
|
||||||
|
embed.put("timestamp", System.currentTimeMillis() / 1000);
|
||||||
|
embed.put("description", updated);
|
||||||
|
embed.put("author", author);
|
||||||
|
embed.put("footer", footer);
|
||||||
|
embed.put("fields", fields);
|
||||||
|
message.put("username", "Skyblock AH");
|
||||||
|
message.put("embeds", new JSONArray().put(embed));
|
||||||
|
message.put("content", auction.getString("item_name") + " is sale at " + format.format(auction.getInt("starting_bid")) + "!\n" + "/viewauction " + auction.getString("uuid"));
|
||||||
|
sendMessage(message);
|
||||||
|
Utils.sendMessage("Auction House:" + auction.getString("item_name") + " is sale for " + format.format(auction.getInt("starting_bid")) + "!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public 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));
|
||||||
|
public final List<String> timesString = Arrays.asList("year", "month", "day", "hour", "minute", "second");
|
||||||
|
|
||||||
|
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 static 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";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendMessage(JSONObject data) throws IOException, JSONException {
|
||||||
|
String DISCORD_WEBHOOK = "https://discord.com/api/webhooks/979502673093079071/p539WaqjEwiUWqCXLSBAcfDY-EhmF2RU9ZzjCKW_8jtFMuldJQwCdOFMPsT0U3VhfdBH";
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(DISCORD_WEBHOOK)
|
||||||
|
.post(RequestBody.create(data.toString(), MediaType.get("application/json")))
|
||||||
|
.addHeader("Content-Type", "application/json")
|
||||||
|
.build();
|
||||||
|
client.newCall(request).execute();
|
||||||
|
}
|
||||||
|
}
|
15
src/main/java/me/night0721/lilase/utils/ah/Item.java
Normal file
15
src/main/java/me/night0721/lilase/utils/ah/Item.java
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package me.night0721.lilase.utils.ah;
|
||||||
|
|
||||||
|
public class Item {
|
||||||
|
public String query;
|
||||||
|
public ItemType type;
|
||||||
|
public Integer price;
|
||||||
|
public ItemTier tier;
|
||||||
|
|
||||||
|
public Item(String query, ItemType type, Integer price, ItemTier tier) {
|
||||||
|
this.query = query;
|
||||||
|
this.type = type;
|
||||||
|
this.price = price;
|
||||||
|
this.tier = tier;
|
||||||
|
}
|
||||||
|
}
|
13
src/main/java/me/night0721/lilase/utils/ah/ItemTier.java
Normal file
13
src/main/java/me/night0721/lilase/utils/ah/ItemTier.java
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package me.night0721.lilase.utils.ah;
|
||||||
|
|
||||||
|
public enum ItemTier {
|
||||||
|
COMMON,
|
||||||
|
UNCOMMON,
|
||||||
|
RARE,
|
||||||
|
EPIC,
|
||||||
|
LEGENDARY,
|
||||||
|
MYTHIC,
|
||||||
|
DIVINE,
|
||||||
|
SPECIAL,
|
||||||
|
VERY_SPECIAL,
|
||||||
|
}
|
20
src/main/java/me/night0721/lilase/utils/ah/ItemType.java
Normal file
20
src/main/java/me/night0721/lilase/utils/ah/ItemType.java
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package me.night0721.lilase.utils.ah;
|
||||||
|
|
||||||
|
public enum ItemType {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue