aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/io/github
diff options
context:
space:
mode:
authorNopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com>2024-08-04 00:23:44 +1000
committerGitHub <noreply@github.com>2024-08-04 00:23:44 +1000
commite41c1694d0c6bd47f35ebcb8bdd3492d686559bc (patch)
tree1b88addb0c5b50162300690ed712261002836bd8 /src/main/kotlin/io/github
parentd8e03fcbf5ae144f62c376a838a06b21afe2365c (diff)
downloadnotenoughupdates-e41c1694d0c6bd47f35ebcb8bdd3492d686559bc.tar.gz
notenoughupdates-e41c1694d0c6bd47f35ebcb8bdd3492d686559bc.tar.bz2
notenoughupdates-e41c1694d0c6bd47f35ebcb8bdd3492d686559bc.zip
Add client side ah/bz search guis (#1248)
Co-authored-by: Lulonaut <lulonaut@lulonaut.dev>
Diffstat (limited to 'src/main/kotlin/io/github')
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/SearchCommand.kt74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/SearchCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/SearchCommand.kt
new file mode 100644
index 00000000..9af9a097
--- /dev/null
+++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/SearchCommand.kt
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2024 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.commands.misc
+
+import com.mojang.brigadier.arguments.StringArgumentType
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates
+import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe
+import io.github.moulberry.notenoughupdates.events.RegisterBrigadierCommandEvent
+import io.github.moulberry.notenoughupdates.overlays.AuctionSearchOverlay
+import io.github.moulberry.notenoughupdates.overlays.BazaarSearchOverlay
+import io.github.moulberry.notenoughupdates.util.brigadier.RestArgumentType
+import io.github.moulberry.notenoughupdates.util.brigadier.get
+import io.github.moulberry.notenoughupdates.util.brigadier.thenArgumentExecute
+import io.github.moulberry.notenoughupdates.util.brigadier.thenExecute
+import io.github.moulberry.notenoughupdates.util.brigadier.withHelp
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+@NEUAutoSubscribe
+class SearchCommand {
+ @SubscribeEvent
+ fun onCommands(event: RegisterBrigadierCommandEvent) {
+ event.command("bzs") {
+ thenArgumentExecute("search", StringArgumentType.string()) { search ->
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/bz ${this[search]}")
+ }.withHelp("Search directly without opening the GUI")
+ thenExecute {
+ NotEnoughUpdates.INSTANCE.openGui = BazaarSearchOverlay()
+ }
+ }.withHelp("Search the bazaar directly with a custom search GUI")
+ event.command("ahs") {
+ thenArgumentExecute("search", StringArgumentType.string()) { search ->
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/ahs ${this[search]}")
+ }.withHelp("Search directly without opening the GUI")
+ thenExecute {
+ NotEnoughUpdates.INSTANCE.openGui = AuctionSearchOverlay()
+ }
+ }.withHelp("Search the auction house directly with a custom search GUI")
+ event.command("ah") {
+ thenArgumentExecute("search", RestArgumentType) { search ->
+ val searchString = this[search]
+ if (!NotEnoughUpdates.INSTANCE.config.ahTweaks.convertSearchCommand) {
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/ah $searchString")
+ return@thenArgumentExecute
+ }
+ val split = searchString.split(" ")
+ if (split.size > 1) {
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/ahs $searchString")
+ } else {
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/ah $searchString")
+ }
+ }
+ thenExecute {
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/ah")
+ }
+ }
+ }
+}