diff --git a/src/main/java/cc/woverflow/hytils/HytilsReborn.java b/src/main/java/cc/woverflow/hytils/HytilsReborn.java index c3ec5f60..e34f8b6e 100644 --- a/src/main/java/cc/woverflow/hytils/HytilsReborn.java +++ b/src/main/java/cc/woverflow/hytils/HytilsReborn.java @@ -24,6 +24,7 @@ import cc.polyfrost.oneconfig.utils.commands.CommandManager; import cc.woverflow.hytils.command.*; import cc.woverflow.hytils.config.HytilsConfig; +import cc.woverflow.hytils.handlers.cache.ArmorStandHandler; import cc.woverflow.hytils.handlers.cache.CosmeticsHandler; import cc.woverflow.hytils.handlers.cache.HeightHandler; import cc.woverflow.hytils.handlers.cache.PatternHandler; @@ -128,6 +129,7 @@ public void init(FMLInitializationEvent event) { // GameNameParser to be initialized, and that depends on networking. PlayCommand.init(); + ArmorStandHandler.INSTANCE.initialize(); CosmeticsHandler.INSTANCE.initialize(); PatternHandler.INSTANCE.initialize(); HeightHandler.INSTANCE.initialize(); diff --git a/src/main/java/cc/woverflow/hytils/handlers/cache/ArmorStandHandler.java b/src/main/java/cc/woverflow/hytils/handlers/cache/ArmorStandHandler.java new file mode 100644 index 00000000..f96e433f --- /dev/null +++ b/src/main/java/cc/woverflow/hytils/handlers/cache/ArmorStandHandler.java @@ -0,0 +1,44 @@ +/* + * Hytils Reborn - Hypixel focused Quality of Life mod. + * Copyright (C) 2020, 2021, 2022 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 cc.woverflow.hytils.handlers.cache; + +import cc.polyfrost.oneconfig.utils.Multithreading; +import cc.polyfrost.oneconfig.utils.NetworkUtils; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +public class ArmorStandHandler { + public static ArmorStandHandler INSTANCE = new ArmorStandHandler(); + public List armorStandNames = new ArrayList<>(); + + public void initialize() { + Multithreading.runAsync(() -> { + final JsonElement gotten = NetworkUtils.getJsonElement("https://data.woverflow.cc/armorstands.json"); + if (gotten != null) { + JsonObject jsonObject = gotten.getAsJsonObject(); + for (JsonElement tag : jsonObject.getAsJsonArray("tags")) { + armorStandNames.add(tag.getAsString()); + } + } + }); + } +} diff --git a/src/main/java/cc/woverflow/hytils/handlers/chat/ChatHandler.java b/src/main/java/cc/woverflow/hytils/handlers/chat/ChatHandler.java index 74b6a3ac..f2026de4 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/chat/ChatHandler.java +++ b/src/main/java/cc/woverflow/hytils/handlers/chat/ChatHandler.java @@ -82,7 +82,6 @@ public ChatHandler() { // Modifiers - this.registerModule(new ColoredFriendStatuses()); this.registerModule(new DefaultChatRestyler()); this.registerModule(new GameStartCompactor()); this.registerModule(new WhiteChat()); diff --git a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/AdBlocker.java b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/AdBlocker.java index 04a27bb5..20890ee3 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/AdBlocker.java +++ b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/AdBlocker.java @@ -21,11 +21,11 @@ import cc.woverflow.hytils.HytilsReborn; import cc.woverflow.hytils.config.HytilsConfig; import cc.woverflow.hytils.handlers.chat.ChatReceiveModule; +import net.minecraft.client.Minecraft; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.jetbrains.annotations.NotNull; import java.util.Locale; -import java.util.regex.Pattern; public class AdBlocker implements ChatReceiveModule { @@ -48,26 +48,20 @@ public int getPriority() { * Blocks advertisements to join German SkyBlock guilds *

* Blocks stuff related with lowballing - * + *

* TODO: add more phrases to regex */ - private final Pattern commonAdvertisements = Pattern.compile("(?!.+: )(/?(((party join|join party)|p join|(guild join)|(join guild)|g join) \\w{1,16})|/?(party me|visit me|duel me|my ah|my smp)|(twitch.tv)|(youtube.com|youtu.be)|(/(visit|ah) \\w{1,16}|(visit /\\w{1,16})|(/gift)|(gilde)|(lowballing|lowbaling|lowvaling|lowvaluing|lowballer)))", - Pattern.CASE_INSENSITIVE); - - // common phrases used in messages where people beg for a rank gift - private final Pattern rankBegging = Pattern.compile("(?!.+: )([^\\[](vip|mvp|mpv|vpi)|(please|pls|plz|give|giving)|(rank|buy me|upgrade me)|(gift|gifting|gifters)|(beg|begging|beggers))", - Pattern.CASE_INSENSITIVE); - @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { final String message = event.message.getUnformattedText().toLowerCase(Locale.ENGLISH); - if ((message.startsWith("-") && message.endsWith("-")) || (message.startsWith("▬") && message.endsWith("▬")) || (message.startsWith("≡") && message.endsWith("≡")) || (message.startsWith("?") && message.endsWith("?")) || (!message.contains(": "))) return; - if (commonAdvertisements.matcher(message).find(0)) { + if ((message.startsWith("-") && message.endsWith("-")) || (message.startsWith("▬") && message.endsWith("▬")) || (message.startsWith("≡") && message.endsWith("≡")) || (message.startsWith("?") && message.endsWith("?")) || (!message.contains(": ")) || (message.contains(Minecraft.getMinecraft().getSession().getUsername().toLowerCase()))) + return; + if (getLanguage().chatCommonAdvertisementsRegex.matcher(message).find(0)) { event.setCanceled(true); } if (!HytilsReborn.INSTANCE.getLobbyChecker().playerIsInLobby()) return; - if (rankBegging.matcher(message).find(0)) { + if (getLanguage().chatRankBeggingRegex.matcher(message).find(0)) { event.setCanceled(true); } } diff --git a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/AntiGL.java b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/AntiGL.java index 33cb9554..ce6b08dc 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/AntiGL.java +++ b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/AntiGL.java @@ -20,21 +20,20 @@ import cc.woverflow.hytils.config.HytilsConfig; import cc.woverflow.hytils.handlers.chat.ChatReceiveModule; +import net.minecraft.client.Minecraft; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.jetbrains.annotations.NotNull; import java.util.Locale; -import java.util.regex.Pattern; public class AntiGL implements ChatReceiveModule { - private final Pattern cancelGlMessages = Pattern.compile("(?!.+: )(gl|glhf|good luck|have a good game|autogl by sk1er)", - Pattern.CASE_INSENSITIVE); - + @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { final String message = event.message.getUnformattedText().toLowerCase(Locale.ENGLISH); - if ((message.startsWith("-") && message.endsWith("-")) || (message.startsWith("▬") && message.endsWith("▬")) || (message.startsWith("≡") && message.endsWith("≡")) || (message.startsWith("?") && message.endsWith("?")) || (!message.contains(": "))) return; - if (cancelGlMessages.matcher(message).find(0)) { + if ((message.startsWith("-") && message.endsWith("-")) || (message.startsWith("▬") && message.endsWith("▬")) || (message.startsWith("≡") && message.endsWith("≡")) || (message.startsWith("?") && message.endsWith("?")) || (!message.contains(": ")) || (message.contains(Minecraft.getMinecraft().getSession().getUsername().toLowerCase()))) + return; + if (getLanguage().cancelGlMessagesRegex.matcher(message).find(0)) { event.setCanceled(true); } } diff --git a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/BedwarsAdvertisementsRemover.java b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/BedwarsAdvertisementsRemover.java index 57a6605d..49c2827c 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/BedwarsAdvertisementsRemover.java +++ b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/BedwarsAdvertisementsRemover.java @@ -23,6 +23,7 @@ import cc.woverflow.hytils.HytilsReborn; import cc.woverflow.hytils.config.HytilsConfig; import cc.woverflow.hytils.handlers.chat.ChatReceiveModule; +import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.jetbrains.annotations.NotNull; @@ -32,7 +33,7 @@ public class BedwarsAdvertisementsRemover implements ChatReceiveModule { public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { LocrawInfo locrawInformation = HypixelUtils.INSTANCE.getLocrawInfo(); String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); - if ((message.startsWith("-") && message.endsWith("-")) || (message.startsWith("▬") && message.endsWith("▬")) || (message.startsWith("≡") && message.endsWith("≡")) || (message.startsWith("?") && message.endsWith("?")) || (!message.contains(": "))) return; + if ((message.startsWith("-") && message.endsWith("-")) || (message.startsWith("▬") && message.endsWith("▬")) || (message.startsWith("≡") && message.endsWith("≡")) || (message.startsWith("?") && message.endsWith("?")) || (!message.contains(": ")) || (message.contains(Minecraft.getMinecraft().getSession().getUsername().toLowerCase()))) return; if (locrawInformation != null && locrawInformation.getGameType() == LocrawInfo.GameType.BEDWARS && HytilsReborn.INSTANCE.getLobbyChecker().playerIsInLobby() && getLanguage().chatCleanerBedwarsPartyAdvertisementRegex.matcher(message).find()) { event.setCanceled(true); diff --git a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/LobbyStatusRemover.java b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/LobbyStatusRemover.java index 96cf5643..8a68e888 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/LobbyStatusRemover.java +++ b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/LobbyStatusRemover.java @@ -24,18 +24,13 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.jetbrains.annotations.NotNull; -import java.util.regex.Pattern; - public class LobbyStatusRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { final String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); - if (message.contains(":")) return; - for (Pattern messages : getLanguage().chatCleanerJoinMessageTypes) { - if (messages.matcher(message).find()) { - event.setCanceled(true); - return; - } + if (message.contains(": ")) return; + if (getLanguage().chatCleanerJoinRegex.matcher(message).find()) { + event.setCanceled(true); } } diff --git a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/events/LevelupEvent.java b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/events/LevelupEvent.java index eb944be7..470461ac 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/events/LevelupEvent.java +++ b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/events/LevelupEvent.java @@ -38,7 +38,7 @@ public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { final String unformattedText = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); final Matcher matcher = getLanguage().hypixelLevelUpRegex.matcher(unformattedText.trim()); if (matcher.find()) { - if (unformattedText.contains(":")) return; // TODO: This is a temporary solution to prevent regular player messages from triggering it. Fix the regex! + if (unformattedText.contains(": ")) return; // TODO: This is a temporary solution to prevent regular player messages from triggering it. Fix the regex! final String level = matcher.group("level"); if (StringUtils.isNumeric(level)) { MinecraftForge.EVENT_BUS.post(new HypixelLevelupEvent(Integer.parseInt(level))); diff --git a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/modifiers/ColoredFriendStatuses.java b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/modifiers/ColoredFriendStatuses.java deleted file mode 100644 index b0e36929..00000000 --- a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/modifiers/ColoredFriendStatuses.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Hytils Reborn - Hypixel focused Quality of Life mod. - * Copyright (C) 2020, 2021, 2022 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 cc.woverflow.hytils.handlers.chat.modules.modifiers; - -import cc.woverflow.hytils.config.HytilsConfig; -import cc.woverflow.hytils.handlers.chat.ChatReceiveModule; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import org.jetbrains.annotations.NotNull; - -import java.util.regex.Matcher; - -public class ColoredFriendStatuses implements ChatReceiveModule { - @Override - public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { - final String message = event.message.getFormattedText().trim(); - - if (HytilsConfig.coloredStatuses) { - Matcher matcher = getLanguage().chatRestylerStatusPatternRegex.matcher(message); - if (matcher.matches()) { - final String status = matcher.group("status"); // TODO: fix short channel names so we can remove the 2nd group - - String channelStarter = null; // Fixes short channel name incompatibility since it randomly popped up despite what appears to be no changes - if (matcher.group("type").contains("F")) { - if (HytilsConfig.shortChannelNames) channelStarter = "§aF > §r"; - else channelStarter = "§aFriend > §r"; - } - if (matcher.group("type").contains("G")) { - if (HytilsConfig.shortChannelNames) channelStarter = "§2G > §r"; - else channelStarter = "§2Guild > §r"; - } - - if (status.equalsIgnoreCase("joined")) { - event.message = colorMessage(channelStarter + matcher.group("player") + " §r" + "§ajoined§e."); - } - if (status.equalsIgnoreCase("left")) { - event.message = colorMessage(channelStarter + matcher.group("player") + " §r" + "§cleft§e."); - } - } - } - } - - @Override - public int getPriority() { - return 5; - } -} diff --git a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/modifiers/DefaultChatRestyler.java b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/modifiers/DefaultChatRestyler.java index 350cf258..33160960 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/modifiers/DefaultChatRestyler.java +++ b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/modifiers/DefaultChatRestyler.java @@ -97,6 +97,18 @@ public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { } } + if (HytilsConfig.coloredStatuses) { + Matcher statusMatcher = getLanguage().chatRestylerStatusPatternRegex.matcher(event.message.getFormattedText().trim()); + if (statusMatcher.matches()) { + final String status = statusMatcher.group("status"); + if (status.equalsIgnoreCase("joined")) { + event.message = colorMessage(statusMatcher.group("type") + " > &r" + statusMatcher.group("player") + " &r&ajoined&e."); + } else if (status.equalsIgnoreCase("left")) { + event.message = colorMessage(statusMatcher.group("type") + " > &r" + statusMatcher.group("player") + " &r&cleft&e."); + } + } + } + // Currently unformattedMessage doesn't need to be changed but I'm leaving these in, commented, in case it's // changed in the future and they need to be padded. if (HytilsConfig.padPlayerCount) { @@ -142,8 +154,10 @@ public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { // if the format (below) is changed, remember to update the regex for it (chatRestylerGameStartCounterOutputStyle) event.message = colorMessage("&e&l* &a" + (startCounterMatcher.group("title")) + " &b&l" + startCounterMatcher.group("time") + " &a" + startCounterMatcher.group("unit")); } else { - if ("We don't have enough players! Start cancelled.".equals(unformattedMessage) || ("We don't have enough players! Start delayed.".equals(unformattedMessage))) { + if ("We don't have enough players! Start cancelled.".equals(unformattedMessage)) { event.message = colorMessage("&e&l* &cStart cancelled."); + } else if ("We don't have enough players! Start delayed.".equals(unformattedMessage)) { + event.message = colorMessage("&e&l* &cStart delayed."); } } } @@ -174,9 +188,9 @@ public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { * Handles the replacement of channel names * Loops through all siblings to find a replacement * - * @param message The message being modified - * @param pattern The regular expression to check the message and it's components against - * @param replacement The text that replaces what is matched by the regular expression + * @param message The message being modified + * @param pattern The regular expression to check the message and it's components against + * @param replacement The text that replaces what is matched by the regular expression * @param checkParentComponent Whether or not to check the parent chat component */ private ChatComponentText shortenChannelName(IChatComponent message, String pattern, String replacement, boolean checkParentComponent) { diff --git a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/triggers/AutoFriend.java b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/triggers/AutoFriend.java index 1286e0a4..82acdbee 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/triggers/AutoFriend.java +++ b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/triggers/AutoFriend.java @@ -21,6 +21,7 @@ import cc.woverflow.hytils.HytilsReborn; import cc.woverflow.hytils.config.HytilsConfig; import cc.woverflow.hytils.handlers.chat.ChatReceiveModule; +import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.jetbrains.annotations.NotNull; @@ -29,6 +30,7 @@ /** * Taken and adapted from AutoFriend under MIT * https://github.com/minemanpi/AutoFriend/blob/master/LICENSE + * * @author 2Pi */ public class AutoFriend implements ChatReceiveModule { @@ -36,12 +38,13 @@ public class AutoFriend implements ChatReceiveModule { public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { String message = event.message.getUnformattedText().replace("\n", ""); Matcher matcher = getLanguage().autoFriendPatternRegex.matcher(message); - if (matcher.matches()) { + if (matcher.find()) { String name = matcher.group("name"); if (name.startsWith("[")) { name = name.substring(name.indexOf("] ") + 2); - HytilsReborn.INSTANCE.getCommandQueue().queue("/friend " + name); } + HytilsReborn.INSTANCE.getCommandQueue().queue("/friend " + name); + HytilsReborn.INSTANCE.sendMessage(EnumChatFormatting.GREEN + "Automatically added " + name + " to your friend list."); } } diff --git a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/triggers/ThankWatchdog.java b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/triggers/ThankWatchdog.java index 3a5a7386..fb2e78ed 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/triggers/ThankWatchdog.java +++ b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/triggers/ThankWatchdog.java @@ -33,7 +33,7 @@ public int getPriority() { @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { - if (event.message.getUnformattedText().equals("[WATCHDOG ANNOUNCEMENT]")) { + if (event.message.getUnformattedText().equals("[WATCHDOG ANNOUNCEMENT]") || event.message.getUnformattedText().startsWith("A player has been removed from your")) { Minecraft.getMinecraft().thePlayer.sendChatMessage("/achat Thanks Watchdog!"); } } diff --git a/src/main/java/cc/woverflow/hytils/handlers/game/GameEndingTitles.java b/src/main/java/cc/woverflow/hytils/handlers/game/GameEndingTitles.java index 770ce8c4..5c950541 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/game/GameEndingTitles.java +++ b/src/main/java/cc/woverflow/hytils/handlers/game/GameEndingTitles.java @@ -32,7 +32,7 @@ public void onTitle(TitleEvent event) { return; } - switch (EnumChatFormatting.getTextWithoutFormattingCodes(event.getTitle())) { + switch (EnumChatFormatting.getTextWithoutFormattingCodes(event.getTitle().toUpperCase())) { case "YOU WIN!": case "YOU DIED!": case "YOU LOSE!": @@ -41,9 +41,6 @@ public void onTitle(TitleEvent event) { case "RESPAWNED!": case "DEFEAT!": case "GAME END": - case "You Win!": - case "You Lose!": - case "Game Over!": case "YOU DIED": case "DEFEAT": event.setCanceled(true); diff --git a/src/main/java/cc/woverflow/hytils/handlers/game/GameStartingTitles.java b/src/main/java/cc/woverflow/hytils/handlers/game/GameStartingTitles.java index 1167eada..474b4966 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/game/GameStartingTitles.java +++ b/src/main/java/cc/woverflow/hytils/handlers/game/GameStartingTitles.java @@ -33,19 +33,22 @@ public void onTitle(TitleEvent event) { return; } - switch (EnumChatFormatting.getTextWithoutFormattingCodes(event.getTitle())) { - case "10 seconds": + switch (EnumChatFormatting.getTextWithoutFormattingCodes(event.getTitle().toUpperCase())) { + case "10 SECONDS": case "10": case "5": case "4": case "3": case "2": case "1": - case "Waiting for more players...": - case "SkyWars": + case "❸": + case "❷": + case "❶": + case "WAITING FOR MORE PLAYERS...": + case "SKYWARS": case "INSANE MODE": - case "Fight!": - case "Zombies": + case "FIGHT!": + case "ZOMBIES": case "ASSASSINS": case "YOU ARE RED": case "YOU ARE BLUE": @@ -53,9 +56,6 @@ public void onTitle(TitleEvent event) { case "YOU ARE GREEN": case "PRE ROUND": case "ROUND START": - case "❸": - case "❷": - case "❶": event.setCanceled(true); break; } diff --git a/src/main/java/cc/woverflow/hytils/handlers/language/LanguageData.java b/src/main/java/cc/woverflow/hytils/handlers/language/LanguageData.java index 0e5a148b..d5f96084 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/language/LanguageData.java +++ b/src/main/java/cc/woverflow/hytils/handlers/language/LanguageData.java @@ -18,9 +18,6 @@ package cc.woverflow.hytils.handlers.language; -import com.google.common.collect.Sets; - -import java.util.Set; import java.util.regex.Pattern; /** @@ -39,9 +36,7 @@ public class LanguageData { public String autoFriendPattern = "\u00A7m----------------------------------------------------Friend request from (?.+)\\[ACCEPT\\] - \\[DENY\\] - \\[IGNORE\\].*"; - private String chatCleanerJoinNormal = "joined the lobby"; - private String chatCleanerJoinHalloween = "spooked into the lobby"; - private String chatCleanerJoinChristmas = "(?:sled|slid) into the lobby"; + private String chatCleanerJoin = "(?:sled into|slid into|joined|spooked into) the lobby"; private String chatCleanerMysteryBoxFind = "^.+ (?(?!You)\\w{1,16}) found (?:a|an) (?:.{5} Mystery Box!|.+ in a .+!)$"; private String chatCleanerSoulWellFind = "^.+ has found .+ in the Soul Well!$"; private String chatCleanerGameAnnouncement = "^\u27A4 A .+ game is (?:available to join|starting in .+ seconds)! CLICK HERE to join!$"; @@ -50,6 +45,8 @@ public class LanguageData { private String chatCleanerMvpEmotes = "\u00a7r\u00a7(?:c\u2764|6\u272e|a\u2714|c\u2716|b\u2615|e\u279c|e\u00af\\\\_\\(\u30c4\\)_/\u00af|c\\(\u256F\u00B0\u25A1\u00B0\uFF09\u256F\u00a7r\u00a7f\uFE35\u00a7r\u00a77 \u253B\u2501\u253B|d\\( \uFF9F\u25E1\uFF9F\\)/|a1\u00a7r\u00a7e2\u00a7r\u00a7c3|b\u2609\u00a7r\u00a7e_\u00a7r\u00a7b\u2609|e\u270E\u00a7r\u00a76\\.\\.\\.|a\u221A\u00a7r\u00a7e\u00a7l\\(\u00a7r\u00a7a\u03C0\u00a7r\u00a7a\u00a7l\\+x\u00a7r\u00a7e\u00a7l\\)\u00a7r\u00a7a\u00a7l=\u00a7r\u00a7c\u00a7lL|e@\u00a7r\u00a7a'\u00a7r\u00a7e-\u00a7r\u00a7a'|6\\(\u00a7r\u00a7a0\u00a7r\u00a76\\.\u00a7r\u00a7ao\u00a7r\u00a7c\\?\u00a7r\u00a76\\)|b\u0F3C\u3064\u25D5_\u25D5\u0F3D\u3064|e\\(\u00a7r\u00a7b'\u00a7r\u00a7e-\u00a7r\u00a7b'\u00a7r\u00a7e\\)\u2283\u00a7r\u00a7c\u2501\u00a7r\u00a7d\u2606\uFF9F\\.\\*\uFF65\uFF61\uFF9F|e\u2694|a\u270C|c\u00a7lOOF|e\u00a7l<\\('O'\\)>)\u00a7r"; public String chatCleanerHypeLimit = " \u27A4 You have reached your Hype limit!"; private String chatGiftBlocker = "They have gifted \\d+ (?:rank|ranks) so far!"; + private String chatCommonAdvertisements = "(?!.+: )(/?(((party join|join party)|p join|(guild join)|(join guild)|g join) \\w{1,16})|/?(party me|visit me|duel me|my ah|my smp)|(twitch.tv)|(youtube.com|youtu.be)|(/(visit|ah) \\w{1,16}|(visit /\\w{1,16})|(/gift)|(gilde)|(lowballing|lowbaling|lowvaling|lowvaluing|lowballer)))"; + private String chatRankBegging = "(?!.+: )([^\\[](vip|mvp|mpv|vpi)|(please|pls|plz|give|giving)|(rank|buy me|upgrade me)|(gift|gifting|gifters)|(beg|begging|beggers))"; private String chatCleanerGrinchPresents = "(?:You found (?:an egg|a gift|a candy)! .\\d{1,3} total.|^\\W{0,3}\\w{0,}\\S{0,3}\\s{0,1}\\w{1,16} has reached \\d{2,3} (?:gifts|eggs|candy)!)"; private String chatCleanerEarnedCoinsAndExp = "^(?:\\W\\d+ .* Experience.*|\\W\\d+ coins!.*|You earned \\d+ GEXP from playing.+!|.+ just earned .+ as a Guild Level Reward!)"; //.* at the end for modifiers public String chatCleanerReplayRecorded = "This game has been recorded. Click here to watch the Replay!"; @@ -91,6 +88,8 @@ public class LanguageData { public String cannotShoutBeforeGame = "You can't use /shout before the game has started."; public String cannotShoutAfterGame = "You can't use /shout after the game has finished."; + public String cancelGlMessages = "(?!.+: )(gl|glhf|good luck|have a good game|autogl by sk1er)"; + private String hypixelLevelUp = "You are now Hypixel Level (?\\d+)!"; /** @@ -101,8 +100,7 @@ public class LanguageData { public Pattern autoFriendPatternRegex; - public Set chatCleanerJoinMessageTypes; - + public Pattern chatCleanerJoinRegex; public Pattern chatCleanerMysteryBoxFindRegex; public Pattern chatCleanerSoulWellFindRegex; public Pattern chatCleanerGameAnnouncementRegex; @@ -110,6 +108,8 @@ public class LanguageData { public Pattern chatCleanerConnectionStatusRegex; public Pattern chatCleanerMvpEmotesRegex; public Pattern chatGiftBlockerRegex; + public Pattern chatCommonAdvertisementsRegex; + public Pattern chatRankBeggingRegex; public Pattern chatCleanerGrinchPresentsRegex; public Pattern chatCleanerEarnedCoinsAndExpRegex; public Pattern chatCleanerReplayRecordedRegex; @@ -143,6 +143,8 @@ public class LanguageData { public Pattern privateMessageWhiteChatRegex; public Pattern silentRemovalLeaveMessageRegex; + public Pattern cancelGlMessagesRegex; + public Pattern hypixelLevelUpRegex; /** @@ -156,8 +158,7 @@ public void initialize() { autoFriendPatternRegex = Pattern.compile(autoFriendPattern); - chatCleanerJoinMessageTypes = Sets.newHashSet(Pattern.compile(chatCleanerJoinNormal), Pattern.compile(chatCleanerJoinHalloween), Pattern.compile(chatCleanerJoinChristmas)); - + chatCleanerJoinRegex = Pattern.compile(chatCleanerJoin); chatCleanerMysteryBoxFindRegex = Pattern.compile(chatCleanerMysteryBoxFind); chatCleanerSoulWellFindRegex = Pattern.compile(chatCleanerSoulWellFind); chatCleanerGameAnnouncementRegex = Pattern.compile(chatCleanerGameAnnouncement); @@ -165,6 +166,8 @@ public void initialize() { chatCleanerConnectionStatusRegex = Pattern.compile(chatCleanerConnectionStatus); chatCleanerMvpEmotesRegex = Pattern.compile(chatCleanerMvpEmotes); chatGiftBlockerRegex = Pattern.compile(chatGiftBlocker); + chatCommonAdvertisementsRegex = Pattern.compile(chatCommonAdvertisements, Pattern.CASE_INSENSITIVE); + chatRankBeggingRegex = Pattern.compile(chatRankBegging, Pattern.CASE_INSENSITIVE); chatCleanerGrinchPresentsRegex = Pattern.compile(chatCleanerGrinchPresents); chatCleanerEarnedCoinsAndExpRegex = Pattern.compile(chatCleanerEarnedCoinsAndExp); chatCleanerReplayRecordedRegex = Pattern.compile(chatCleanerReplayRecorded); @@ -199,6 +202,8 @@ public void initialize() { silentRemovalLeaveMessageRegex = Pattern.compile(silentRemovalLeaveMessage); hypixelLevelUpRegex = Pattern.compile(hypixelLevelUp); + + cancelGlMessagesRegex = Pattern.compile(cancelGlMessages, Pattern.CASE_INSENSITIVE); } } diff --git a/src/main/java/cc/woverflow/hytils/handlers/lobby/armorstands/ArmorStandHider.java b/src/main/java/cc/woverflow/hytils/handlers/lobby/armorstands/ArmorStandHider.java index 1bf98808..35557664 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/lobby/armorstands/ArmorStandHider.java +++ b/src/main/java/cc/woverflow/hytils/handlers/lobby/armorstands/ArmorStandHider.java @@ -20,28 +20,25 @@ import cc.polyfrost.oneconfig.utils.hypixel.HypixelUtils; import cc.polyfrost.oneconfig.utils.hypixel.LocrawInfo; +import cc.woverflow.hytils.HytilsReborn; import cc.woverflow.hytils.config.HytilsConfig; +import cc.woverflow.hytils.handlers.cache.ArmorStandHandler; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityArmorStand; import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import cc.woverflow.hytils.HytilsReborn; public class ArmorStandHider { - private static final String[] armorStandNames = {"click", "mystery vault", "daily reward tokens", "advent calendar reward", "free rewards", "special holiday quests", "release", - "festive floors", "museums", "hype", "coming soon", " set #", "fireball/tnt jumping", "parkour starts this way", "go ahead into the cave", "holiday mode", "new update", "new modes & maps", - "bug fixes & qol update", "sign posting", "parkour challenge", "your arcade games profile", "crimson isle", "featured", "limited time", "hytale trailer", - "happy easter", "happy halloween", "happy holidays", "easter event", "holiday event", "halloween event", "summer event", "goal", "defend", "jump in to score"}; - @SubscribeEvent public void onEntityRenderer(RenderLivingEvent.Pre event) { final LocrawInfo locraw = HypixelUtils.INSTANCE.getLocrawInfo(); if (HypixelUtils.INSTANCE.isHypixel() && locraw != null && (HytilsReborn.INSTANCE.getLobbyChecker().playerIsInLobby() && HytilsConfig.hideUselessArmorStands || HytilsConfig.hideUselessArmorStandsGame && (locraw.getGameType() == LocrawInfo.GameType.SKYBLOCK || locraw.getGameType() == LocrawInfo.GameType.BEDWARS || locraw.getGameType() == LocrawInfo.GameType.SKYWARS || locraw.getGameMode().contains("BRIDGE")))) { if (event.entity instanceof EntityArmorStand) { String unformattedArmorStandName = event.entity.getCustomNameTag().toLowerCase(); - for (String armorStands : armorStandNames) { + for (String armorStands : ArmorStandHandler.INSTANCE.armorStandNames) { if (unformattedArmorStandName.contains(armorStands)) { event.setCanceled(true); + break; } } } diff --git a/src/main/java/cc/woverflow/hytils/mixin/GuiPlayerTabOverlayMixin_HidePing.java b/src/main/java/cc/woverflow/hytils/mixin/GuiPlayerTabOverlayMixin_HidePing.java index d10f1581..3a1045e8 100644 --- a/src/main/java/cc/woverflow/hytils/mixin/GuiPlayerTabOverlayMixin_HidePing.java +++ b/src/main/java/cc/woverflow/hytils/mixin/GuiPlayerTabOverlayMixin_HidePing.java @@ -26,7 +26,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(value = GuiPlayerTabOverlay.class, priority = Integer.MIN_VALUE) +@Mixin(value = GuiPlayerTabOverlay.class, priority = 0) public class GuiPlayerTabOverlayMixin_HidePing { @Inject(method = "drawPing", at = @At("HEAD"), cancellable = true) private void checkPlayer(int p_175245_1_, int p_175245_2_, int p_175245_3_, NetworkPlayerInfo networkPlayerInfoIn, CallbackInfo ci) {