aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenCommandsConfig.java31
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenCommands.kt57
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt2
5 files changed, 96 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index e38940ec6..c63003f1e 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -133,6 +133,7 @@ import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishMessages
import at.hannibal2.skyhanni.features.garden.AnitaMedalProfit
import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay
import at.hannibal2.skyhanni.features.garden.GardenAPI
+import at.hannibal2.skyhanni.features.garden.GardenCommands
import at.hannibal2.skyhanni.features.garden.GardenCropMilestoneFix
import at.hannibal2.skyhanni.features.garden.GardenLevelDisplay
import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest
@@ -384,6 +385,7 @@ class SkyHanniMod {
loadModule(ActionBarStatsData)
loadModule(GardenCropMilestoneInventory())
loadModule(GardenCropSpeed)
+ loadModule(GardenCommands())
loadModule(ProfileStorageData)
loadModule(TitleData())
loadModule(BlockData())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenCommandsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenCommandsConfig.java
new file mode 100644
index 000000000..1d88140ec
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenCommandsConfig.java
@@ -0,0 +1,31 @@
+package at.hannibal2.skyhanni.config.features.garden;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+import com.google.gson.annotations.Expose;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind;
+import io.github.moulberry.moulconfig.annotations.ConfigOption;
+import org.lwjgl.input.Keyboard;
+
+public class GardenCommandsConfig {
+ @Expose
+ @ConfigOption(name = "Warp Commands", desc = "Enable commands §e/home§7, §e/barn §7and §e/tp <plot>§7. §cOnly works while on the garden.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean warpCommands = true;
+
+ @Expose
+ @ConfigOption(name = "Home Hotkey", desc = "Press this key to set your Garden home. §cOnly works while on the garden.")
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE)
+ public int homeHotkey = Keyboard.KEY_NONE;
+
+ @Expose
+ @ConfigOption(name = "Sethome Hotkey", desc = "Press this key to teleport you to your Garden home. §cOnly works while on the garden.")
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE)
+ public int sethomeHotkey = Keyboard.KEY_NONE;
+
+ @Expose
+ @ConfigOption(name = "Barn Hotkey", desc = "Press this key to teleport you to the Garden barn. §cOnly works while on the garden.")
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE)
+ public int barnHotkey = Keyboard.KEY_NONE;
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java
index 13269ad57..5b8485e77 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java
@@ -114,6 +114,11 @@ public class GardenConfig {
public PlotIconConfig plotIcon = new PlotIconConfig();
@Expose
+ @ConfigOption(name = "Garden Commands", desc = "")
+ @Accordion
+ public GardenCommandsConfig gardenCommands = new GardenCommandsConfig();
+
+ @Expose
@ConfigOption(name = "Plot Price", desc = "Show the price of the plot in coins when inside the Configure Plots inventory.")
@ConfigEditorBoolean
@FeatureToggle
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)
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 90970a315..e82ce0da1 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -359,7 +359,7 @@ object LorenzUtils {
}
fun sendMessageToServer(message: String) {
- if (System.currentTimeMillis() > lastMessageSent + 2_000) {
+ if (System.currentTimeMillis() > lastMessageSent + 1_000) {
lastMessageSent = System.currentTimeMillis()
val thePlayer = Minecraft.getMinecraft().thePlayer
thePlayer.sendChatMessage(message)