From e10b829cefcc3a903a6d81f8de200ee681dc5fc8 Mon Sep 17 00:00:00 2001 From: MicrocontrollersDev Date: Mon, 17 Jun 2024 23:06:35 -0700 Subject: [PATCH 01/11] initial untested implementation --- .../polyfrost/hytils/config/HytilsConfig.java | 74 +++++++++++++++++++ .../hytils/handlers/chat/ChatHandler.java | 3 + .../chat/modules/blockers/AntiGG.java | 48 ++++++++++++ .../chat/modules/blockers/KarmaRemover.java | 45 +++++++++++ .../chat/modules/triggers/AutoGG.java | 73 ++++++++++++++++++ .../chat/modules/triggers/AutoVictory.java | 2 +- .../handlers/language/LanguageData.java | 6 ++ 7 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGG.java create mode 100644 src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java create mode 100644 src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGG.java diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index fa13ae0..c3b6da8 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -128,6 +128,66 @@ public class HytilsConfig extends Config { // Chat + @Switch( + name = "Auto GG", + description = "Send a \"gg\" message at the end of a game.", + category = "Chat", subcategory = "Automatic" + ) + public static boolean autoGG; + + @Switch( + name = "Auto GG Second Message", + description = "Enable a secondary message to send after your first GG.", + category = "Chat", subcategory = "Automatic" + ) + public static boolean autoGGSecondMessage; + + @Switch( + name = "Casual Auto GG", + description = "Send a \"gg\" message at the end of minigames/events that don't give out Karma, such as SkyBlock and The Pit events.", + category = "Chat", subcategory = "Automatic" + ) + public static boolean casualAutoGG; + + @Switch( + name = "Anti GG", + description = "Remove GG messages from chat.", + category = "Chat", subcategory = "Automatic" + ) + public static boolean antiGG; + + @Dropdown( + 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"} + ) + public static int autoGGMessage = 0; + + @Slider( + name = "Auto GG First Phrase Delay", + description = "Delay after the game ends to say the first message in seconds.", + category = "Chat", subcategory = "Automatic", + min = 0, max = 5 + ) + public static int autoGGFirstPhraseDelay = 1; + + @Dropdown( + 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!", "gf", "Good Fight", "Good Round", ":D", "Well played!", "wp"} + ) + public static int autoGGMessage2 = 0; + + @Slider( + name = "Auto GG Second Phrase Delay", + description = "Delay after the game ends to say the second message in seconds.", + category = "Chat", subcategory = "Automatic", + min = 0, max = 5 + ) + public static int autoGGSecondPhraseDelay = 1; + @Switch( name = "Auto GL", description = "Send a message 5 seconds before a Hypixel game starts.", @@ -339,6 +399,13 @@ public class HytilsConfig extends Config { ) public static boolean preventShoutingOnCooldown = true; + @Switch( + name = "Hide Karma Messages", + description = "Remove Karma messages from the chat.", + category = "Chat", subcategory = "Toggles" + ) + public static boolean hideKarmaMessages; + @Switch( name = "Hide Locraw Messages", description = "Hide locraw messages in chat (e.g {\"server\": \"something\"}).", @@ -1065,6 +1132,13 @@ public HytilsConfig() { addDependency("gexpMode", "autoGetGEXP"); + addDependency("autoGGSecondMessage", "autoGG"); + addDependency("casualAutoGG", "autoGG"); + addDependency("autoGGMessage", "autoGG"); + addDependency("autoGGFirstPhraseDelay", "autoGG"); + addDependency("autoGGMessage2", "autoGG"); + addDependency("autoGGSecondPhraseDelay", "autoGG"); + addDependency("glPhrase", "autoGL"); addDependency("guildAutoWB", "autoWB"); diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java b/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java index 3b6b270..065212b 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java @@ -49,6 +49,7 @@ public ChatHandler() { // Blockers this.registerModule(new AdBlocker()); + this.registerModule(new AntiGG()); this.registerModule(new AntiGL()); this.registerModule(new AutoWB()); this.registerModule(new BedwarsAdvertisementsRemover()); @@ -66,6 +67,7 @@ public ChatHandler() { this.registerModule(new GuildMOTD()); this.registerModule(new HotPotatoRemover()); this.registerModule(new HypeLimitReminderRemover()); + this.registerModule(new KarmaRemover()); this.registerModule(new LobbyFishingAnnouncementRemover()); this.registerModule(new LobbyStatusRemover()); this.registerModule(new MvpEmotesRemover()); @@ -98,6 +100,7 @@ public ChatHandler() { this.registerModule(new AutoChatReportConfirm()); this.registerModule(new AutoChatSwapper()); this.registerModule(new AutoFriend()); + this.registerModule(new AutoGG()); this.registerModule(new AutoGL()); this.registerModule(new AutoPartyWarpConfirm()); this.registerModule(new AutoVictory()); diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGG.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGG.java new file mode 100644 index 0000000..fe995a8 --- /dev/null +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGG.java @@ -0,0 +1,48 @@ +/* + * Hytils Reborn - Hypixel focused Quality of Life mod. + * Copyright (C) 2020, 2021, 2022, 2023 Polyfrost, Sk1er LLC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.polyfrost.hytils.handlers.chat.modules.blockers; + +import cc.polyfrost.oneconfig.utils.hypixel.LocrawUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import org.jetbrains.annotations.NotNull; +import org.polyfrost.hytils.config.HytilsConfig; +import org.polyfrost.hytils.handlers.chat.ChatReceiveModule; + +public class AntiGG implements ChatReceiveModule { + @Override + public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { + String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText().toLowerCase()); + if ((message.startsWith("-") && message.endsWith("-")) || (message.startsWith("▬") && message.endsWith("▬")) || (message.startsWith("≡") && message.endsWith("≡")) || (!message.contains(": ")) || (message.contains(Minecraft.getMinecraft().getSession().getUsername().toLowerCase())) || (LocrawUtil.INSTANCE.getLocrawInfo() != null && !LocrawUtil.INSTANCE.isInGame())) return; + if (getLanguage().cancelGgMessagesRegex.matcher(message).matches()) { + event.setCanceled(true); + } + } + + @Override + public boolean isEnabled() { + return HytilsConfig.antiGG; + } + + @Override + public int getPriority() { + return -3; + } +} diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java new file mode 100644 index 0000000..5229d77 --- /dev/null +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java @@ -0,0 +1,45 @@ +/* + * Hytils Reborn - Hypixel focused Quality of Life mod. + * Copyright (C) 2020, 2021, 2022, 2023 Polyfrost, Sk1er LLC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.polyfrost.hytils.handlers.chat.modules.blockers; + +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import org.jetbrains.annotations.NotNull; +import org.polyfrost.hytils.config.HytilsConfig; +import org.polyfrost.hytils.handlers.chat.ChatReceiveModule; + +public class KarmaRemover implements ChatReceiveModule { + @Override + public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { + String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + if (getLanguage().cancelKarmaMessagesRegex.matcher(message).matches()) { + event.setCanceled(true); + } + } + + @Override + public boolean isEnabled() { + return HytilsConfig.hideKarmaMessages; + } + + @Override + public int getPriority() { + return -1; + } +} 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 new file mode 100644 index 0000000..f2ff72f --- /dev/null +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGG.java @@ -0,0 +1,73 @@ +/* + * Hytils Reborn - Hypixel focused Quality of Life mod. + * Copyright (C) 2020, 2021, 2022, 2023 Polyfrost, Sk1er LLC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.polyfrost.hytils.handlers.chat.modules.triggers; + +import cc.polyfrost.oneconfig.libs.universal.UChat; +import cc.polyfrost.oneconfig.utils.Multithreading; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import org.jetbrains.annotations.NotNull; +import org.polyfrost.hytils.config.HytilsConfig; +import org.polyfrost.hytils.handlers.cache.PatternHandler; +import org.polyfrost.hytils.handlers.chat.ChatReceiveModule; + +import java.util.concurrent.TimeUnit; +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!", "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()).trim(); + if (!hasGameEnded(message)) return; + Multithreading.schedule(() -> UChat.say("/ac " + getGGMessageOne()), HytilsConfig.autoGGFirstPhraseDelay, TimeUnit.SECONDS); + if (HytilsConfig.autoGGSecondMessage) + Multithreading.schedule(() -> UChat.say("/ac " + getGGMessageTwo()), HytilsConfig.autoGGSecondPhraseDelay, TimeUnit.SECONDS); + } + + private boolean hasGameEnded(String message) { + if (!PatternHandler.INSTANCE.gameEnd.isEmpty()) { + for (Pattern triggers : PatternHandler.INSTANCE.gameEnd) { + if (triggers.matcher(message).matches()) { + return true; + } + } + } + return false; + } + + @Override + public boolean isEnabled() { + return HytilsConfig.autoGG; + } + + @Override + public int getPriority() { + return 3; + } +} diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoVictory.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoVictory.java index 0d07a1f..3fba4b2 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoVictory.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoVictory.java @@ -49,7 +49,7 @@ public AutoVictory() { @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { String unformattedText = UTextComponent.Companion.stripFormatting(event.message.getUnformattedText()); - if (PatternHandler.INSTANCE.gameEnd.size() != 0) { + if (!PatternHandler.INSTANCE.gameEnd.isEmpty()) { if (!victoryDetected) { // prevent victories being detected twice Multithreading.runAsync(() -> { //run this async as getting from the API normally would freeze minecraft for (Pattern triggers : PatternHandler.INSTANCE.gameEnd) { diff --git a/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java b/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java index 1ef7d1c..079acca 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java +++ b/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java @@ -98,6 +98,8 @@ public class LanguageData { private String hypixelLevelUp = "You are now Hypixel Level (?\\d+)!"; + private String cancelGgMessages = "^(?:.* )?(?:\\\\[.+] )?\\\\w{1,16}(?: .+)?: (?:❤|gg|GG|gf|Good Game|Good Fight|Good Round! :D|Have a good day!|<3|AutoGG By Sk1er|AutoGG By Hytils|gf|Good Fight|Good Round|:D|Well Played!|wp)$"; + private String cancelKarmaMessages = "^\\+(?\\d)+ Karma!$"; private String cancelGlMessages = "(?!.+: )(gl|glhf|good luck|have a good game|autogl by sk1er)"; public String autoChatReportConfirm = "Please type /report confirm to log your report for staff review."; @@ -164,6 +166,8 @@ public class LanguageData { public Pattern hypixelLevelUpRegex; + public Pattern cancelGgMessagesRegex; + public Pattern cancelKarmaMessagesRegex; public Pattern cancelGlMessagesRegex; public Pattern gameBossbarAdvertisementRegex; @@ -227,6 +231,8 @@ public void initialize() { hypixelLevelUpRegex = Pattern.compile(hypixelLevelUp); + cancelGgMessagesRegex = Pattern.compile(cancelGgMessages); + cancelKarmaMessagesRegex = Pattern.compile(cancelKarmaMessages); cancelGlMessagesRegex = Pattern.compile(cancelGlMessages, Pattern.CASE_INSENSITIVE); gameBossbarAdvertisementRegex = Pattern.compile(gameBossbarAdvertisement); From 688b7f3c8f7ca45b7f98cdbd6dac13ee5ef74df7 Mon Sep 17 00:00:00 2001 From: MicrocontrollersDev Date: Tue, 18 Jun 2024 13:58:37 -0700 Subject: [PATCH 02/11] fix autogg, casual autogg, and antigg --- .../java/org/polyfrost/hytils/config/HytilsConfig.java | 4 ++-- .../hytils/handlers/chat/modules/blockers/AntiGG.java | 5 +---- .../hytils/handlers/chat/modules/triggers/AutoGG.java | 8 +++++--- .../polyfrost/hytils/handlers/language/LanguageData.java | 8 +++++++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index c3b6da8..4d3b11a 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -176,7 +176,7 @@ public class HytilsConfig extends Config { 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!", "gf", "Good Fight", "Good Round", ":D", "Well played!", "wp"} + options = {"Have a good day!", "<3", "AutoGG By Hytils Reborn!", "gf", "Good Fight", "Good Round", ":D", "Well played!", "wp"} ) public static int autoGGMessage2 = 0; @@ -400,7 +400,7 @@ public class HytilsConfig extends Config { public static boolean preventShoutingOnCooldown = true; @Switch( - name = "Hide Karma Messages", + name = "Remove Karma Messages", description = "Remove Karma messages from the chat.", category = "Chat", subcategory = "Toggles" ) diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGG.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGG.java index fe995a8..80af2b7 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGG.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGG.java @@ -18,8 +18,6 @@ package org.polyfrost.hytils.handlers.chat.modules.blockers; -import cc.polyfrost.oneconfig.utils.hypixel.LocrawUtil; -import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.jetbrains.annotations.NotNull; @@ -29,8 +27,7 @@ public class AntiGG implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText().toLowerCase()); - if ((message.startsWith("-") && message.endsWith("-")) || (message.startsWith("▬") && message.endsWith("▬")) || (message.startsWith("≡") && message.endsWith("≡")) || (!message.contains(": ")) || (message.contains(Minecraft.getMinecraft().getSession().getUsername().toLowerCase())) || (LocrawUtil.INSTANCE.getLocrawInfo() != null && !LocrawUtil.INSTANCE.isInGame())) return; + String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); if (getLanguage().cancelGgMessagesRegex.matcher(message).matches()) { event.setCanceled(true); } 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 f2ff72f..b314858 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 @@ -32,7 +32,7 @@ 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!", "gf", "Good Fight", "Good Round", ":D", "Well played!", "wp"}; + 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]; @@ -43,7 +43,7 @@ private static String getGGMessageTwo() { @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()).trim(); + String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); if (!hasGameEnded(message)) return; Multithreading.schedule(() -> UChat.say("/ac " + getGGMessageOne()), HytilsConfig.autoGGFirstPhraseDelay, TimeUnit.SECONDS); if (HytilsConfig.autoGGSecondMessage) @@ -58,7 +58,9 @@ private boolean hasGameEnded(String message) { } } } - return false; + + // TODO: UNTESTED! + return getLanguage().casualGameEndRegex.matcher(message).matches(); } @Override diff --git a/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java b/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java index 079acca..54a1c0a 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java +++ b/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java @@ -34,6 +34,8 @@ public class LanguageData { */ private String autoQueuePrefixGlobal = "^(?:You died! .+|YOU DIED! .+|You have been eliminated!|You won! .+|YOU WON! .+)$"; + private String casualGameEnd = "^(?:MINOR EVENT! .+ in .+ ended|DRAGON EGG OVER! Earned [\\d,]+XP [\\d,]g clicking the egg \\d+ times|GIANT CAKE! Event ended! Cake's gone!|PIT EVENT ENDED: .+ \\[INFO\\])$"; + private String autoFriendPattern = "Friend request from (?.+)\\[ACCEPT] - \\[DENY] - \\[IGNORE].*"; private String autoAfkReplyPattern = "^From (\\[.+?] )?(.+?): .+$"; @@ -98,7 +100,7 @@ public class LanguageData { private String hypixelLevelUp = "You are now Hypixel Level (?\\d+)!"; - private String cancelGgMessages = "^(?:.* )?(?:\\\\[.+] )?\\\\w{1,16}(?: .+)?: (?:❤|gg|GG|gf|Good Game|Good Fight|Good Round! :D|Have a good day!|<3|AutoGG By Sk1er|AutoGG By Hytils|gf|Good Fight|Good Round|:D|Well Played!|wp)$"; + private String cancelGgMessages = "^(?:.* )?(?:\\[.+] )?\\w{1,16}(?: .+)?: (?:❤|gg|GG|gf|Good Game|Good Fight|Good Round! :D|Have a good day!|<3|AutoGG By Sk1er!|AutoGG By Hytils Reborn!|gf|Good Fight|Good Round|:D|Well Played!|wp)$"; private String cancelKarmaMessages = "^\\+(?\\d)+ Karma!$"; private String cancelGlMessages = "(?!.+: )(gl|glhf|good luck|have a good game|autogl by sk1er)"; @@ -116,6 +118,8 @@ public class LanguageData { */ public Pattern autoQueuePrefixGlobalRegex; + public Pattern casualGameEndRegex; + public Pattern autoFriendPatternRegex; public Pattern autoAfkReplyPatternRegex; @@ -181,6 +185,8 @@ public void initialize() { autoQueuePrefixGlobalRegex = Pattern.compile(autoQueuePrefixGlobal); + casualGameEndRegex = Pattern.compile(casualGameEnd); + autoFriendPatternRegex = Pattern.compile(autoFriendPattern); autoAfkReplyPatternRegex = Pattern.compile(autoAfkReplyPattern); From c60466a90443d2e4a6d48d45bcfc57dee2f5dd89 Mon Sep 17 00:00:00 2001 From: MicrocontrollersDev Date: Tue, 18 Jun 2024 15:37:07 -0700 Subject: [PATCH 03/11] group new regexes better --- .../chat/modules/blockers/KarmaRemover.java | 2 +- .../hytils/handlers/language/LanguageData.java | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java index 5229d77..2119447 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java @@ -28,7 +28,7 @@ public class KarmaRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); - if (getLanguage().cancelKarmaMessagesRegex.matcher(message).matches()) { + if (getLanguage().chatCleanerKarmaMessagesRegex.matcher(message).matches()) { event.setCanceled(true); } } diff --git a/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java b/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java index 54a1c0a..c15501b 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java +++ b/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java @@ -34,11 +34,10 @@ public class LanguageData { */ private String autoQueuePrefixGlobal = "^(?:You died! .+|YOU DIED! .+|You have been eliminated!|You won! .+|YOU WON! .+)$"; - private String casualGameEnd = "^(?:MINOR EVENT! .+ in .+ ended|DRAGON EGG OVER! Earned [\\d,]+XP [\\d,]g clicking the egg \\d+ times|GIANT CAKE! Event ended! Cake's gone!|PIT EVENT ENDED: .+ \\[INFO\\])$"; - private String autoFriendPattern = "Friend request from (?.+)\\[ACCEPT] - \\[DENY] - \\[IGNORE].*"; private String autoAfkReplyPattern = "^From (\\[.+?] )?(.+?): .+$"; + private String chatCleanerKarmaMessages = "^\\+(?\\d)+ Karma!$"; private String chatCleanerJoin = "(?:sled into|slid into|joined|spooked into) the lobby"; private String chatCleanerTicketAnnouncer = "^(?(?!You )\\w{1,16} )has found an? .+$"; private String chatCleanerSoulWellFind = "^.+ has found .+ in the Soul Well!$"; @@ -100,8 +99,8 @@ public class LanguageData { private String hypixelLevelUp = "You are now Hypixel Level (?\\d+)!"; + private String casualGameEnd = "^(?:MINOR EVENT! .+ in .+ ended|DRAGON EGG OVER! Earned [\\d,]+XP [\\d,]g clicking the egg \\d+ times|GIANT CAKE! Event ended! Cake's gone!|PIT EVENT ENDED: .+ \\[INFO\\])$"; private String cancelGgMessages = "^(?:.* )?(?:\\[.+] )?\\w{1,16}(?: .+)?: (?:❤|gg|GG|gf|Good Game|Good Fight|Good Round! :D|Have a good day!|<3|AutoGG By Sk1er!|AutoGG By Hytils Reborn!|gf|Good Fight|Good Round|:D|Well Played!|wp)$"; - private String cancelKarmaMessages = "^\\+(?\\d)+ Karma!$"; private String cancelGlMessages = "(?!.+: )(gl|glhf|good luck|have a good game|autogl by sk1er)"; public String autoChatReportConfirm = "Please type /report confirm to log your report for staff review."; @@ -118,11 +117,10 @@ public class LanguageData { */ public Pattern autoQueuePrefixGlobalRegex; - public Pattern casualGameEndRegex; - public Pattern autoFriendPatternRegex; public Pattern autoAfkReplyPatternRegex; + public Pattern chatCleanerKarmaMessagesRegex; public Pattern chatCleanerJoinRegex; public Pattern chatCleanerTicketAnnouncerRegex; public Pattern chatCleanerSoulWellFindRegex; @@ -170,8 +168,8 @@ public class LanguageData { public Pattern hypixelLevelUpRegex; + public Pattern casualGameEndRegex; public Pattern cancelGgMessagesRegex; - public Pattern cancelKarmaMessagesRegex; public Pattern cancelGlMessagesRegex; public Pattern gameBossbarAdvertisementRegex; @@ -185,11 +183,10 @@ public void initialize() { autoQueuePrefixGlobalRegex = Pattern.compile(autoQueuePrefixGlobal); - casualGameEndRegex = Pattern.compile(casualGameEnd); - autoFriendPatternRegex = Pattern.compile(autoFriendPattern); autoAfkReplyPatternRegex = Pattern.compile(autoAfkReplyPattern); + chatCleanerKarmaMessagesRegex = Pattern.compile(chatCleanerKarmaMessages); chatCleanerJoinRegex = Pattern.compile(chatCleanerJoin); chatCleanerTicketAnnouncerRegex = Pattern.compile(chatCleanerTicketAnnouncer); chatCleanerSoulWellFindRegex = Pattern.compile(chatCleanerSoulWellFind); @@ -237,8 +234,8 @@ public void initialize() { hypixelLevelUpRegex = Pattern.compile(hypixelLevelUp); + casualGameEndRegex = Pattern.compile(casualGameEnd); cancelGgMessagesRegex = Pattern.compile(cancelGgMessages); - cancelKarmaMessagesRegex = Pattern.compile(cancelKarmaMessages); cancelGlMessagesRegex = Pattern.compile(cancelGlMessages, Pattern.CASE_INSENSITIVE); gameBossbarAdvertisementRegex = Pattern.compile(gameBossbarAdvertisement); From ad8184053ea0176b7731952faedcefc4ce2e46da Mon Sep 17 00:00:00 2001 From: MicrocontrollersDev <66657148+MicrocontrollersDev@users.noreply.github.com> Date: Wed, 19 Jun 2024 21:58:37 -0700 Subject: [PATCH 04/11] Cleanup waypoints (#85) --- .../game/miniwalls/MiddleBeaconMiniWalls.java | 2 +- .../handlers/render/ChestHighlighter.java | 96 +--------- .../polyfrost/hytils/util/WaypointUtil.java | 173 +++++++++++++----- 3 files changed, 129 insertions(+), 142 deletions(-) diff --git a/src/main/java/org/polyfrost/hytils/handlers/game/miniwalls/MiddleBeaconMiniWalls.java b/src/main/java/org/polyfrost/hytils/handlers/game/miniwalls/MiddleBeaconMiniWalls.java index e795c51..b8d4e63 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/game/miniwalls/MiddleBeaconMiniWalls.java +++ b/src/main/java/org/polyfrost/hytils/handlers/game/miniwalls/MiddleBeaconMiniWalls.java @@ -54,6 +54,6 @@ public boolean shouldMakeBeacon() { @SubscribeEvent public void onRenderWorldLast(RenderWorldLastEvent event) { if (!shouldMakeBeacon()) return; - WaypointUtil.renderBeaconBeam(block, HytilsConfig.miniWallsMiddleBeaconColor.getRGB(), 1.0f, event.partialTicks); + WaypointUtil.renderBeaconBeam(block, HytilsConfig.miniWallsMiddleBeaconColor, event.partialTicks); } } diff --git a/src/main/java/org/polyfrost/hytils/handlers/render/ChestHighlighter.java b/src/main/java/org/polyfrost/hytils/handlers/render/ChestHighlighter.java index 609a6aa..8a4ea0c 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/render/ChestHighlighter.java +++ b/src/main/java/org/polyfrost/hytils/handlers/render/ChestHighlighter.java @@ -18,27 +18,20 @@ package org.polyfrost.hytils.handlers.render; -import cc.polyfrost.oneconfig.config.core.OneColor; import cc.polyfrost.oneconfig.utils.hypixel.LocrawInfo; import cc.polyfrost.oneconfig.utils.hypixel.LocrawUtil; -import org.polyfrost.hytils.config.HytilsConfig; -import org.polyfrost.hytils.events.TitleEvent; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.opengl.GL11; +import org.polyfrost.hytils.config.HytilsConfig; +import org.polyfrost.hytils.events.TitleEvent; +import org.polyfrost.hytils.util.WaypointUtil; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -83,92 +76,11 @@ public void onWorldRendered(RenderWorldLastEvent event) { if (entity instanceof TileEntityChest) { BlockPos pos = entity.getPos(); if (!highlightedChestPositions.contains(pos)) continue; - drawBoundingBox(event, pos); + WaypointUtil.drawBoundingBox(event, pos, HytilsConfig.highlightChestsColor); } } } - private void drawBoundingBox(RenderWorldLastEvent event, BlockPos pos) { - Entity viewer = Minecraft.getMinecraft().getRenderViewEntity(); - double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks; - double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks; - double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks; - - double x = pos.getX() - viewerX; - double y = pos.getY() - viewerY; - double z = pos.getZ() - viewerZ; - GlStateManager.disableCull(); - drawFilledBoundingBox(new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1).expand(0.01, 0.01, 0.01), HytilsConfig.highlightChestsColor); - GlStateManager.enableCull(); - } - - /** - * Taken from NotEnoughUpdates under Creative Commons Attribution-NonCommercial 3.0 - * https://github.com/Moulberry/NotEnoughUpdates/blob/master/LICENSE - * - * @author Moulberry - */ - private void drawFilledBoundingBox(AxisAlignedBB aabb, OneColor c) { - GlStateManager.enableBlend(); - GlStateManager.disableLighting(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.disableTexture2D(); - - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - - GlStateManager.color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * (float) 0.8); - - //vertical - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); - worldrenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex(); - worldrenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex(); - worldrenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex(); - worldrenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex(); - tessellator.draw(); - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); - worldrenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex(); - worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex(); - worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex(); - worldrenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex(); - tessellator.draw(); - - - GlStateManager.color(c.getRed() / 255f * 0.8f, c.getGreen() / 255f * 0.8f, c.getBlue() / 255f * 0.8f, c.getAlpha() / 255f * (float) 0.8); - - //x - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); - worldrenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex(); - worldrenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex(); - worldrenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex(); - worldrenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex(); - tessellator.draw(); - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); - worldrenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex(); - worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex(); - worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex(); - worldrenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex(); - tessellator.draw(); - - - GlStateManager.color(c.getRed() / 255f * 0.9f, c.getGreen() / 255f * 0.9f, c.getBlue() / 255f * 0.9f, c.getAlpha() / 255f * (float) 0.8); - //z - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); - worldrenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex(); - worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex(); - worldrenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex(); - worldrenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex(); - tessellator.draw(); - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); - worldrenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex(); - worldrenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex(); - worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex(); - worldrenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex(); - tessellator.draw(); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - } - private boolean isNotSupported() { return LocrawUtil.INSTANCE.getLocrawInfo() == null || (LocrawUtil.INSTANCE.getLocrawInfo().getGameType() != LocrawInfo.GameType.SKYWARS && LocrawUtil.INSTANCE.getLocrawInfo().getGameType() != LocrawInfo.GameType.BLITZ_SG && (LocrawUtil.INSTANCE.getLocrawInfo().getGameType() != LocrawInfo.GameType.DUELS || !LocrawUtil.INSTANCE.getLocrawInfo().getGameMode().contains("_SW_"))); } diff --git a/src/main/java/org/polyfrost/hytils/util/WaypointUtil.java b/src/main/java/org/polyfrost/hytils/util/WaypointUtil.java index b8b1779..5f6e935 100644 --- a/src/main/java/org/polyfrost/hytils/util/WaypointUtil.java +++ b/src/main/java/org/polyfrost/hytils/util/WaypointUtil.java @@ -18,7 +18,7 @@ package org.polyfrost.hytils.util; - +import cc.polyfrost.oneconfig.config.core.OneColor; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.GlStateManager; @@ -27,21 +27,20 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.Entity; import net.minecraft.util.*; +import net.minecraftforge.client.event.RenderWorldLastEvent; import org.lwjgl.opengl.GL11; import org.lwjgl.util.vector.Vector3f; -import java.awt.*; - /** - * Taken and adapted from NotEnoughUpdates under Creative Commons Attribution-NonCommercial 3.0 - * https://github.com/Moulberry/NotEnoughUpdates/blob/master/LICENSE + * Taken and adapted from NotEnoughUpdates under GPL-3.0 + * https://github.com/NotEnoughUpdates/NotEnoughUpdates/blob/master/COPYING * @author Moulberry */ public class WaypointUtil { - private static final ResourceLocation beaconBeam = new ResourceLocation("textures/entity/beacon_beam.png"); + private static final OneColor nameColor = new OneColor(-1); - private static void renderBeaconBeam(double x, double y, double z, int rgb, float alphaMult, float partialTicks, boolean disableDepth) { + private static void renderBeaconBeam(double x, double y, double z, OneColor color, float partialTicks, boolean disableDepth) { int height = 300; int bottomOffset = 0; int topOffset = bottomOffset + height; @@ -66,9 +65,10 @@ private static void renderBeaconBeam(double x, double y, double z, int rgb, floa double time = Minecraft.getMinecraft().theWorld.getTotalWorldTime() + (double) partialTicks; double d1 = MathHelper.func_181162_h(-time * 0.2D - (double) MathHelper.floor_double(-time * 0.1D)); - float r = ((rgb >> 16) & 0xFF) / 255f; - float g = ((rgb >> 8) & 0xFF) / 255f; - float b = (rgb & 0xFF) / 255f; + float r = ((color.getRGB() >> 16) & 0xFF) / 255f; + float g = ((color.getRGB() >> 8) & 0xFF) / 255f; + float b = (color.getRGB() & 0xFF) / 255f; + float a = ((color.getRGB() >> 24) & 0xFF) / 255f; double d2 = time * 0.025D * -1.5D; double d4 = 0.5D + Math.cos(d2 + 2.356194490192345D) * 0.2D; double d5 = 0.5D + Math.sin(d2 + 2.356194490192345D) * 0.2D; @@ -81,22 +81,22 @@ private static void renderBeaconBeam(double x, double y, double z, int rgb, floa double d14 = -1.0D + d1; double d15 = (double) (height) * 2.5D + d14; worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(1.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex(); + worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(1.0D, d15).color(r, g, b, a).endVertex(); worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(0.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex(); - worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(1.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex(); + worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(0.0D, d15).color(r, g, b, a).endVertex(); + worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(1.0D, d15).color(r, g, b, a).endVertex(); worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(0.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex(); - worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(1.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex(); + worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(0.0D, d15).color(r, g, b, a).endVertex(); + worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(1.0D, d15).color(r, g, b, a).endVertex(); worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(0.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex(); - worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(1.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex(); + worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(0.0D, d15).color(r, g, b, a).endVertex(); + worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(1.0D, d15).color(r, g, b, a).endVertex(); worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(0.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex(); + worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(0.0D, d15).color(r, g, b, a).endVertex(); tessellator.draw(); GlStateManager.disableCull(); @@ -104,22 +104,22 @@ private static void renderBeaconBeam(double x, double y, double z, int rgb, floa double d13 = height + d12; worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex(); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F * a).endVertex(); worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F * a).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F * a).endVertex(); worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex(); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F * a).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F * a).endVertex(); worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex(); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F * a).endVertex(); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F * a).endVertex(); worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex(); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F * a).endVertex(); tessellator.draw(); GlStateManager.disableLighting(); @@ -129,28 +129,28 @@ private static void renderBeaconBeam(double x, double y, double z, int rgb, floa } } - private static void renderBoundingBox(double x, double y, double z, int rgb, float alphaMult, float partialTicks) { + private static void renderBoundingBox(double x, double y, double z, OneColor color, float alphaMult) { AxisAlignedBB bb = new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1); GlStateManager.disableDepth(); GlStateManager.disableCull(); GlStateManager.disableTexture2D(); - drawFilledBoundingBox(bb, 1f, new Color(rgb)); + drawFilledBoundingBox(bb, color, alphaMult); GlStateManager.enableTexture2D(); GlStateManager.enableCull(); GlStateManager.enableDepth(); } - public static void drawFilledBoundingBox(AxisAlignedBB boundingBox, float alpha, Color color) { + public static void drawFilledBoundingBox(AxisAlignedBB boundingBox, OneColor color, float alphaMult) { GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); GlStateManager.disableTexture2D(); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f * alpha); + GlStateManager.color(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, color.getAlpha() / 255F * alphaMult); //vertical worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); @@ -167,10 +167,10 @@ public static void drawFilledBoundingBox(AxisAlignedBB boundingBox, float alpha, tessellator.draw(); GlStateManager.color( - color.getRed() / 255f * 0.8f, - color.getGreen() / 255f * 0.8f, - color.getBlue() / 255f * 0.8f, - color.getAlpha() / 255f * alpha + color.getRed() / 255F * 0.8f, + color.getGreen() / 255F * 0.8f, + color.getBlue() / 255F * 0.8f, + color.getAlpha() / 255F * alphaMult ); //x @@ -188,10 +188,10 @@ public static void drawFilledBoundingBox(AxisAlignedBB boundingBox, float alpha, tessellator.draw(); GlStateManager.color( - color.getRed() / 255f * 0.9f, - color.getGreen() / 255f * 0.9f, - color.getBlue() / 255f * 0.9f, - color.getAlpha() / 255f * alpha + color.getRed() / 255F * 0.9F, + color.getGreen() / 255F * 0.9F, + color.getBlue() / 255F * 0.9F, + color.getAlpha() / 255F * alphaMult ); //z worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); @@ -208,7 +208,82 @@ public static void drawFilledBoundingBox(AxisAlignedBB boundingBox, float alpha, tessellator.draw(); } - public static void renderBeaconBeam(BlockPos block, int rgb, float alphaMult, float partialTicks) { + public static void drawBoundingBox(RenderWorldLastEvent event, BlockPos pos, OneColor color) { + Entity viewer = Minecraft.getMinecraft().getRenderViewEntity(); + double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks; + double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks; + double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks; + + double x = pos.getX() - viewerX; + double y = pos.getY() - viewerY; + double z = pos.getZ() - viewerZ; + GlStateManager.disableCull(); + drawFilledBoundingBox(new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1).expand(0.01, 0.01, 0.01), color); + GlStateManager.enableCull(); + } + + private static void drawFilledBoundingBox(AxisAlignedBB aabb, OneColor c) { + GlStateManager.enableBlend(); + GlStateManager.disableLighting(); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); + GlStateManager.disableTexture2D(); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + + GlStateManager.color(c.getRed() / 255F, c.getGreen() / 255F, c.getBlue() / 255F, c.getAlpha() / 255F * (float) 0.8); + + //vertical + worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); + worldrenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex(); + worldrenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex(); + worldrenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex(); + worldrenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex(); + tessellator.draw(); + worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); + worldrenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex(); + worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex(); + worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex(); + worldrenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex(); + tessellator.draw(); + + + GlStateManager.color(c.getRed() / 255F * 0.8f, c.getGreen() / 255F * 0.8f, c.getBlue() / 255F * 0.8f, c.getAlpha() / 255F * (float) 0.8); + + //x + worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); + worldrenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex(); + worldrenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex(); + worldrenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex(); + worldrenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex(); + tessellator.draw(); + worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); + worldrenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex(); + worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex(); + worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex(); + worldrenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex(); + tessellator.draw(); + + + GlStateManager.color(c.getRed() / 255F * 0.9F, c.getGreen() / 255F * 0.9F, c.getBlue() / 255F * 0.9F, c.getAlpha() / 255F * (float) 0.8); + //z + worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); + worldrenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex(); + worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex(); + worldrenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex(); + worldrenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex(); + tessellator.draw(); + worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); + worldrenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex(); + worldrenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex(); + worldrenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex(); + worldrenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void renderBeaconBeam(BlockPos block, OneColor color, float partialTicks) { double viewerX; double viewerY; double viewerZ; @@ -224,10 +299,10 @@ public static void renderBeaconBeam(BlockPos block, int rgb, float alphaMult, fl double distSq = x * x + y * y + z * z; - WaypointUtil.renderBeaconBeam(x, y, z, rgb, 1.0f, partialTicks, distSq > 10 * 10); + WaypointUtil.renderBeaconBeam(x, y, z, color, partialTicks, distSq > 10 * 10); } - public static void renderBeaconBeamOrBoundingBox(BlockPos block, int rgb, float alphaMult, float partialTicks) { + public static void renderBeaconBeamOrBoundingBox(BlockPos block, OneColor color, float alphaMult, float partialTicks) { double viewerX; double viewerY; double viewerZ; @@ -244,9 +319,9 @@ public static void renderBeaconBeamOrBoundingBox(BlockPos block, int rgb, float double distSq = x * x + y * y + z * z; if (distSq > 10 * 10) { - WaypointUtil.renderBeaconBeam(x, y, z, rgb, 1.0f, partialTicks, true); + WaypointUtil.renderBeaconBeam(x, y, z, color, partialTicks, true); } else { - WaypointUtil.renderBoundingBox(x, y, z, rgb, 1.0f, partialTicks); + WaypointUtil.renderBoundingBox(x, y, z, color, alphaMult); } } @@ -278,7 +353,7 @@ public static void renderWayPoint(String str, Vector3f loc, float partialTicks) GlStateManager.translate(x, y, z); GlStateManager.translate(0, viewer.getEyeHeight(), 0); - renderNametag(str); + renderNametag(str, nameColor); GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); @@ -286,14 +361,14 @@ public static void renderWayPoint(String str, Vector3f loc, float partialTicks) GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); - renderNametag(EnumChatFormatting.YELLOW.toString() + Math.round(dist) + "m"); + renderNametag(EnumChatFormatting.YELLOW.toString() + Math.round(dist) + "m", nameColor); GlStateManager.popMatrix(); GlStateManager.disableLighting(); } - public static void renderNametag(String str) { + public static void renderNametag(String str, OneColor textColor) { FontRenderer fontrenderer = Minecraft.getMinecraft().fontRendererObj; float f = 1.6F; float f1 = 0.016666668F * f; @@ -306,7 +381,7 @@ public static void renderNametag(String str) { GlStateManager.depthMask(false); GlStateManager.disableDepth(); GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); int i = 0; @@ -327,7 +402,7 @@ public static void renderNametag(String str) { GlStateManager.enableDepth(); GlStateManager.enableBlend(); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.color(textColor.getRed(), textColor.getGreen(), textColor.getBlue(), textColor.getAlpha()); GlStateManager.popMatrix(); } } From c3ba6477c607e6e00943964affcf7ef7e936cda6 Mon Sep 17 00:00:00 2001 From: ev chang Date: Thu, 20 Jun 2024 16:51:18 +0700 Subject: [PATCH 05/11] add migration for Sk1er's AutoGG --- .../java/club/sk1er/mods/autogg/AutoGG.java | 29 ++++++++ .../mods/autogg/config/AutoGGConfig.java | 69 +++++++++++++++++++ .../org/polyfrost/hytils/HytilsReborn.java | 1 + .../polyfrost/hytils/config/HytilsConfig.java | 52 ++++++++++++-- .../chat/modules/triggers/AutoGG.java | 3 +- 5 files changed, 148 insertions(+), 6 deletions(-) create mode 100644 src/dummy/java/club/sk1er/mods/autogg/AutoGG.java create mode 100644 src/dummy/java/club/sk1er/mods/autogg/config/AutoGGConfig.java diff --git a/src/dummy/java/club/sk1er/mods/autogg/AutoGG.java b/src/dummy/java/club/sk1er/mods/autogg/AutoGG.java new file mode 100644 index 0000000..e21f9c7 --- /dev/null +++ b/src/dummy/java/club/sk1er/mods/autogg/AutoGG.java @@ -0,0 +1,29 @@ +/* + * Hytils Reborn - Hypixel focused Quality of Life mod. + * Copyright (C) 2020, 2021, 2022, 2023 Polyfrost, Sk1er LLC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package club.sk1er.mods.autogg; + +import club.sk1er.mods.autogg.config.AutoGGConfig; + +public class AutoGG { + public static AutoGG INSTANCE = new AutoGG(); + + public AutoGGConfig getAutoGGConfig() { + return new AutoGGConfig(); + } +} diff --git a/src/dummy/java/club/sk1er/mods/autogg/config/AutoGGConfig.java b/src/dummy/java/club/sk1er/mods/autogg/config/AutoGGConfig.java new file mode 100644 index 0000000..3507d12 --- /dev/null +++ b/src/dummy/java/club/sk1er/mods/autogg/config/AutoGGConfig.java @@ -0,0 +1,69 @@ +/* + * Hytils Reborn - Hypixel focused Quality of Life mod. + * Copyright (C) 2020, 2021, 2022, 2023 Polyfrost, Sk1er LLC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package club.sk1er.mods.autogg.config; + +public class AutoGGConfig { + + // these arent the actual default values + private boolean autoGGEnabled = true; + private boolean casualAutoGGEnabled = true; + private boolean antiGGEnabled = true; + private boolean antiKarmaEnabled = true; + private int autoGGDelay = 5; + private int autoGGPhrase = 0; + private boolean secondaryEnabled = true; + private int autoGGPhrase2 = 0; + private int secondaryDelay = 5; + + public boolean isModEnabled() { + return autoGGEnabled; + } + + public boolean isCasualAutoGGEnabled() { + return casualAutoGGEnabled; + } + + public boolean isAntiGGEnabled() { + return antiGGEnabled; + } + + public boolean isAntiKarmaEnabled() { + return antiKarmaEnabled; + } + + public int getAutoGGDelay() { + return autoGGDelay; + } + + public int getAutoGGPhrase() { + return autoGGPhrase; + } + + public boolean isSecondaryEnabled() { + return secondaryEnabled; + } + + public int getAutoGGPhrase2() { + return autoGGPhrase2; + } + + public int getSecondaryDelay() { + return secondaryDelay; + } +} diff --git a/src/main/java/org/polyfrost/hytils/HytilsReborn.java b/src/main/java/org/polyfrost/hytils/HytilsReborn.java index 9f87b89..a0f98f1 100644 --- a/src/main/java/org/polyfrost/hytils/HytilsReborn.java +++ b/src/main/java/org/polyfrost/hytils/HytilsReborn.java @@ -97,6 +97,7 @@ public class HytilsReborn { public boolean isPatcher; public boolean isChatting; + public boolean isSk1erAutoGG; private boolean loadedCall; private RankType rank; diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index 387aec1..5ff47e6 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -26,6 +26,8 @@ import cc.polyfrost.oneconfig.config.data.ModType; import cc.polyfrost.oneconfig.config.data.PageLocation; import cc.polyfrost.oneconfig.config.migration.VigilanceMigrator; +import cc.polyfrost.oneconfig.utils.Notifications; +import club.sk1er.mods.autogg.AutoGG; import org.polyfrost.hytils.HytilsReborn; import org.polyfrost.hytils.handlers.chat.modules.modifiers.GameStartCompactor; import org.polyfrost.hytils.util.DarkColorUtils; @@ -35,11 +37,13 @@ import java.awt.Color; import java.io.File; +import java.lang.reflect.Field; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Arrays; +import java.util.function.Supplier; @SuppressWarnings("unused") public class HytilsConfig extends Config { @@ -133,7 +137,7 @@ public class HytilsConfig extends Config { description = "Send a \"gg\" message at the end of a game.", category = "Chat", subcategory = "Automatic" ) - public static boolean autoGG; + public static boolean autoGG = true; @Switch( name = "Auto GG Second Message", @@ -147,7 +151,7 @@ public class HytilsConfig extends Config { description = "Send a \"gg\" message at the end of minigames/events that don't give out Karma, such as SkyBlock and The Pit events.", category = "Chat", subcategory = "Automatic" ) - public static boolean casualAutoGG; + public static boolean casualAutoGG = true; @Switch( name = "Anti GG", @@ -1224,7 +1228,6 @@ public class HytilsConfig extends Config { public HytilsConfig() { super(new Mod("Hytils Reborn", ModType.HYPIXEL, "/assets/hytils/hypixel.png", new VigilanceMigrator(new File(HytilsReborn.INSTANCE.oldModDir, "hytilsreborn.toml").getAbsolutePath())), "hytilsreborn.json"); - initialize(); try { File modDir = HytilsReborn.INSTANCE.oldModDir; File oldModDir = new File(modDir.getParentFile(), "Hytilities Reborn"); @@ -1239,11 +1242,40 @@ public HytilsConfig() { e.printStackTrace(); } - if (configNumber != 2) { // Config version has not been set or is outdated + initialize(); + + if (configNumber != 3) { // Config version has not been set or is outdated if (configNumber == 1) { overlayAmount = 300; } - configNumber = 2; // set this to the current config version + if (configNumber <= 2) { + try { + Class clazz = Class.forName("club.sk1er.mods.autogg.config.AutoGGConfig"); + + HytilsReborn.INSTANCE.isSk1erAutoGG = true; + + autoGG = AutoGG.INSTANCE.getAutoGGConfig().isModEnabled(); + autoGGSecondMessage = AutoGG.INSTANCE.getAutoGGConfig().isSecondaryEnabled(); + casualAutoGG = AutoGG.INSTANCE.getAutoGGConfig().isCasualAutoGGEnabled(); + autoGGMessage = AutoGG.INSTANCE.getAutoGGConfig().getAutoGGPhrase(); + autoGGFirstPhraseDelay = AutoGG.INSTANCE.getAutoGGConfig().getAutoGGDelay(); + autoGGMessage2 = AutoGG.INSTANCE.getAutoGGConfig().getAutoGGPhrase2(); + autoGGSecondPhraseDelay = AutoGG.INSTANCE.getAutoGGConfig().getSecondaryDelay(); + + try { + Field sk1erEnabled = clazz.getDeclaredField("autoGGEnabled"); + sk1erEnabled.setAccessible(true); + sk1erEnabled.set(AutoGG.INSTANCE.getAutoGGConfig(), false); + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + + Notifications.INSTANCE.send("Hytils Reborn", "AutoGG settings have been migrated to Hytils Reborn. You can now configure them in the Hytils Reborn settings.", 5); + } catch (ClassNotFoundException ignored) { + + } + } + configNumber = 3; // set this to the current config version save(); } @@ -1258,6 +1290,16 @@ public HytilsConfig() { addDependency("autoGGMessage2", "autoGG"); addDependency("autoGGSecondPhraseDelay", "autoGG"); + Supplier autoGGEnabled = () -> HytilsReborn.INSTANCE.isSk1erAutoGG && AutoGG.INSTANCE.getAutoGGConfig().isModEnabled(); + + addDependency("autoGG", "Sk1er's AutoGG Enabled", autoGGEnabled); + addDependency("autoGGSecondMessage", "Sk1er's AutoGG Enabled", autoGGEnabled); + addDependency("casualAutoGG", "Sk1er's AutoGG Enabled", autoGGEnabled); + addDependency("autoGGMessage", "Sk1er's AutoGG Enabled", autoGGEnabled); + addDependency("autoGGFirstPhraseDelay", "Sk1er's AutoGG Enabled", autoGGEnabled); + addDependency("autoGGMessage2", "Sk1er's AutoGG Enabled", autoGGEnabled); + addDependency("autoGGSecondPhraseDelay", "Sk1er's AutoGG Enabled", autoGGEnabled); + addDependency("glPhrase", "autoGL"); addDependency("guildAutoWB", "autoWB"); 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 b314858..30e8021 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 @@ -23,6 +23,7 @@ import net.minecraft.util.EnumChatFormatting; 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.PatternHandler; import org.polyfrost.hytils.handlers.chat.ChatReceiveModule; @@ -65,7 +66,7 @@ private boolean hasGameEnded(String message) { @Override public boolean isEnabled() { - return HytilsConfig.autoGG; + return HytilsConfig.autoGG && (!HytilsReborn.INSTANCE.isSk1erAutoGG || club.sk1er.mods.autogg.AutoGG.INSTANCE.getAutoGGConfig().isModEnabled()); // If Sk1er's AutoGG is enabled, we don't want to interfere with it. } @Override From caf08e83c66653436b4db8671a133cc620811f53 Mon Sep 17 00:00:00 2001 From: ev chang Date: Thu, 20 Jun 2024 23:13:14 +0700 Subject: [PATCH 06/11] Add lobbysounds migration + fix autogg migration --- .../club/sk1er/lobbysounds/config/Sounds.java | 58 +++++++ .../mods/autogg/config/AutoGGConfig.java | 17 ++- .../polyfrost/hytils/config/HytilsConfig.java | 141 ++++++++++++++++-- 3 files changed, 198 insertions(+), 18 deletions(-) create mode 100644 src/dummy/java/club/sk1er/lobbysounds/config/Sounds.java diff --git a/src/dummy/java/club/sk1er/lobbysounds/config/Sounds.java b/src/dummy/java/club/sk1er/lobbysounds/config/Sounds.java new file mode 100644 index 0000000..befb866 --- /dev/null +++ b/src/dummy/java/club/sk1er/lobbysounds/config/Sounds.java @@ -0,0 +1,58 @@ +/* + * Hytils Reborn - Hypixel focused Quality of Life mod. + * Copyright (C) 2020, 2021, 2022, 2023 Polyfrost, Sk1er LLC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package club.sk1er.lobbysounds.config; + +public class Sounds { + + public static boolean DISABLE_SLIME_SOUNDS; + + public static boolean DISABLE_DRAGON_SOUNDS; + + public static boolean DISABLE_WITHER_SOUNDS; + + public static boolean DISABLE_ITEM_PICKUP_SOUNDS; + + public static boolean DISABLE_EXPERIENCE_SOUNDS; + + public static boolean DISABLE_TNT_PRIME_SOUNDS; + + public static boolean DISABLE_EXPLOSION_SOUNDS; + + public static boolean DISABLE_DELIVERY_MAN_SOUNDS; + + public static boolean DISABLE_NOTE_SOUNDS; + + public static boolean DISABLE_FIREWORKS_SOUNDS; + + public static boolean DISABLE_LEVELUP_SOUNDS; + + public static boolean DISABLE_STEP_SOUNDS; + + public static boolean DISABLE_ARROW_SOUNDS; + + public static boolean DISABLE_BAT_SOUNDS; + + public static boolean DISABLE_FIRE_SOUNDS; + + public static boolean DISABLE_ENDERMEN_SOUNDS; + + public void markDirty() {} + + public void writeData() {} +} diff --git a/src/dummy/java/club/sk1er/mods/autogg/config/AutoGGConfig.java b/src/dummy/java/club/sk1er/mods/autogg/config/AutoGGConfig.java index 3507d12..da715fa 100644 --- a/src/dummy/java/club/sk1er/mods/autogg/config/AutoGGConfig.java +++ b/src/dummy/java/club/sk1er/mods/autogg/config/AutoGGConfig.java @@ -20,16 +20,15 @@ public class AutoGGConfig { - // these arent the actual default values private boolean autoGGEnabled = true; - private boolean casualAutoGGEnabled = true; - private boolean antiGGEnabled = true; - private boolean antiKarmaEnabled = true; - private int autoGGDelay = 5; + private boolean casualAutoGGEnabled; + private boolean antiGGEnabled; + private boolean antiKarmaEnabled; + private int autoGGDelay = 1; private int autoGGPhrase = 0; - private boolean secondaryEnabled = true; + private boolean secondaryEnabled; private int autoGGPhrase2 = 0; - private int secondaryDelay = 5; + private int secondaryDelay = 1; public boolean isModEnabled() { return autoGGEnabled; @@ -66,4 +65,8 @@ public int getAutoGGPhrase2() { public int getSecondaryDelay() { return secondaryDelay; } + + public void markDirty() {} + + public void writeData() {} } diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index 5ff47e6..e2333bd 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -19,6 +19,7 @@ package org.polyfrost.hytils.config; import cc.polyfrost.oneconfig.config.Config; +import cc.polyfrost.oneconfig.config.annotations.Checkbox; import cc.polyfrost.oneconfig.config.annotations.*; import cc.polyfrost.oneconfig.config.core.OneColor; import cc.polyfrost.oneconfig.config.data.InfoType; @@ -27,13 +28,14 @@ import cc.polyfrost.oneconfig.config.data.PageLocation; import cc.polyfrost.oneconfig.config.migration.VigilanceMigrator; import cc.polyfrost.oneconfig.utils.Notifications; +import club.sk1er.lobbysounds.config.Sounds; import club.sk1er.mods.autogg.AutoGG; -import org.polyfrost.hytils.HytilsReborn; -import org.polyfrost.hytils.handlers.chat.modules.modifiers.GameStartCompactor; -import org.polyfrost.hytils.util.DarkColorUtils; import com.google.common.collect.Lists; import net.minecraft.client.Minecraft; import org.apache.commons.io.FileUtils; +import org.polyfrost.hytils.HytilsReborn; +import org.polyfrost.hytils.handlers.chat.modules.modifiers.GameStartCompactor; +import org.polyfrost.hytils.util.DarkColorUtils; import java.awt.Color; import java.io.File; @@ -1254,23 +1256,140 @@ public HytilsConfig() { HytilsReborn.INSTANCE.isSk1erAutoGG = true; - autoGG = AutoGG.INSTANCE.getAutoGGConfig().isModEnabled(); - autoGGSecondMessage = AutoGG.INSTANCE.getAutoGGConfig().isSecondaryEnabled(); - casualAutoGG = AutoGG.INSTANCE.getAutoGGConfig().isCasualAutoGGEnabled(); - autoGGMessage = AutoGG.INSTANCE.getAutoGGConfig().getAutoGGPhrase(); - autoGGFirstPhraseDelay = AutoGG.INSTANCE.getAutoGGConfig().getAutoGGDelay(); - autoGGMessage2 = AutoGG.INSTANCE.getAutoGGConfig().getAutoGGPhrase2(); - autoGGSecondPhraseDelay = AutoGG.INSTANCE.getAutoGGConfig().getSecondaryDelay(); + if (AutoGG.INSTANCE.getAutoGGConfig().isModEnabled()) { + autoGG = true; + } + if (AutoGG.INSTANCE.getAutoGGConfig().isSecondaryEnabled()) { + autoGGSecondMessage = true; + } + 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(); + } + if (AutoGG.INSTANCE.getAutoGGConfig().isAntiGGEnabled()) { + antiGG = true; + } + if (AutoGG.INSTANCE.getAutoGGConfig().isAntiKarmaEnabled()) { + hideKarmaMessages = true; + } try { Field sk1erEnabled = clazz.getDeclaredField("autoGGEnabled"); sk1erEnabled.setAccessible(true); sk1erEnabled.set(AutoGG.INSTANCE.getAutoGGConfig(), false); + + AutoGG.INSTANCE.getAutoGGConfig().markDirty(); + AutoGG.INSTANCE.getAutoGGConfig().writeData(); } catch (NoSuchFieldException | IllegalAccessException e) { e.printStackTrace(); } - Notifications.INSTANCE.send("Hytils Reborn", "AutoGG settings have been migrated to Hytils Reborn. You can now configure them in the Hytils Reborn settings.", 5); + Notifications.INSTANCE.send("Hytils Reborn", "AutoGG settings have been migrated to Hytils Reborn. You can now configure them in the Hytils Reborn settings, and remove Sk1erLLC's AutoGG.", 5); + } catch (ClassNotFoundException ignored) { + + } + try { + Class.forName("club.sk1er.lobbysounds.config.Sounds"); + boolean modified = false; + if (Sounds.DISABLE_SLIME_SOUNDS) { + lobbyDisableSlimeSounds = true; + modified = true; + } + if (Sounds.DISABLE_DRAGON_SOUNDS) { + lobbyDisableDragonSounds = true; + modified = true; + } + if (Sounds.DISABLE_WITHER_SOUNDS) { + lobbyDisableWitherSounds = true; + modified = true; + } + if (Sounds.DISABLE_ITEM_PICKUP_SOUNDS) { + lobbyDisableItemPickupSounds = true; + modified = true; + } + if (Sounds.DISABLE_EXPERIENCE_SOUNDS) { + lobbyDisableExperienceOrbSounds = true; + modified = true; + } + if (Sounds.DISABLE_TNT_PRIME_SOUNDS) { + lobbyDisablePrimedTntSounds = true; + modified = true; + } + if (Sounds.DISABLE_EXPLOSION_SOUNDS) { + lobbyDisableExplosionSounds = true; + modified = true; + } + if (Sounds.DISABLE_DELIVERY_MAN_SOUNDS) { + lobbyDisableDeliveryManSounds = true; + modified = true; + } + if (Sounds.DISABLE_NOTE_SOUNDS) { + lobbyDisableNoteBlockSounds = true; + modified = true; + } + if (Sounds.DISABLE_FIREWORKS_SOUNDS) { + lobbyDisableFireworkSounds = true; + modified = true; + } + if (Sounds.DISABLE_LEVELUP_SOUNDS) { + lobbyDisableLevelupSounds = true; + modified = true; + } + if (Sounds.DISABLE_ARROW_SOUNDS) { + lobbyDisableArrowSounds = true; + modified = true; + } + if (Sounds.DISABLE_BAT_SOUNDS) { + lobbyDisableBatSounds = true; + modified = true; + } + if (Sounds.DISABLE_FIRE_SOUNDS) { + lobbyDisableFireSounds = true; + modified = true; + } + if (Sounds.DISABLE_ENDERMEN_SOUNDS) { + lobbyDisableEndermanSounds = true; + modified = true; + } + if (Sounds.DISABLE_STEP_SOUNDS) { + lobbyDisableSteppingSounds = true; + modified = true; + } + + if (Sounds.DISABLE_SLIME_SOUNDS && + Sounds.DISABLE_DRAGON_SOUNDS && + Sounds.DISABLE_WITHER_SOUNDS && + Sounds.DISABLE_ITEM_PICKUP_SOUNDS && + Sounds.DISABLE_EXPERIENCE_SOUNDS && + Sounds.DISABLE_TNT_PRIME_SOUNDS && + Sounds.DISABLE_EXPLOSION_SOUNDS && + Sounds.DISABLE_DELIVERY_MAN_SOUNDS && + Sounds.DISABLE_NOTE_SOUNDS && + Sounds.DISABLE_FIREWORKS_SOUNDS && + Sounds.DISABLE_LEVELUP_SOUNDS && + Sounds.DISABLE_ARROW_SOUNDS && + Sounds.DISABLE_BAT_SOUNDS && + Sounds.DISABLE_FIRE_SOUNDS && + Sounds.DISABLE_ENDERMEN_SOUNDS && + Sounds.DISABLE_STEP_SOUNDS) { + silentLobby = true; + lobbyDisableDoorSounds = true; + } + + if (modified) { + Notifications.INSTANCE.send("Hytils Reborn", "Lobby Sounds settings have been migrated to Hytils Reborn. You can now configure them in the Hytils Reborn settings, and remove Sk1erLLC's Lobby Sounds.", 5); + } } catch (ClassNotFoundException ignored) { } From 97cc8c9dddcb610cc536cd8c485b83314cba9381 Mon Sep 17 00:00:00 2001 From: ev chang Date: Thu, 20 Jun 2024 23:39:27 +0700 Subject: [PATCH 07/11] Fix AutoGG dependency condition --- src/main/java/org/polyfrost/hytils/config/HytilsConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index e2333bd..bc4337a 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -1409,7 +1409,7 @@ public HytilsConfig() { addDependency("autoGGMessage2", "autoGG"); addDependency("autoGGSecondPhraseDelay", "autoGG"); - Supplier autoGGEnabled = () -> HytilsReborn.INSTANCE.isSk1erAutoGG && AutoGG.INSTANCE.getAutoGGConfig().isModEnabled(); + Supplier autoGGEnabled = () -> !HytilsReborn.INSTANCE.isSk1erAutoGG || !AutoGG.INSTANCE.getAutoGGConfig().isModEnabled(); addDependency("autoGG", "Sk1er's AutoGG Enabled", autoGGEnabled); addDependency("autoGGSecondMessage", "Sk1er's AutoGG Enabled", autoGGEnabled); From ebeef89a1936ebcc27f57c2395cf433ee64f6f9b Mon Sep 17 00:00:00 2001 From: ev chang Date: Thu, 20 Jun 2024 23:54:24 +0700 Subject: [PATCH 08/11] ACTUALLY fix the condition this time --- .../polyfrost/hytils/config/HytilsConfig.java | 19 +++++++++++-------- .../chat/modules/triggers/AutoGG.java | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index bc4337a..bdc2167 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -1245,17 +1245,20 @@ public HytilsConfig() { } initialize(); + Class autoGGClass = null; + try { + autoGGClass = Class.forName("club.sk1er.mods.autogg.config.AutoGGConfig"); + + HytilsReborn.INSTANCE.isSk1erAutoGG = true; + } catch (ClassNotFoundException ignored) { + } if (configNumber != 3) { // Config version has not been set or is outdated if (configNumber == 1) { overlayAmount = 300; } if (configNumber <= 2) { - try { - Class clazz = Class.forName("club.sk1er.mods.autogg.config.AutoGGConfig"); - - HytilsReborn.INSTANCE.isSk1erAutoGG = true; - + if (autoGGClass != null) { if (AutoGG.INSTANCE.getAutoGGConfig().isModEnabled()) { autoGG = true; } @@ -1285,7 +1288,7 @@ public HytilsConfig() { } try { - Field sk1erEnabled = clazz.getDeclaredField("autoGGEnabled"); + Field sk1erEnabled = autoGGClass.getDeclaredField("autoGGEnabled"); sk1erEnabled.setAccessible(true); sk1erEnabled.set(AutoGG.INSTANCE.getAutoGGConfig(), false); @@ -1296,9 +1299,8 @@ public HytilsConfig() { } Notifications.INSTANCE.send("Hytils Reborn", "AutoGG settings have been migrated to Hytils Reborn. You can now configure them in the Hytils Reborn settings, and remove Sk1erLLC's AutoGG.", 5); - } catch (ClassNotFoundException ignored) { - } + try { Class.forName("club.sk1er.lobbysounds.config.Sounds"); boolean modified = false; @@ -1418,6 +1420,7 @@ public HytilsConfig() { addDependency("autoGGFirstPhraseDelay", "Sk1er's AutoGG Enabled", autoGGEnabled); addDependency("autoGGMessage2", "Sk1er's AutoGG Enabled", autoGGEnabled); addDependency("autoGGSecondPhraseDelay", "Sk1er's AutoGG Enabled", autoGGEnabled); + addDependency("antiGG", "Sk1er's AutoGG Enabled", autoGGEnabled); addDependency("glPhrase", "autoGL"); 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 30e8021..0a4f2ab 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 @@ -66,7 +66,7 @@ private boolean hasGameEnded(String message) { @Override public boolean isEnabled() { - return HytilsConfig.autoGG && (!HytilsReborn.INSTANCE.isSk1erAutoGG || club.sk1er.mods.autogg.AutoGG.INSTANCE.getAutoGGConfig().isModEnabled()); // If Sk1er's AutoGG is enabled, we don't want to interfere with it. + return HytilsConfig.autoGG && (!HytilsReborn.INSTANCE.isSk1erAutoGG || !club.sk1er.mods.autogg.AutoGG.INSTANCE.getAutoGGConfig().isModEnabled()); // If Sk1er's AutoGG is enabled, we don't want to interfere with it. } @Override From 81bc260a5d8fcf7abbcc657ee0ca90bcc67209de Mon Sep 17 00:00:00 2001 From: ev chang Date: Fri, 21 Jun 2024 00:13:40 +0700 Subject: [PATCH 09/11] Change default second phrase delay to 2 --- src/main/java/org/polyfrost/hytils/config/HytilsConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index bdc2167..b1bf982 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -192,7 +192,7 @@ public class HytilsConfig extends Config { category = "Chat", subcategory = "Automatic", min = 0, max = 5 ) - public static int autoGGSecondPhraseDelay = 1; + public static int autoGGSecondPhraseDelay = 2; @Switch( name = "Auto GL", From 862bda2540dffed1c21b204fd37f7b0413ecfdd6 Mon Sep 17 00:00:00 2001 From: ev chang Date: Fri, 21 Jun 2024 00:14:13 +0700 Subject: [PATCH 10/11] i lied --- src/main/java/org/polyfrost/hytils/config/HytilsConfig.java | 2 +- .../polyfrost/hytils/handlers/chat/modules/triggers/AutoGG.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index b1bf982..bdc2167 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -192,7 +192,7 @@ public class HytilsConfig extends Config { category = "Chat", subcategory = "Automatic", min = 0, max = 5 ) - public static int autoGGSecondPhraseDelay = 2; + public static int autoGGSecondPhraseDelay = 1; @Switch( name = "Auto GL", 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 0a4f2ab..6e7c510 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 @@ -48,7 +48,7 @@ public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { if (!hasGameEnded(message)) return; Multithreading.schedule(() -> UChat.say("/ac " + getGGMessageOne()), HytilsConfig.autoGGFirstPhraseDelay, TimeUnit.SECONDS); if (HytilsConfig.autoGGSecondMessage) - Multithreading.schedule(() -> UChat.say("/ac " + getGGMessageTwo()), HytilsConfig.autoGGSecondPhraseDelay, TimeUnit.SECONDS); + Multithreading.schedule(() -> UChat.say("/ac " + getGGMessageTwo()), HytilsConfig.autoGGSecondPhraseDelay + HytilsConfig.autoGGFirstPhraseDelay, TimeUnit.SECONDS); } private boolean hasGameEnded(String message) { From 7595c42a4da935cb05e0e699af1c30c5d686f4fd Mon Sep 17 00:00:00 2001 From: ev chang Date: Fri, 21 Jun 2024 01:43:28 +0700 Subject: [PATCH 11/11] bump version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 663e6a0..9a68825 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ mod_name = Hytils Reborn mod_id = hytils-reborn -mod_version = 1.6.2 +mod_version = 1.7.0 # Sets the name of the jar file that you put in your 'mods' folder. mod_archives_name=Hytils Reborn