diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java
index b7cab9e7..979fb6de 100644
--- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java
+++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java
@@ -81,11 +81,18 @@ public class HytilsConfig extends Config {
private static boolean autoQueueInfo;
@Switch(
- name = "Auto Queue",
- description = "Automatically queues for another game once you win or die.",
+ name = "Auto Queue Game End",
+ description = "Automatically queues for another game once your game ends.",
category = "General", subcategory = "Automatic"
)
- public static boolean autoQueue;
+ public static boolean autoQueueGameEnd;
+
+ @Switch(
+ name = "Auto Queue Die",
+ description = "Automatically queues for another game once you die.",
+ category = "General", subcategory = "Automatic"
+ )
+ public static boolean autoQueueDie;
@Slider(
name = "Auto Queue Delay",
diff --git a/src/main/java/org/polyfrost/hytils/handlers/cache/PatternHandler.java b/src/main/java/org/polyfrost/hytils/handlers/cache/PatternHandler.java
index 74278a77..c27dde3f 100644
--- a/src/main/java/org/polyfrost/hytils/handlers/cache/PatternHandler.java
+++ b/src/main/java/org/polyfrost/hytils/handlers/cache/PatternHandler.java
@@ -41,7 +41,7 @@ public void initialize() {
processJson(cached);
return;
}
- final String gotten = NetworkUtils.getString("https://data.woverflow.cc/regex.json");
+ final String gotten = NetworkUtils.getString("https://data.polyfrost.org/regex.json");
if (gotten != null) {
processJson(JsonUtils.parseString(gotten).getAsJsonObject());
}
diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGG.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGG.java
index ccbbf297..34228e8c 100644
--- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGG.java
+++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGG.java
@@ -16,6 +16,7 @@
* along with this program. If not, see .
*/
+
package org.polyfrost.hytils.handlers.chat.modules.triggers;
import cc.polyfrost.oneconfig.events.event.WorldLoadEvent;
@@ -30,6 +31,7 @@
import org.polyfrost.hytils.handlers.cache.PatternHandler;
import org.polyfrost.hytils.handlers.chat.ChatReceiveModule;
+import java.util.Random;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
@@ -46,9 +48,12 @@ public void onMessageReceived(@NotNull ClientChatReceivedEvent event) {
if (!matchFound) {
matchFound = true;
- Multithreading.schedule(() -> UChat.say("/ac " + HytilsConfig.ggMessage), (long) (HytilsConfig.autoGGFirstPhraseDelay * 1000), TimeUnit.MILLISECONDS);
+ String ggMessage1 = "random".equals(HytilsConfig.ggMessage) ? getRandomGG() : HytilsConfig.ggMessage;
+ String ggMessage2 = "random".equals(HytilsConfig.ggMessage2) ? getRandomGG() : HytilsConfig.ggMessage2;
+
+ Multithreading.schedule(() -> UChat.say("/ac " + ggMessage1), (long) (HytilsConfig.autoGGFirstPhraseDelay * 1000), TimeUnit.MILLISECONDS);
if (HytilsConfig.autoGGSecondMessage) {
- Multithreading.schedule(() -> UChat.say("/ac " + HytilsConfig.ggMessage2), (long) ((HytilsConfig.autoGGSecondPhraseDelay + HytilsConfig.autoGGFirstPhraseDelay) * 1000), TimeUnit.MILLISECONDS);
+ Multithreading.schedule(() -> UChat.say("/ac " + ggMessage2), (long) ((HytilsConfig.autoGGSecondPhraseDelay + HytilsConfig.autoGGFirstPhraseDelay) * 1000), TimeUnit.MILLISECONDS);
}
// Schedule the reset of matchFound after the second message has been sent
Multithreading.schedule(() -> matchFound = false, (long) ((HytilsConfig.autoGGSecondPhraseDelay + HytilsConfig.autoGGFirstPhraseDelay) * 1000) + 5000, TimeUnit.MILLISECONDS);
@@ -65,7 +70,10 @@ private boolean hasGameEnded(String message) {
}
// TODO: UNTESTED!
- return getLanguage().casualGameEndRegex.matcher(message).matches();
+ if (HytilsConfig.casualAutoGG) {
+ return getLanguage().casualGameEndRegex.matcher(message).matches();
+ }
+ return false;
}
@Subscribe
@@ -82,5 +90,50 @@ public boolean isEnabled() {
public int getPriority() {
return 3;
}
-}
+ private static final Random random = new Random();
+
+ public static String getRandomGG() {
+ String base;
+
+ int roll = random.nextInt(258);
+
+ if (roll < 2) {
+ base = "gg";
+ } else if (roll < 130) {
+ base = "goodgame";
+ } else {
+ base = "good game";
+ }
+
+ char[] chars = base.toCharArray();
+ int capsCount = 0;
+
+ for (int i = 0; i < chars.length; i++) {
+ if (!Character.isLetter(chars[i])) continue; // Skip spaces
+
+ if (random.nextBoolean()) {
+ chars[i] = Character.toUpperCase(chars[i]);
+ capsCount++;
+ } else {
+ chars[i] = Character.toLowerCase(chars[i]);
+ }
+ }
+
+ if (capsCount % 2 != 0) {
+ for (int i = chars.length - 1; i >= 0; i--) {
+ if (Character.isLetter(chars[i])) {
+ // Flip case of the last letter
+ if (Character.isUpperCase(chars[i])) {
+ chars[i] = Character.toLowerCase(chars[i]);
+ } else {
+ chars[i] = Character.toUpperCase(chars[i]);
+ }
+ break;
+ }
+ }
+ }
+
+ return new String(chars);
+ }
+}
diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoQueue.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoQueue.java
index 425b2e14..b6753bd6 100644
--- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoQueue.java
+++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoQueue.java
@@ -16,64 +16,55 @@
* along with this program. If not, see .
*/
+
package org.polyfrost.hytils.handlers.chat.modules.triggers;
import cc.polyfrost.oneconfig.utils.Multithreading;
+import java.util.concurrent.TimeUnit;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import net.minecraftforge.client.event.ClientChatReceivedEvent;
+import org.jetbrains.annotations.NotNull;
import org.polyfrost.hytils.HytilsReborn;
import org.polyfrost.hytils.config.HytilsConfig;
import org.polyfrost.hytils.handlers.cache.LocrawGamesHandler;
+import org.polyfrost.hytils.handlers.cache.PatternHandler;
import org.polyfrost.hytils.handlers.chat.ChatReceiveModule;
-import net.minecraftforge.client.event.ClientChatReceivedEvent;
-import net.minecraftforge.event.world.WorldEvent;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import net.minecraftforge.fml.common.gameevent.InputEvent;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.concurrent.TimeUnit;
-import java.util.regex.Matcher;
-public class AutoQueue implements ChatReceiveModule {
+public class AutoQueue
+ implements ChatReceiveModule {
private String command = null;
private boolean sentCommand;
@Override
public void onMessageReceived(@NotNull ClientChatReceivedEvent event) {
- if (!HytilsConfig.autoQueue) {
+ if (!HytilsConfig.autoQueueGameEnd && !HytilsConfig.autoQueueDie) {
return;
}
+ String message = this.getStrippedMessage(event.message);
+ Matcher matcher = this.getLanguage().autoQueuePrefixGlobalRegex.matcher(message);
- final String message = getStrippedMessage(event.message);
- Matcher matcher = getLanguage().autoQueuePrefixGlobalRegex.matcher(message);
- if (matcher.matches() && getLocraw() != null) {
- String game = getLocraw().getGameMode();
- String value = LocrawGamesHandler.locrawGames.get(getLocraw().getRawGameType().toLowerCase() + "_" + game.toLowerCase());
+ if (((matcher.matches() && HytilsConfig.autoQueueDie) ||
+ (this.hasGameEnded(message) && HytilsConfig.autoQueueGameEnd)) &&
+ this.getLocraw() != null) {
+ String game = this.getLocraw().getGameMode();
+ String value = LocrawGamesHandler.locrawGames.get(this.getLocraw().getRawGameType().toLowerCase() + "_" + game.toLowerCase());
if (value != null) {
game = value;
}
this.command = "/play " + game.toLowerCase();
- }
- }
-
- @SubscribeEvent
- public void onKeyInput(InputEvent.KeyInputEvent event) {
- if (this.command != null) {
this.switchGame();
}
}
- @SubscribeEvent
- public void onMouseEvent(InputEvent.MouseInputEvent event) {
- if (this.command != null) {
- this.switchGame();
- }
- }
-
- @SubscribeEvent
- public void onWorldLoad(WorldEvent.Load event) {
- // stop the command from being spammed, to prevent chat from filling with "please do not spam commands"
- if (event.world.provider.getDimensionId() == 0 && this.sentCommand) {
- this.sentCommand = false;
+ private boolean hasGameEnded(String message) {
+ if (!PatternHandler.INSTANCE.gameEnd.isEmpty()) {
+ for (Pattern triggers : PatternHandler.INSTANCE.gameEnd) {
+ if (!triggers.matcher(message).matches()) continue;
+ return true;
+ }
}
+ return false;
}
private void switchGame() {
@@ -83,13 +74,15 @@ private void switchGame() {
this.sentCommand = true;
this.command = null;
}
-
+ Multithreading.schedule(() -> {
+ this.sentCommand = false;
+ }, 5L, TimeUnit.SECONDS);
}, HytilsConfig.autoQueueDelay, TimeUnit.SECONDS);
}
@Override
public boolean isEnabled() {
- return HytilsConfig.autoQueue;
+ return HytilsConfig.autoQueueGameEnd || HytilsConfig.autoQueueDie;
}
/**