pretty much fixed most things with gui + config
This commit is contained in:
parent
32992a720e
commit
05dde26aa4
5 changed files with 91 additions and 13 deletions
14
build.gradle
14
build.gradle
|
@ -36,7 +36,7 @@ minecraft {
|
||||||
|
|
||||||
replace "@VERSION@": project.version
|
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 {
|
configurations {
|
||||||
|
@ -51,6 +51,7 @@ repositories {
|
||||||
maven { url "https://repo.sk1er.club/repository/maven-public" }
|
maven { url "https://repo.sk1er.club/repository/maven-public" }
|
||||||
maven { url "https://repo.sk1er.club/repository/maven-releases/" }
|
maven { url "https://repo.sk1er.club/repository/maven-releases/" }
|
||||||
maven { url "https://storehouse.okaeri.eu/repository/maven-public/" }
|
maven { url "https://storehouse.okaeri.eu/repository/maven-public/" }
|
||||||
|
maven { url "https://repo.polyfrost.cc/releases" }
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -59,12 +60,10 @@ dependencies {
|
||||||
implementation("org.spongepowered:mixin:0.7.11-SNAPSHOT")
|
implementation("org.spongepowered:mixin:0.7.11-SNAPSHOT")
|
||||||
annotationProcessor("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.apache.commons:commons-collections4:4.4")
|
||||||
|
include("org.json:json:20220924")
|
||||||
|
|
||||||
implementation("org.projectlombok:lombok:1.18.24")
|
compileOnly('cc.polyfrost:oneconfig-1.8.9-forge:0.2.0-alpha+')
|
||||||
annotationProcessor("org.projectlombok:lombok:1.18.24")
|
include("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta9")
|
||||||
|
|
||||||
include("org.joml:joml:1.10.5")
|
|
||||||
include "org.json:json:20220924"
|
|
||||||
|
|
||||||
include(fileTree(dir: "libs", include: "*.jar"))
|
include(fileTree(dir: "libs", include: "*.jar"))
|
||||||
implementation(fileTree(dir: "libs", include: "*.jar"))
|
implementation(fileTree(dir: "libs", include: "*.jar"))
|
||||||
|
@ -82,7 +81,8 @@ jar {
|
||||||
"ForceLoadAsMod": true,
|
"ForceLoadAsMod": true,
|
||||||
"MixinConfigs": "mixins.night0721.json",
|
"MixinConfigs": "mixins.night0721.json",
|
||||||
"ModSide": "CLIENT",
|
"ModSide": "CLIENT",
|
||||||
"TweakClass": "gg.essential.loader.stage0.EssentialSetupTweaker",
|
// "TweakClass": "gg.essential.loader.stage0.EssentialSetupTweaker",
|
||||||
|
"TweakClass": "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker",
|
||||||
"TweakOrder": "0")
|
"TweakOrder": "0")
|
||||||
enabled = false
|
enabled = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
package me.night0721.lilase;
|
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 com.mojang.realmsclient.gui.ChatFormatting;
|
||||||
|
import me.night0721.lilase.config.AHConfig;
|
||||||
import me.night0721.lilase.events.PacketReceivedEvent;
|
import me.night0721.lilase.events.PacketReceivedEvent;
|
||||||
import me.night0721.lilase.features.ah.States;
|
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.ConfigUtils;
|
||||||
import me.night0721.lilase.utils.Utils;
|
import me.night0721.lilase.utils.Utils;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -23,6 +27,7 @@ import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Mod(modid = Main.MODID, name = Main.MOD_NAME, version = Main.VERSION, acceptedMinecraftVersions = "[1.8.9]")
|
@Mod(modid = Main.MODID, name = Main.MOD_NAME, version = Main.VERSION, acceptedMinecraftVersions = "[1.8.9]")
|
||||||
public class Main {
|
public class Main {
|
||||||
|
@ -31,22 +36,28 @@ public class Main {
|
||||||
public static final String VERSION = "1.0.0";
|
public static final String VERSION = "1.0.0";
|
||||||
static int tickAmount;
|
static int tickAmount;
|
||||||
private AuctionHouse auctionHouse;
|
private AuctionHouse auctionHouse;
|
||||||
|
public static AHConfig config;
|
||||||
static final Minecraft mc = Minecraft.getMinecraft();
|
static final Minecraft mc = Minecraft.getMinecraft();
|
||||||
static final KeyBinding[] keyBindings = new KeyBinding[3];
|
static final KeyBinding[] keyBindings = new KeyBinding[4];
|
||||||
static final 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.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));
|
static final 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.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
|
@Mod.EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
EventManager.INSTANCE.register(this);
|
||||||
auctionHouse = new AuctionHouse();
|
auctionHouse = new AuctionHouse();
|
||||||
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");
|
keyBindings[2] = new KeyBinding("Auction House", Keyboard.KEY_END, "Lilase");
|
||||||
|
keyBindings[3] = new KeyBinding("Config", Keyboard.KEY_MULTIPLY, "Lilase");
|
||||||
for (KeyBinding keyBinding : keyBindings) {
|
for (KeyBinding keyBinding : keyBindings) {
|
||||||
ClientRegistry.registerKeyBinding(keyBinding);
|
ClientRegistry.registerKeyBinding(keyBinding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Subscribe
|
||||||
|
public void onConfigInit(InitializationEvent event) {
|
||||||
|
config = new AHConfig();
|
||||||
|
}
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onTick(TickEvent.ClientTickEvent event) {
|
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;
|
||||||
|
@ -66,8 +77,17 @@ public class Main {
|
||||||
if (keyBindings[2].isPressed()) {
|
if (keyBindings[2].isPressed()) {
|
||||||
auctionHouse.toggleAuction();
|
auctionHouse.toggleAuction();
|
||||||
}
|
}
|
||||||
|
if (keyBindings[3].isPressed()) {
|
||||||
|
config.openGui();
|
||||||
|
}
|
||||||
|
|
||||||
if (tickAmount % 20 == 0) {
|
if (tickAmount % 20 == 0) {
|
||||||
Utils.checkForDungeon();
|
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();
|
AuctionHouse.switchStates();
|
||||||
}
|
}
|
||||||
|
@ -83,6 +103,11 @@ public class Main {
|
||||||
System.out.println("Failed to buy item, not enough money. Closing the menu");
|
System.out.println("Failed to buy item, not enough money. Closing the menu");
|
||||||
AuctionHouse.clickState = States.STOP;
|
AuctionHouse.clickState = States.STOP;
|
||||||
mc.playerController.windowClick(mc.thePlayer.openContainer.windowId, 49, 0, 0, mc.thePlayer); // Close the window as could not buy
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
25
src/main/java/me/night0721/lilase/config/AHConfig.java
Normal file
25
src/main/java/me/night0721/lilase/config/AHConfig.java
Normal file
|
@ -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 = "";
|
||||||
|
}
|
|
@ -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 net.minecraft.client.Minecraft;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
@ -29,6 +32,7 @@ public class AuctionHouse {
|
||||||
private Boolean open = false;
|
private Boolean open = false;
|
||||||
private final DiscordWebhook webhook;
|
private final DiscordWebhook webhook;
|
||||||
private final List<Item> items = new ArrayList<>();
|
private final List<Item> items = new ArrayList<>();
|
||||||
|
private final List<Item> temp_items = new ArrayList<>();
|
||||||
private final List<String> posted = new ArrayList<>();
|
private final List<String> posted = new ArrayList<>();
|
||||||
public static States clickState = States.NONE;
|
public static States clickState = States.NONE;
|
||||||
|
|
||||||
|
@ -61,6 +65,7 @@ public class AuctionHouse {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getItem() throws IOException, JSONException {
|
private void getItem() throws IOException, JSONException {
|
||||||
|
if (items.size() == 0) return;
|
||||||
URL url = new URL("https://api.hypixel.net/skyblock/auctions");
|
URL url = new URL("https://api.hypixel.net/skyblock/auctions");
|
||||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||||
connection.setRequestProperty("Content-Type", "application/json");
|
connection.setRequestProperty("Content-Type", "application/json");
|
||||||
|
@ -187,7 +192,8 @@ public class AuctionHouse {
|
||||||
public void toggleAuction() {
|
public void toggleAuction() {
|
||||||
if (open) {
|
if (open) {
|
||||||
Utils.sendMessage("Stopped Auction House");
|
Utils.sendMessage("Stopped Auction House");
|
||||||
thread = null;
|
items.forEach(item -> temp_items.add(item));
|
||||||
|
items.clear();
|
||||||
open = false;
|
open = false;
|
||||||
} else {
|
} else {
|
||||||
Utils.sendMessage("Started Auction House");
|
Utils.sendMessage("Started Auction House");
|
22
src/main/java/me/night0721/lilase/gui/ConfigGUI.java
Normal file
22
src/main/java/me/night0721/lilase/gui/ConfigGUI.java
Normal file
|
@ -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<String> 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
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue