Skip to content

Commit

Permalink
Allows the user to set custom AutoGG phrases (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
SKDemon820 authored Jul 22, 2024
1 parent 661def0 commit 8f8371b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
20 changes: 6 additions & 14 deletions src/main/java/org/polyfrost/hytils/config/HytilsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,12 @@ public class HytilsConfig extends Config {
)
public static boolean antiGG;

@Dropdown(
@Text(
name = "Auto GG First Message",
description = "Choose what message is said on game completion.",
category = "Chat", subcategory = "Automatic",
options = {"gg", "GG", "gf", "Good Game", "Good Fight", "Good Round! :D"}
category = "Chat", subcategory = "Automatic"
)
public static int autoGGMessage = 0;
public static String autoGGMessage = "gg";

@Slider(
name = "Auto GG First Phrase Delay",
Expand All @@ -178,13 +177,12 @@ public class HytilsConfig extends Config {
)
public static float autoGGFirstPhraseDelay = 1;

@Dropdown(
@Text(
name = "Auto GG Second Message",
description = "Send a secondary message sent after the first GG message.",
category = "Chat", subcategory = "Automatic",
options = {"Have a good day!", "<3", "AutoGG By Hytils Reborn!", "gf", "Good Fight", "Good Round", ":D", "Well played!", "wp"}
category = "Chat", subcategory = "Automatic"
)
public static int autoGGMessage2 = 0;
public static String autoGGMessage2 = "Have a good day!";

@Slider(
name = "Auto GG Second Phrase Delay",
Expand Down Expand Up @@ -1282,15 +1280,9 @@ public HytilsConfig() {
if (AutoGG.INSTANCE.getAutoGGConfig().isCasualAutoGGEnabled()) {
casualAutoGG = true;
}
if (AutoGG.INSTANCE.getAutoGGConfig().getAutoGGPhrase() != 0) {
autoGGMessage = AutoGG.INSTANCE.getAutoGGConfig().getAutoGGPhrase();
}
if (AutoGG.INSTANCE.getAutoGGConfig().getAutoGGDelay() != 1) {
autoGGFirstPhraseDelay = AutoGG.INSTANCE.getAutoGGConfig().getAutoGGDelay();
}
if (AutoGG.INSTANCE.getAutoGGConfig().getAutoGGPhrase2() != 0) {
autoGGMessage2 = AutoGG.INSTANCE.getAutoGGConfig().getAutoGGPhrase2();
}
if (AutoGG.INSTANCE.getAutoGGConfig().getSecondaryDelay() != 1) {
autoGGSecondPhraseDelay = AutoGG.INSTANCE.getAutoGGConfig().getSecondaryDelay();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,13 @@
import java.util.regex.Pattern;

public class AutoGG implements ChatReceiveModule {
private static final String[] ggMessagesOne = {"gg", "GG", "gf", "Good Game", "Good Fight", "Good Round! :D"};
private static final String[] ggMessagesTwo = {"Have a good day!", "<3", "AutoGG By Hytils Reborn!", "gf", "Good Fight", "Good Round", ":D", "Well played!", "wp"};

private static String getGGMessageOne() {
return ggMessagesOne[HytilsConfig.autoGGMessage];
}
private static String getGGMessageTwo() {
return ggMessagesTwo[HytilsConfig.autoGGMessage2];
}

@Override
public void onMessageReceived(@NotNull ClientChatReceivedEvent event) {
String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText());
if (!hasGameEnded(message)) return;
Multithreading.schedule(() -> UChat.say("/ac " + getGGMessageOne()), (long) (HytilsConfig.autoGGFirstPhraseDelay * 1000), TimeUnit.MILLISECONDS);
Multithreading.schedule(() -> UChat.say("/ac " + HytilsConfig.autoGGMessage), (long) (HytilsConfig.autoGGFirstPhraseDelay * 1000), TimeUnit.MILLISECONDS);
if (HytilsConfig.autoGGSecondMessage)
Multithreading.schedule(() -> UChat.say("/ac " + getGGMessageTwo()), (long) ((HytilsConfig.autoGGSecondPhraseDelay + HytilsConfig.autoGGFirstPhraseDelay) * 1000), TimeUnit.MILLISECONDS);
Multithreading.schedule(() -> UChat.say("/ac " + HytilsConfig.autoGGMessage2), (long) ((HytilsConfig.autoGGSecondPhraseDelay + HytilsConfig.autoGGFirstPhraseDelay) * 1000), TimeUnit.MILLISECONDS);
}

private boolean hasGameEnded(String message) {
Expand Down

0 comments on commit 8f8371b

Please sign in to comment.