diff options
Diffstat (limited to 'src/main/java/at/hannibal2')
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 { |