diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-03-30 01:01:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-30 01:01:51 +0100 |
commit | ed07b78b83aaa736c860a7aa510e578f46c62514 (patch) | |
tree | 1182af2c071d709096d99bd54e78428e28a48b50 /src/main/java/at | |
parent | d54e1bb0625c8d786a687707371f31e4ac62c9d0 (diff) | |
download | skyhanni-ed07b78b83aaa736c860a7aa510e578f46c62514.tar.gz skyhanni-ed07b78b83aaa736c860a7aa510e578f46c62514.tar.bz2 skyhanni-ed07b78b83aaa736c860a7aa510e578f46c62514.zip |
aprilfoolsjoke-words (#1314)
Co-authored-by: Linnea Gräf <nea@nea.moe>
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at')
3 files changed, 30 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java index ba57d123c..c43680efe 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java @@ -119,10 +119,15 @@ public class DebugConfig { public boolean currentAreaDebug = true; @Expose - @ConfigOption(name = "Always April Fools", desc = "Always show april fools jokes.") + @ConfigOption(name = "Always April Fools", desc = "Always show April fools jokes.") @ConfigEditorBoolean public boolean alwaysFunnyTime = false; @Expose + @ConfigOption(name = "Never April Fools", desc = "Admit it, you hate fun.") + @ConfigEditorBoolean + public boolean neverFunnyTime = false; + + @Expose public Position trackSoundPosition = new Position(0, 0); } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt index 55d9b7202..e6fcb8af5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt @@ -4,10 +4,12 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.events.HypixelJoinEvent +import at.hannibal2.skyhanni.mixins.hooks.FontRendererHook import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.convertToFormatted import at.hannibal2.skyhanni.utils.TimeLimitedCache import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.random.Random import kotlin.time.Duration.Companion.minutes object ModifyVisualWords { @@ -17,6 +19,8 @@ object ModifyVisualWords { var modifiedWords = mutableListOf<VisualWord>() + val reverseRegex = "(§.|^|[\\s:()+-])([^§\\s:()+-]*)".toRegex() + fun modifyText(originalText: String?): String? { var modifiedText = originalText ?: return null if (!LorenzUtils.onHypixel) return originalText @@ -42,13 +46,17 @@ object ModifyVisualWords { if (phrase.isEmpty()) continue modifiedText = modifiedText.replace( - phrase, - modifiedWord.replacement.convertToFormatted(), - modifiedWord.isCaseSensitive() + phrase, modifiedWord.replacement.convertToFormatted(), modifiedWord.isCaseSensitive() ) } } + + if (LorenzUtils.isAprilFoolsDay && !FontRendererHook.cameFromChat && Random.nextDouble() < 0.02) { + modifiedText = modifiedText.replace(reverseRegex) { + it.groupValues[1] + it.groupValues[2].reversed() + } + } textCache.put(originalText, modifiedText) return modifiedText } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 6249ec54a..048100f71 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.data.Perk import at.hannibal2.skyhanni.data.TitleManager import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI +import at.hannibal2.skyhanni.features.misc.visualwords.ModifyVisualWords import at.hannibal2.skyhanni.mixins.transformers.AccessorGuiEditSign import at.hannibal2.skyhanni.test.TestBingo import at.hannibal2.skyhanni.utils.ChatUtils.lastButtonClicked @@ -70,10 +71,20 @@ object LorenzUtils { val lastWorldSwitch get() = HypixelData.joinedWorld val isAprilFoolsDay: Boolean - get() = SkyHanniMod.feature.dev.debug.alwaysFunnyTime || LocalDate.now().let { - it.month == Month.APRIL && it.dayOfMonth == 1 + get() { + val itsTime = LocalDate.now().let { it.month == Month.APRIL && it.dayOfMonth == 1 } + val always = SkyHanniMod.feature.dev.debug.alwaysFunnyTime + val never = SkyHanniMod.feature.dev.debug.neverFunnyTime + val result = (!never && (always || itsTime)) + if (previousApril != result) { + ModifyVisualWords.textCache.clear() + } + previousApril = result + return result } + private var previousApril = false + fun SimpleDateFormat.formatCurrentTime(): String = this.format(System.currentTimeMillis()) fun stripVanillaMessage(originalMessage: String): String { |