blob: a259493508cff2c64831f2399621357a5b97acba (
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
|
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.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class GardenWarpCommands {
private val config get() = GardenAPI.config.gardenCommands
// TODO repo
private val tpPlotPattern = "/tp (?<plot>.*)".toPattern()
@SubscribeEvent
fun onMessageSendToServer(event: MessageSendToServerEvent) {
if (!config.warpCommands) return
if (!GardenAPI.inGarden()) return
val message = event.message.lowercase()
if (message == "/home") {
event.isCanceled = true
LorenzUtils.sendCommandToServer("warp garden")
LorenzUtils.chat("§aTeleported you to the spawn location!", prefix = false)
}
if (message == "/barn") {
event.isCanceled = true
LorenzUtils.sendCommandToServer("tptoplot barn")
LockMouseLook.autoDisable()
}
tpPlotPattern.matchMatcher(event.message) {
event.isCanceled = true
val plotName = group("plot")
LorenzUtils.sendCommandToServer("tptoplot $plotName")
LockMouseLook.autoDisable()
}
}
@SubscribeEvent
fun onKeyClick(event: LorenzKeyPressEvent) {
if (!GardenAPI.inGarden()) return
if (Minecraft.getMinecraft().currentScreen != null) return
if (NEUItems.neuHasFocus()) return
val command = when (event.keyCode) {
config.homeHotkey -> "warp garden"
config.sethomeHotkey -> "sethome"
config.barnHotkey -> "tptoplot barn"
else -> return
}
if (command == "tptoplot barn") {
LockMouseLook.autoDisable()
}
LorenzUtils.sendCommandToServer(command)
}
}
|