anti afk
This commit is contained in:
parent
03809a260f
commit
8c2003931d
1 changed files with 20 additions and 5 deletions
|
@ -21,9 +21,10 @@ import static me.night0721.lilase.config.AHConfig.SEND_MESSAGE;
|
||||||
|
|
||||||
public class Cofl {
|
public class Cofl {
|
||||||
public final Queue queue = new Queue();
|
public final Queue queue = new Queue();
|
||||||
private @Getter @Setter boolean open = false;
|
private @Getter
|
||||||
public ArrayList<HashMap<String, String>> sold_items = new ArrayList<>();
|
@Setter boolean open = false;
|
||||||
public ArrayList<HashMap<String, String>> bought_items = new ArrayList<>();
|
public final ArrayList<HashMap<String, String>> sold_items = new ArrayList<>();
|
||||||
|
public final ArrayList<HashMap<String, String>> bought_items = new ArrayList<>();
|
||||||
|
|
||||||
public void onOpen() {
|
public void onOpen() {
|
||||||
System.setOut(new PrintStream(System.out) {
|
System.setOut(new PrintStream(System.out) {
|
||||||
|
@ -34,14 +35,16 @@ public class Cofl {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Thread antiafk;
|
||||||
|
|
||||||
private final Pattern pattern = Pattern.compile("type[\":]*flip");
|
private final Pattern pattern = Pattern.compile("type[\":]*flip");
|
||||||
|
|
||||||
public void handleMessage(String str) {
|
public void handleMessage(String str) {
|
||||||
try {
|
try {
|
||||||
if (!isOpen() || !str.startsWith("Received:")) return;
|
if (!isOpen() || !str.startsWith("Received:")) return;
|
||||||
if (pattern.matcher(str).find()) {
|
if (pattern.matcher(str).find()) {
|
||||||
Random random = new Random();
|
// Random random = new Random();
|
||||||
Lilase.mc.thePlayer.inventory.currentItem = random.nextInt(9);
|
// Lilase.mc.thePlayer.inventory.currentItem = random.nextInt(9);
|
||||||
String[] split = str.split("Received: ");
|
String[] split = str.split("Received: ");
|
||||||
JsonObject received = new JsonParser().parse(split[1]).getAsJsonObject();
|
JsonObject received = new JsonParser().parse(split[1]).getAsJsonObject();
|
||||||
if (!received.get("type").getAsString().equals("flip")) return;
|
if (!received.get("type").getAsString().equals("flip")) return;
|
||||||
|
@ -71,6 +74,7 @@ public class Cofl {
|
||||||
queue.setRunning(false);
|
queue.setRunning(false);
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
UngrabUtils.regrabMouse();
|
UngrabUtils.regrabMouse();
|
||||||
|
if (antiafk.isAlive()) antiafk.interrupt();
|
||||||
} else {
|
} else {
|
||||||
if (SEND_MESSAGE && Lilase.configHandler.getString("Webhook").equals("")) {
|
if (SEND_MESSAGE && Lilase.configHandler.getString("Webhook").equals("")) {
|
||||||
Utils.sendMessage("Sending message to Webhook is on but Webhook is missing, stopping");
|
Utils.sendMessage("Sending message to Webhook is on but Webhook is missing, stopping");
|
||||||
|
@ -88,6 +92,17 @@ public class Cofl {
|
||||||
queue.clear();
|
queue.clear();
|
||||||
queue.setRunning(false);
|
queue.setRunning(false);
|
||||||
UngrabUtils.ungrabMouse();
|
UngrabUtils.ungrabMouse();
|
||||||
|
antiafk = new Thread(() -> {
|
||||||
|
while (isOpen() && Lilase.mc.thePlayer != null) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(30 * 1000);
|
||||||
|
Random random = new Random();
|
||||||
|
Lilase.mc.thePlayer.inventory.currentItem = random.nextInt(9);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
antiafk.start();
|
||||||
} else {
|
} else {
|
||||||
Utils.sendMessage("Detected not in hub, please go to hub to start");
|
Utils.sendMessage("Detected not in hub, please go to hub to start");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue