From 092c0c921188901e3980bef102619bbe2e2a8312 Mon Sep 17 00:00:00 2001 From: MrSam7K <64192417+MrSam7K@users.noreply.github.com> Date: Sat, 16 Mar 2024 19:32:05 +0200 Subject: [PATCH] hide plot boosts in streamer mode --- .../mod/config/impl/StreamerModeGroup.java | 1 + .../chat/message/LegacyMessageType.java | 1 + .../social/chat/message/MessageCheck.java | 1 + .../chat/message/checks/PlotBoostCheck.java | 34 +++++++++++++++++++ .../streamer/StreamerModeHandler.java | 4 +++ .../resources/assets/recode/lang/en_us.json | 2 ++ 6 files changed, 43 insertions(+) create mode 100644 src/main/java/io/github/homchom/recode/mod/features/social/chat/message/checks/PlotBoostCheck.java diff --git a/src/main/java/io/github/homchom/recode/mod/config/impl/StreamerModeGroup.java b/src/main/java/io/github/homchom/recode/mod/config/impl/StreamerModeGroup.java index 9815a8983..245aab553 100644 --- a/src/main/java/io/github/homchom/recode/mod/config/impl/StreamerModeGroup.java +++ b/src/main/java/io/github/homchom/recode/mod/config/impl/StreamerModeGroup.java @@ -24,6 +24,7 @@ public void initialize() { modules.register(new BooleanSetting("streamerSpies", true)); modules.register(new BooleanSetting("streamerHideDMs", false)); modules.register(new BooleanSetting("streamerHidePlotAds", false)); + modules.register(new BooleanSetting("streamerHidePlotBoosts", false)); modules.register(new BooleanSetting("streamerHideBuycraftUpdate", true)); modules.register(new BooleanSetting("streamerHideSupport", true)); modules.register(new BooleanSetting("streamerHideModeration", true)); diff --git a/src/main/java/io/github/homchom/recode/mod/features/social/chat/message/LegacyMessageType.java b/src/main/java/io/github/homchom/recode/mod/features/social/chat/message/LegacyMessageType.java index 314b30ad0..88e4f32e2 100644 --- a/src/main/java/io/github/homchom/recode/mod/features/social/chat/message/LegacyMessageType.java +++ b/src/main/java/io/github/homchom/recode/mod/features/social/chat/message/LegacyMessageType.java @@ -8,6 +8,7 @@ public enum LegacyMessageType { // General DIRECT_MESSAGE(true), PLOT_AD(true), + PLOT_BOOST(true), // Support SUPPORT, diff --git a/src/main/java/io/github/homchom/recode/mod/features/social/chat/message/MessageCheck.java b/src/main/java/io/github/homchom/recode/mod/features/social/chat/message/MessageCheck.java index 86fb57e49..bd1e6d858 100644 --- a/src/main/java/io/github/homchom/recode/mod/features/social/chat/message/MessageCheck.java +++ b/src/main/java/io/github/homchom/recode/mod/features/social/chat/message/MessageCheck.java @@ -11,6 +11,7 @@ public abstract class MessageCheck { // General new DirectMessageCheck(), new PlotAdCheck(), + new PlotBoostCheck(), // Support new SupportCheck(), diff --git a/src/main/java/io/github/homchom/recode/mod/features/social/chat/message/checks/PlotBoostCheck.java b/src/main/java/io/github/homchom/recode/mod/features/social/chat/message/checks/PlotBoostCheck.java new file mode 100644 index 000000000..17a1082eb --- /dev/null +++ b/src/main/java/io/github/homchom/recode/mod/features/social/chat/message/checks/PlotBoostCheck.java @@ -0,0 +1,34 @@ +package io.github.homchom.recode.mod.features.social.chat.message.checks; + +import io.github.homchom.recode.mod.features.social.chat.message.LegacyMessage; +import io.github.homchom.recode.mod.features.social.chat.message.LegacyMessageType; +import io.github.homchom.recode.mod.features.social.chat.message.MessageCheck; +import io.github.homchom.recode.mod.features.streamer.StreamerModeHandler; +import io.github.homchom.recode.mod.features.streamer.StreamerModeMessageCheck; + +import java.util.regex.Pattern; + +public class PlotBoostCheck extends MessageCheck implements StreamerModeMessageCheck { + + private static final Pattern PLOT_BOOST_REGEX = Pattern.compile("\n {78}\n(.+)\n {29}\u200c→ Click to join!\n {78}"); + + @Override + public LegacyMessageType getType() { + return LegacyMessageType.PLOT_BOOST; + } + + @Override + public boolean check(LegacyMessage message, String stripped) { + return PLOT_BOOST_REGEX.matcher(stripped).matches(); + } + + @Override + public void onReceive(LegacyMessage message) { + + } + + @Override + public boolean streamerHideEnabled() { + return StreamerModeHandler.hidePlotBoosts(); + } +} \ No newline at end of file diff --git a/src/main/java/io/github/homchom/recode/mod/features/streamer/StreamerModeHandler.java b/src/main/java/io/github/homchom/recode/mod/features/streamer/StreamerModeHandler.java index a6f59215a..545ee0b0a 100644 --- a/src/main/java/io/github/homchom/recode/mod/features/streamer/StreamerModeHandler.java +++ b/src/main/java/io/github/homchom/recode/mod/features/streamer/StreamerModeHandler.java @@ -56,6 +56,10 @@ public static boolean hidePlotAds() { return getOption("streamerHidePlotAds"); } + public static boolean hidePlotBoosts() { + return getOption("streamerHidePlotBoosts"); + } + public static boolean hideBuycraftUpdate() { return getOption("streamerHideBuycraftUpdate"); } diff --git a/src/main/resources/assets/recode/lang/en_us.json b/src/main/resources/assets/recode/lang/en_us.json index 690556b0b..cc1000f8f 100644 --- a/src/main/resources/assets/recode/lang/en_us.json +++ b/src/main/resources/assets/recode/lang/en_us.json @@ -217,6 +217,8 @@ "config.recode.option.streamerHideDMs.tooltip": "Hides all incoming private messages", "config.recode.option.streamerHidePlotAds": "Hide Plot Ads", "config.recode.option.streamerHidePlotAds.tooltip": "Hides plot ads and blocks it's sound", + "config.recode.option.streamerHidePlotBoosts": "Hide Plot Boosts", + "config.recode.option.streamerHidePlotBoosts.tooltip": "Hides plot boosts and blocks it's sound", "config.recode.option.streamerHideBuycraftUpdate": "Hide BuycraftX Update", "config.recode.option.streamerHideBuycraftUpdate.tooltip": "Hides the BuycraftX plugin update message", "config.recode.option.streamerHideSupport": "Hide Support",