Join to Skyblock if found lobby's messages

This commit is contained in:
Perchun Pak 2023-06-13 22:29:49 +02:00 committed by GitHub
parent 3f7ecbce43
commit be5df8f037
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 3 deletions

View file

@ -26,6 +26,7 @@ import static me.night0721.lilase.features.flipper.Flipper.*;
public class ChatReceivedEvent { public class ChatReceivedEvent {
private final Pattern AUCTION_SOLD_PATTERN = Pattern.compile("^(.*?) bought (.*?) for ([\\d,]+) coins CLICK$"); private final Pattern AUCTION_SOLD_PATTERN = Pattern.compile("^(.*?) bought (.*?) for ([\\d,]+) coins CLICK$");
private final LockWithTimeReset lockForJoiningSkyblock = new LockWithTimeReset();
@SubscribeEvent @SubscribeEvent
public void onChat(ClientChatReceivedEvent event) { public void onChat(ClientChatReceivedEvent event) {
@ -96,10 +97,12 @@ public class ChatReceivedEvent {
Flipper.state = FlipperState.NONE; Flipper.state = FlipperState.NONE;
Lilase.cofl.toggleAuction(); Lilase.cofl.toggleAuction();
} }
if (message.contains("You were spawned in Limbo")) { if (message.contains("You were spawned in Limbo") || message.contains("joined the lobby!")) {
try { try {
Utils.debugLog("Detected in Limbo, stopping everything for 5 minutes"); if (this.lockForJoiningSkyblock.isLocked) return
Utils.addTitle("You got sent to Limbo!"); this.lockForJoiningSkyblock.lock()
Utils.debugLog("Detected in Limbo or Lobby, stopping everything for 5 minutes");
Utils.addTitle("You got sent to Limbo or Lobby!");
Flipper.state = FlipperState.NONE; Flipper.state = FlipperState.NONE;
if (Lilase.cofl.isOpen()) Lilase.cofl.toggleAuction(); if (Lilase.cofl.isOpen()) Lilase.cofl.toggleAuction();
Thread.sleep(5000); Thread.sleep(5000);

View file

@ -0,0 +1,17 @@
package me.night0721.lilase.utils;
public class LockWithTimeReset {
public boolean isLocked = false;
public static void lock() {
this.isLocked = true;
new Thread(() -> {
try {
Thread.sleep(10000);
this.isLocked = false;
} catch (Exception ignored) {
}
}).start();
}
}