blob: 220c7a7575c36f877c0a0fbd13bdf3d345da58b3 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
package at.hannibal2.skyhanni.features.garden
import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
import at.hannibal2.skyhanni.events.MessageSendToServerEvent
import at.hannibal2.skyhanni.features.misc.LockMouseLook
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds
class GardenWarpCommands {
private val config get() = GardenAPI.config.gardenCommands
private val tpPlotPattern by RepoPattern.pattern(
"garden.warpcommand.tpplot",
"/tp (?<plot>.*)"
)
private var lastWarpTime = SimpleTimeMark.farPast()
@SubscribeEvent
fun onMessageSendToServer(event: MessageSendToServerEvent) {
if (!config.warpCommands) return
if (!GardenAPI.inGarden()) return
val message = event.message.lowercase()
if (message == "/home") {
event.isCanceled = true
HypixelCommands.warp("garden")
ChatUtils.chat("§aTeleported you to the spawn location!", prefix = false)
}
if (message == "/barn") {
event.isCanceled = true
HypixelCommands.teleportToPlot("barn")
LockMouseLook.autoDisable()
}
tpPlotPattern.matchMatcher(event.message) {
event.isCanceled = true
val plotName = group("plot")
HypixelCommands.teleportToPlot(plotName)
LockMouseLook.autoDisable()
}
}
@SubscribeEvent
fun onKeyClick(event: LorenzKeyPressEvent) {
if (!GardenAPI.inGarden()) return
if (Minecraft.getMinecraft().currentScreen != null) return
if (NEUItems.neuHasFocus()) return
if (lastWarpTime.passedSince() < 2.seconds) return
when (event.keyCode) {
config.homeHotkey -> {
HypixelCommands.warp("garden")
}
config.sethomeHotkey -> {
ChatUtils.sendCommandToServer("sethome")
}
config.barnHotkey -> {
LockMouseLook.autoDisable()
HypixelCommands.teleportToPlot("barn")
}
else -> return
}
lastWarpTime = SimpleTimeMark.now()
}
}
|