aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/chat/AutoGGOnTapCube.kt
blob: 356d40a0fe8303e2bf2e510d53644c894900cd10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package moe.nea.firmament.features.chat

import java.util.concurrent.ThreadLocalRandom
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.time.Duration.Companion.milliseconds
import net.minecraft.text.Text
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ProcessChatEvent
import moe.nea.firmament.features.fixes.CompatibliltyFeatures
import moe.nea.firmament.util.FirmFormatters
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.SBData
import moe.nea.firmament.util.useMatch

object AutoGGOnTapCube {

	val regex = " *. STORE PURCHASE .".toPattern()

	@Subscribe
	fun onChat(event: ProcessChatEvent) {
		if (!SBData.isTabCube) return
		if (!CompatibliltyFeatures.TConfig.tapCube) return
		regex.useMatch(event.unformattedString) {
			val delay = ThreadLocalRandom.current().nextInt(500, 3000).milliseconds
			MC.sendChat(Text.literal("Sending gg in ${FirmFormatters.formatTimespan(delay, true)}"))
			Firmament.coroutineScope.launch {
				delay(delay)
				MC.sendServerChat("gg")
				MC.sendChat(Text.literal("Mission accomplished. AutoGG out."))
			}
		}
	}
}