diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-26 12:57:05 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-26 12:57:05 +0100 |
commit | 96b220f94dc0782959fa327a1f3c91c954685e8d (patch) | |
tree | 5c3e283328b7a6f71c5d8d2bb61670e6bcc4a1b4 /src/main/java/at/hannibal2/skyhanni/features | |
parent | 13442c2fb2fe17bb7317cf154976f6e833c85c07 (diff) | |
download | skyhanni-96b220f94dc0782959fa327a1f3c91c954685e8d.tar.gz skyhanni-96b220f94dc0782959fa327a1f3c91c954685e8d.tar.bz2 skyhanni-96b220f94dc0782959fa327a1f3c91c954685e8d.zip |
Added Garden only commands /home, /barn and /tp, and hotkeys.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenCommands.kt | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCommands.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCommands.kt new file mode 100644 index 000000000..3ae6b81f6 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCommands.kt @@ -0,0 +1,57 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.events.LorenzKeyPressEvent +import at.hannibal2.skyhanni.events.MessageSendToServerEvent +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 GardenCommands { + 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") + } + + tpPlotPattern.matchMatcher(message) { + event.isCanceled = true + val plotName = group("plot") + LorenzUtils.sendCommandToServer("tptoplot $plotName") + } + } + + @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 + } + LorenzUtils.sendCommandToServer(command) + } +} |