check hub

This commit is contained in:
NK 2023-02-21 09:04:32 +00:00
parent 05dde26aa4
commit a61716710d
4 changed files with 29 additions and 24 deletions

View file

@ -27,7 +27,6 @@ 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 {
@ -83,11 +82,6 @@ public class Main {
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();
}

View file

@ -7,11 +7,14 @@ 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;
import me.night0721.lilase.utils.ConfigUtils;
public class AHConfig extends Config {
public AHConfig() {
super(new Mod("Lilase", ModType.UTIL_QOL), "lilase.json");
initialize();
addListener("AUCTION_HOUSE_DELAY", () -> ConfigUtils.writeIntConfig("main", "AuctionHouseDelay", Math.round(AHConfig.AUCTION_HOUSE_DELAY)));
addListener("WEBHOOK", () -> ConfigUtils.writeStringConfig("main", "Webhook", AHConfig.WEBHOOK));
}
@HUD(name = "Lilase")

View file

@ -196,18 +196,22 @@ public class AuctionHouse {
items.clear();
open = false;
} else {
Utils.sendMessage("Started Auction House");
thread = new Thread(() -> {
while (true) {
try {
getItem();
thread.sleep(TimeUnit.SECONDS.toMillis(ConfigUtils.getInt("main", "AuctionHouseDelay")));
} catch (IOException | JSONException | InterruptedException ignore) {
if (Utils.checkInHub()) {
Utils.sendMessage("Started Auction House");
thread = new Thread(() -> {
while (true) {
try {
getItem();
thread.sleep(TimeUnit.SECONDS.toMillis(ConfigUtils.getInt("main", "AuctionHouseDelay")));
} catch (IOException | JSONException | InterruptedException ignore) {
}
}
}
});
thread.start();
open = true;
});
thread.start();
open = true;
} else {
Utils.sendMessage("Detected not in hub, please go to hub to start");
}
}
}
public static void switchStates() {

View file

@ -10,7 +10,6 @@ import java.util.List;
public class Utils {
public static boolean inDungeon;
public static boolean inHub;
public static String translateAlternateColorCodes(String text) {
char[] b = text.toCharArray();
@ -43,16 +42,21 @@ public class Utils {
inDungeon = false;
}
public static void checkInHub() {
public static boolean checkInHub() {
List<String> scoreboard = ScoreboardUtils.getSidebarLines();
for (String s : scoreboard) {
String sCleaned = ScoreboardUtils.cleanSB(s);
if (sCleaned.contains("Forest") || sCleaned.contains("Village") || sCleaned.contains("Farm") || sCleaned.contains("Mountain") || sCleaned.contains("Wilderness") || sCleaned.contains("Community Center") || sCleaned.contains("Graveyard")) {
inHub = true;
return;
}
return sCleaned.contains("Forest") ||
sCleaned.contains("Village") ||
sCleaned.contains("Farm") ||
sCleaned.contains("Mountain") ||
sCleaned.contains("Wilderness") ||
sCleaned.contains("Community") ||
sCleaned.contains("Graveyard") ||
sCleaned.contains("Bazaar") ||
sCleaned.contains("Auction");
}
inDungeon = true;
return false;
}
public static void sendMessage(String message) {