diff --git a/build.gradle b/build.gradle index c382de2..619c001 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ minecraft { replace "@VERSION@": project.version - clientRunArgs += ["--tweakClass gg.essential.loader.stage0.EssentialSetupTweaker", "--mixin mixins.night0721.json"] + clientRunArgs += ["--tweakClass gg.essential.loader.stage0.EssentialSetupTweaker cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker", "--mixin mixins.night0721.json"] } configurations { @@ -51,6 +51,7 @@ repositories { maven { url "https://repo.sk1er.club/repository/maven-public" } maven { url "https://repo.sk1er.club/repository/maven-releases/" } maven { url "https://storehouse.okaeri.eu/repository/maven-public/" } + maven { url "https://repo.polyfrost.cc/releases" } } dependencies { @@ -59,12 +60,10 @@ dependencies { implementation("org.spongepowered:mixin:0.7.11-SNAPSHOT") annotationProcessor("org.spongepowered:mixin:0.7.11-SNAPSHOT") include("org.apache.commons:commons-collections4:4.4") + include("org.json:json:20220924") - implementation("org.projectlombok:lombok:1.18.24") - annotationProcessor("org.projectlombok:lombok:1.18.24") - - include("org.joml:joml:1.10.5") - include "org.json:json:20220924" + compileOnly('cc.polyfrost:oneconfig-1.8.9-forge:0.2.0-alpha+') + include("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta9") include(fileTree(dir: "libs", include: "*.jar")) implementation(fileTree(dir: "libs", include: "*.jar")) @@ -82,7 +81,8 @@ jar { "ForceLoadAsMod": true, "MixinConfigs": "mixins.night0721.json", "ModSide": "CLIENT", - "TweakClass": "gg.essential.loader.stage0.EssentialSetupTweaker", +// "TweakClass": "gg.essential.loader.stage0.EssentialSetupTweaker", + "TweakClass": "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker", "TweakOrder": "0") enabled = false } diff --git a/src/main/java/me/night0721/lilase/Main.java b/src/main/java/me/night0721/lilase/Main.java index a1c2832..4a0bb50 100644 --- a/src/main/java/me/night0721/lilase/Main.java +++ b/src/main/java/me/night0721/lilase/Main.java @@ -1,9 +1,13 @@ package me.night0721.lilase; +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.InitializationEvent; +import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; import com.mojang.realmsclient.gui.ChatFormatting; +import me.night0721.lilase.config.AHConfig; import me.night0721.lilase.events.PacketReceivedEvent; import me.night0721.lilase.features.ah.States; -import me.night0721.lilase.utils.AuctionHouse; +import me.night0721.lilase.features.ah.AuctionHouse; import me.night0721.lilase.utils.ConfigUtils; import me.night0721.lilase.utils.Utils; import net.minecraft.block.Block; @@ -23,6 +27,7 @@ import org.lwjgl.input.Keyboard; import java.util.ArrayList; import java.util.Arrays; +import java.util.Objects; @Mod(modid = Main.MODID, name = Main.MOD_NAME, version = Main.VERSION, acceptedMinecraftVersions = "[1.8.9]") public class Main { @@ -31,22 +36,28 @@ public class Main { public static final String VERSION = "1.0.0"; static int tickAmount; private AuctionHouse auctionHouse; + public static AHConfig config; static final Minecraft mc = Minecraft.getMinecraft(); - static final KeyBinding[] keyBindings = new KeyBinding[3]; + static final KeyBinding[] keyBindings = new KeyBinding[4]; static final ArrayList 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.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.stone_button, Blocks.oak_door, Blocks.skull)); @Mod.EventHandler public void init(FMLInitializationEvent event) { MinecraftForge.EVENT_BUS.register(this); + EventManager.INSTANCE.register(this); auctionHouse = new AuctionHouse(); keyBindings[0] = new KeyBinding("Ghost Block Bind", Keyboard.KEY_G, "Lilase"); keyBindings[1] = new KeyBinding("Hub", Keyboard.KEY_DIVIDE, "Lilase"); keyBindings[2] = new KeyBinding("Auction House", Keyboard.KEY_END, "Lilase"); + keyBindings[3] = new KeyBinding("Config", Keyboard.KEY_MULTIPLY, "Lilase"); for (KeyBinding keyBinding : keyBindings) { ClientRegistry.registerKeyBinding(keyBinding); } } - + @Subscribe + public void onConfigInit(InitializationEvent event) { + config = new AHConfig(); + } @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { if (mc.thePlayer == null || event.phase != TickEvent.Phase.START) return; @@ -66,8 +77,17 @@ public class Main { if (keyBindings[2].isPressed()) { auctionHouse.toggleAuction(); } + if (keyBindings[3].isPressed()) { + config.openGui(); + } + if (tickAmount % 20 == 0) { Utils.checkForDungeon(); + if (!Objects.equals(AHConfig.WEBHOOK, ConfigUtils.getString("main", "Webhook"))) { + ConfigUtils.writeStringConfig("main", "Webhook", AHConfig.WEBHOOK); + } else if (!Objects.equals(AHConfig.AUCTION_HOUSE_DELAY, ConfigUtils.getInt("main", "AuctionHouseDelay"))) { + ConfigUtils.writeIntConfig("main", "AuctionHouseDelay", Math.round(AHConfig.AUCTION_HOUSE_DELAY)); + } } AuctionHouse.switchStates(); } @@ -83,6 +103,11 @@ public class Main { System.out.println("Failed to buy item, not enough money. Closing the menu"); AuctionHouse.clickState = States.STOP; mc.playerController.windowClick(mc.thePlayer.openContainer.windowId, 49, 0, 0, mc.thePlayer); // Close the window as could not buy + } else if (message.contains("Your new API key is")) { + System.out.println("Detected new API key, saving it to config"); + Utils.sendMessage("Saved new API key to config"); + String apiKey = message.replace("Your new API key is ", ""); + ConfigUtils.writeStringConfig("main", "APIKey", apiKey); } } } diff --git a/src/main/java/me/night0721/lilase/config/AHConfig.java b/src/main/java/me/night0721/lilase/config/AHConfig.java new file mode 100644 index 0000000..9696306 --- /dev/null +++ b/src/main/java/me/night0721/lilase/config/AHConfig.java @@ -0,0 +1,25 @@ +package me.night0721.lilase.config; + +import cc.polyfrost.oneconfig.config.Config; +import cc.polyfrost.oneconfig.config.annotations.HUD; +import cc.polyfrost.oneconfig.config.annotations.Slider; +import cc.polyfrost.oneconfig.config.annotations.Text; +import cc.polyfrost.oneconfig.config.data.Mod; +import cc.polyfrost.oneconfig.config.data.ModType; +import me.night0721.lilase.gui.ConfigGUI; + +public class AHConfig extends Config { + public AHConfig() { + super(new Mod("Lilase", ModType.UTIL_QOL), "lilase.json"); + initialize(); + } + + @HUD(name = "Lilase") + public ConfigGUI hud = new ConfigGUI(); + + @Slider(name = "Time per fetch (seconds)", min = 5, max = 15, step = 1) + public static int AUCTION_HOUSE_DELAY = 5; + + @Text(name = "Discord Webhook", placeholder = "URL") + public static String WEBHOOK = ""; +} diff --git a/src/main/java/me/night0721/lilase/utils/AuctionHouse.java b/src/main/java/me/night0721/lilase/features/ah/AuctionHouse.java similarity index 96% rename from src/main/java/me/night0721/lilase/utils/AuctionHouse.java rename to src/main/java/me/night0721/lilase/features/ah/AuctionHouse.java index d5d5078..e3f5ec9 100644 --- a/src/main/java/me/night0721/lilase/utils/AuctionHouse.java +++ b/src/main/java/me/night0721/lilase/features/ah/AuctionHouse.java @@ -1,6 +1,9 @@ -package me.night0721.lilase.utils; +package me.night0721.lilase.features.ah; -import me.night0721.lilase.features.ah.States; +import me.night0721.lilase.config.AHConfig; +import me.night0721.lilase.utils.ConfigUtils; +import me.night0721.lilase.utils.DiscordWebhook; +import me.night0721.lilase.utils.Utils; import net.minecraft.client.Minecraft; import org.json.JSONArray; import org.json.JSONException; @@ -29,6 +32,7 @@ public class AuctionHouse { private Boolean open = false; private final DiscordWebhook webhook; private final List items = new ArrayList<>(); + private final List temp_items = new ArrayList<>(); private final List posted = new ArrayList<>(); public static States clickState = States.NONE; @@ -61,6 +65,7 @@ public class AuctionHouse { } private void getItem() throws IOException, JSONException { + if (items.size() == 0) return; URL url = new URL("https://api.hypixel.net/skyblock/auctions"); HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); connection.setRequestProperty("Content-Type", "application/json"); @@ -187,7 +192,8 @@ public class AuctionHouse { public void toggleAuction() { if (open) { Utils.sendMessage("Stopped Auction House"); - thread = null; + items.forEach(item -> temp_items.add(item)); + items.clear(); open = false; } else { Utils.sendMessage("Started Auction House"); diff --git a/src/main/java/me/night0721/lilase/gui/ConfigGUI.java b/src/main/java/me/night0721/lilase/gui/ConfigGUI.java new file mode 100644 index 0000000..2b59309 --- /dev/null +++ b/src/main/java/me/night0721/lilase/gui/ConfigGUI.java @@ -0,0 +1,22 @@ +package me.night0721.lilase.gui; + +import cc.polyfrost.oneconfig.hud.TextHud; +import me.night0721.lilase.utils.PlayerUtils; + +import java.util.List; + +public class ConfigGUI extends TextHud { + + public ConfigGUI() { + super(true, 0, 0); + } + @Override + protected void getLines(List lines, boolean example) { + if (PlayerUtils.mc.thePlayer == null) return; + lines.add("X: " + Math.round(PlayerUtils.mc.thePlayer.posX)); + lines.add("Y: " + Math.round(PlayerUtils.mc.thePlayer.posY)); + lines.add("Z: " + Math.round(PlayerUtils.mc.thePlayer.posZ)); + // get the time in real life and format it to xx:xx, eg 23:54 + + } +}