diff --git a/src/main/java/org/polyfrost/hytils/HytilsReborn.java b/src/main/java/org/polyfrost/hytils/HytilsReborn.java index 4685660..d103a9a 100644 --- a/src/main/java/org/polyfrost/hytils/HytilsReborn.java +++ b/src/main/java/org/polyfrost/hytils/HytilsReborn.java @@ -50,7 +50,6 @@ import org.polyfrost.hytils.handlers.lobby.limbo.LimboLimiter; import org.polyfrost.hytils.handlers.lobby.limbo.LimboPmDing; import org.polyfrost.hytils.handlers.lobby.limbo.LimboTitle; -import org.polyfrost.hytils.handlers.lobby.mysterybox.MysteryBoxStar; import org.polyfrost.hytils.handlers.lobby.npc.NPCHandler; import org.polyfrost.hytils.handlers.lobby.sound.SilentLobby; import org.polyfrost.hytils.handlers.render.ChestHighlighter; @@ -182,7 +181,6 @@ private void registerHandlers() { eventBus.register(new LimboLimiter()); eventBus.register(new LimboTitle()); eventBus.register(new LimboPmDing()); - eventBus.register(new MysteryBoxStar()); eventBus.register(new SilentLobby()); // specific games diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index 08f888f..7406ada 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -361,11 +361,11 @@ public class HytilsConfig extends Config { public static boolean lobbyStatus; @Switch( - name = "Remove Mystery Box Rewards", - description = "Remove mystery box messages from chat and only show your own.\n§eExample: §b[MVP§c+§b] Steve §ffound a §6Legendary Hype Train Gadget§f!", + name = "Remove Ticket Machine Rewards", + description = "Remove ticket machine messages from chat and only show your own.\n§eExample: Steve has found a COMMON Figurine", category = "Chat", subcategory = "Toggles" ) - public static boolean mysteryBoxAnnouncer; + public static boolean ticketMachineAnnouncer; @Switch( name = "Remove Soul Well Announcements", @@ -1001,13 +1001,6 @@ public class HytilsConfig extends Config { ) public static boolean lobbyBossbar = true; - @Switch( - name = "Mystery Box Star", - description = "Shows what star a mystery box is in the Mystery Box Vault, Orange stars are special boxes.", - category = "Lobby", subcategory = "GUI" - ) - public static boolean mysteryBoxStar = true; - @Switch( name = "Silent Lobby", description = "Prevent all sounds from playing when you are in a lobby.", 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 8559e24..3b6b270 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java @@ -69,7 +69,6 @@ public ChatHandler() { this.registerModule(new LobbyFishingAnnouncementRemover()); this.registerModule(new LobbyStatusRemover()); this.registerModule(new MvpEmotesRemover()); - this.registerModule(new MysteryBoxRemover()); this.registerModule(new NonCooldownBlocker()); this.registerModule(new OnlineStatusRemover()); this.registerModule(new QuestBlocker()); @@ -79,6 +78,7 @@ public ChatHandler() { this.registerModule(new SkyblockWelcomeRemover()); this.registerModule(new SoulWellAnnouncerRemover()); this.registerModule(new StatsMessageRemover()); + this.registerModule(new TicketMachineRemover()); this.registerModule(new TipMessageRemover()); // Events diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/MysteryBoxRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/TicketMachineRemover.java similarity index 74% rename from src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/MysteryBoxRemover.java rename to src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/TicketMachineRemover.java index 05095ed..9083d4f 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/MysteryBoxRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/TicketMachineRemover.java @@ -18,24 +18,28 @@ package org.polyfrost.hytils.handlers.chat.modules.blockers; +import cc.polyfrost.oneconfig.utils.hypixel.LocrawInfo; +import cc.polyfrost.oneconfig.utils.hypixel.LocrawUtil; import org.polyfrost.hytils.config.HytilsConfig; import org.polyfrost.hytils.handlers.chat.ChatReceiveModule; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.jetbrains.annotations.NotNull; -public class MysteryBoxRemover implements ChatReceiveModule { +public class TicketMachineRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { + LocrawInfo locrawInformation = getLocraw(); String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); - if (getLanguage().chatCleanerMysteryBoxFindRegex.matcher(message).matches()) { + if (locrawInformation != null && locrawInformation.getGameType() == LocrawInfo.GameType.BEDWARS && !LocrawUtil.INSTANCE.isInGame() + && getLanguage().chatCleanerTicketAnnouncerRegex.matcher(message).matches()) { event.setCanceled(true); } } @Override public boolean isEnabled() { - return HytilsConfig.mysteryBoxAnnouncer; + return HytilsConfig.ticketMachineAnnouncer; } @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 72221c6..986df72 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java +++ b/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java @@ -37,7 +37,7 @@ public class LanguageData { private String autoFriendPattern = "Friend request from (?.+)\\[ACCEPT] - \\[DENY] - \\[IGNORE].*"; 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 chatCleanerTicketAnnouncer = "^(?(?!You )\\w{1,16} )has found an? .+$"; 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!$"; private String chatCleanerBedwarsPartyAdvertisement = "(?!.+: )(([1-8]/[1-8]|[1-8]v[1-8]|[2-8]s)|(any|rbw|ranked))"; @@ -116,7 +116,7 @@ public class LanguageData { public Pattern autoFriendPatternRegex; public Pattern chatCleanerJoinRegex; - public Pattern chatCleanerMysteryBoxFindRegex; + public Pattern chatCleanerTicketAnnouncerRegex; public Pattern chatCleanerSoulWellFindRegex; public Pattern chatCleanerGameAnnouncementRegex; public Pattern chatCleanerBedwarsPartyAdvertisementRegex; @@ -178,7 +178,7 @@ public void initialize() { autoFriendPatternRegex = Pattern.compile(autoFriendPattern); chatCleanerJoinRegex = Pattern.compile(chatCleanerJoin); - chatCleanerMysteryBoxFindRegex = Pattern.compile(chatCleanerMysteryBoxFind); + chatCleanerTicketAnnouncerRegex = Pattern.compile(chatCleanerTicketAnnouncer); chatCleanerSoulWellFindRegex = Pattern.compile(chatCleanerSoulWellFind); chatCleanerGameAnnouncementRegex = Pattern.compile(chatCleanerGameAnnouncement); chatCleanerBedwarsPartyAdvertisementRegex = Pattern.compile(chatCleanerBedwarsPartyAdvertisement); diff --git a/src/main/java/org/polyfrost/hytils/handlers/lobby/mysterybox/MysteryBoxStar.java b/src/main/java/org/polyfrost/hytils/handlers/lobby/mysterybox/MysteryBoxStar.java deleted file mode 100644 index 6fc20f1..0000000 --- a/src/main/java/org/polyfrost/hytils/handlers/lobby/mysterybox/MysteryBoxStar.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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.lobby.mysterybox; - -import cc.polyfrost.oneconfig.utils.hypixel.HypixelUtils; -import cc.polyfrost.oneconfig.utils.hypixel.LocrawUtil; -import org.polyfrost.hytils.HytilsReborn; -import org.polyfrost.hytils.config.HytilsConfig; -import org.polyfrost.hytils.util.ranks.RankType; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class MysteryBoxStar { - - private final Pattern mysteryBoxStarPattern = Pattern.compile("\\u00a75\\u00a7o\\u00a77\\u00a77Quality: \\u00a7e(?\\u2730+).*"); - - private boolean missingRank(int stars) { - return (HytilsReborn.INSTANCE.getRank() == RankType.NON && stars >= 4) || ((HytilsReborn.INSTANCE.getRank() == RankType.VIP || HytilsReborn.INSTANCE.getRank() == RankType.VIP_PLUS) && stars == 5); - } - - @SubscribeEvent - public void onDrawScreenPre(GuiScreenEvent.DrawScreenEvent.Pre event) { - if (!HytilsConfig.mysteryBoxStar || !HypixelUtils.INSTANCE.isHypixel() || LocrawUtil.INSTANCE.getLocrawInfo() == null || LocrawUtil.INSTANCE.isInGame()) { - return; - } - - if (event.gui instanceof GuiChest) { - final GuiChest guiChest = (GuiChest) event.gui; - final Container inventorySlots = guiChest.inventorySlots; - final IInventory inventory = inventorySlots.getSlot(0).inventory; - if (inventory.getName().contains("Mystery Vault")) { - final int guiLeft = (guiChest.width - 176) / 2; - final int inventoryRows = inventory.getSizeInventory() / 9; - final int ySize = 222 - 108 + inventoryRows * 18; - final int guiTop = (guiChest.height - ySize) / 2; - final float scaleFactor = 0.9f; - GlStateManager.pushMatrix(); - GlStateManager.translate(0, 0, 260); - GlStateManager.scale(scaleFactor, scaleFactor, 0); - for (Slot inventorySlot : inventorySlots.inventorySlots) { - final int slotRow = inventorySlot.slotNumber / 9; - final int maxRow = inventoryRows - 1; - if (slotRow < maxRow && inventorySlot.getHasStack()) { - final int slotX = (int) ((guiLeft + inventorySlot.xDisplayPosition) / scaleFactor) + 2; - final int slotY = (int) ((guiTop + inventorySlot.yDisplayPosition) / scaleFactor) + 1; - drawStars(inventorySlot.getStack(), slotX, slotY); - } - } - GlStateManager.popMatrix(); - } - } - } - - public void drawStars(ItemStack item, int x, int y) { - // avoid rendering star when no mystery boxes are present or on bags of experience - if (item.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) || item.getItem() == Items.dye) { - return; - } - - final List tooltip = item.getTooltip(Minecraft.getMinecraft().thePlayer, false); - // avoid accessing negative index - if (tooltip.size() < 4) { - return; - } - - final String normalBox = tooltip.get(tooltip.size() - 4); - final Matcher normalBoxMatcher = mysteryBoxStarPattern.matcher(normalBox); - final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; - // yellow stars for regular boxes - if (normalBoxMatcher.matches()) { - fontRenderer.drawStringWithShadow(normalBoxMatcher.group("stars").length() + "\u2730", x, y, -14080); - } else { - // for boxes with vip/mvp+ access - String rankedBoxLine = tooltip.get(tooltip.size() - 5); - Matcher rankedBoxMatcher = mysteryBoxStarPattern.matcher(rankedBoxLine); - if (rankedBoxMatcher.matches()) { - // prints the star in red if you cant open it - fontRenderer.drawStringWithShadow(rankedBoxMatcher.group("stars").length() + "\u2730", x, y, missingRank(rankedBoxMatcher.group("stars").length()) ? -43691 : -14080); - return; - } - - // not a regular box, so assume it is a special box. e.g. holiday boxes - // orange stars for special boxes - fontRenderer.drawStringWithShadow("\u2730", x, y, -34304); - } - } -}