-
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Crash Game On Death (#2238)
Co-authored-by: hannibal2 <[email protected]>
- Loading branch information
1 parent
a2266a8
commit 1da1de3
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/at/hannibal2/skyhanni/features/misc/CrashOnDeath.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package at.hannibal2.skyhanni.features.misc | ||
|
||
import at.hannibal2.skyhanni.SkyHanniMod | ||
import at.hannibal2.skyhanni.events.LorenzChatEvent | ||
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule | ||
import at.hannibal2.skyhanni.utils.LorenzUtils | ||
import at.hannibal2.skyhanni.utils.RegexUtils.matches | ||
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern | ||
import net.minecraft.client.Minecraft | ||
import net.minecraft.crash.CrashReport | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent | ||
|
||
@SkyHanniModule | ||
object CrashOnDeath { | ||
private val config get() = SkyHanniMod.feature.misc | ||
|
||
private val pattern by RepoPattern.pattern( | ||
"ownplayer.death.chat", | ||
"§c ☠ §r§7You (?<reason>.+)", | ||
) | ||
|
||
@SubscribeEvent | ||
fun onChat(event: LorenzChatEvent) { | ||
if (!isEnabled()) return | ||
|
||
if (pattern.matches(event.message)) { | ||
Minecraft.getMinecraft().crashed(CrashReport("Not Reading", Throwable("Don't toggle all the Options"))) | ||
} | ||
} | ||
private fun isEnabled() = LorenzUtils.inSkyBlock && config.crashOnDeath | ||
} |