From 218e8048e345f4792cc1b696570fae29ac532ef8 Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Fri, 21 Oct 2022 02:40:16 +0000 Subject: Remove messages in chat if they are under a set skyblock level (#322) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove messages in chat if they are under a set skyblock level * 🤓 "not future proof. what if someone gets sb level 1000" * 2.1.1.md * Update Update Notes/2.1.1.md Co-authored-by: Roman / Linnea Gräf --- .../moulberry/notenoughupdates/listener/ChatListener.java | 8 ++++++++ .../notenoughupdates/options/seperateSections/Misc.java | 12 ++++++++++++ 2 files changed, 20 insertions(+) (limited to 'src') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java index 3473124c..e3a3edad 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java @@ -53,6 +53,8 @@ public class ChatListener { private final NotEnoughUpdates neu; private static final Pattern SLAYER_XP = Pattern.compile( " (Spider|Zombie|Wolf|Enderman|Blaze) Slayer LVL (\\d) - (?:Next LVL in ([\\d,]+) XP!|LVL MAXED OUT!)"); + + private static final Pattern SKYBLOCK_LVL_MESSAGE = Pattern.compile("\\[(\\d{1,4})\\] .*"); AtomicBoolean missingRecipe = new AtomicBoolean(false); public ChatListener(NotEnoughUpdates neu) { @@ -254,5 +256,11 @@ public class ChatListener { unformatted.startsWith(" ") || unformatted.startsWith("✦") || unformatted.equals( " You've earned a Crystal Loot Bundle!")) OverlayManager.crystalHollowOverlay.message(unformatted); + Matcher LvlMatcher = SKYBLOCK_LVL_MESSAGE.matcher(unformatted); + if (LvlMatcher.matches()) { + if (Integer.parseInt(LvlMatcher.group(1)) < NotEnoughUpdates.INSTANCE.config.misc.filterChatLevel && NotEnoughUpdates.INSTANCE.config.misc.filterChatLevel != 0) { + e.setCanceled(true); + } + } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java index 86c4c5dd..568f852e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java @@ -237,6 +237,18 @@ public class Misc { @ConfigEditorBoolean public boolean coopWarning = true; + @Expose + @ConfigOption( + name = "Filter Skyblock Levels in Chat", + desc = "Requires the \"SkyBlock Levels in Chat\" skyblock setting to be on" + ) + @ConfigEditorSlider( + minValue = 0, + maxValue = 300, + minStep = 10 + ) + public int filterChatLevel = 0; + @Expose @ConfigOption( name = "Enable text field tweaks", -- cgit