aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-04-27 23:20:32 +0200
committerLinnea Gräf <nea@nea.moe>2024-04-27 23:20:32 +0200
commitd6fa330744ba2640bd0841fecf741f0971679e99 (patch)
tree01fc6740962ea6d6ed600279bb2155db58c02346 /src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete
parenta7d2a2c0346b864ea597300ed4eb9d024457e8b7 (diff)
downloadSkyHanni-tabcompletionapi.tar.gz
SkyHanni-tabcompletionapi.tar.bz2
SkyHanni-tabcompletionapi.zip
Fix party tab completiontabcompletionapi
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt11
2 files changed, 12 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt
index a835efd38..49bde5993 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt
@@ -1,29 +1,29 @@
package at.hannibal2.skyhanni.features.commands.tabcomplete
+import at.hannibal2.skyhanni.events.TabCompletionEvent
import at.hannibal2.skyhanni.features.commands.PartyCommands
import at.hannibal2.skyhanni.features.commands.ViewRecipeCommand
import at.hannibal2.skyhanni.features.misc.CollectionTracker
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object TabComplete {
- @JvmStatic
- fun handleTabComplete(leftOfCursor: String, originalArray: Array<String>): Array<String>? {
- val splits = leftOfCursor.split(" ")
+ @SubscribeEvent
+ fun handleTabComplete(event: TabCompletionEvent) {
+ val splits = event.leftOfCursor.split(" ")
if (splits.size > 1) {
var command = splits.first().lowercase()
if (command.startsWith("/")) {
command = command.substring(1)
customTabComplete(command)?.let {
- return buildResponse(splits, it).toSet().toTypedArray()
+ event.addSuggestions(it)
}
}
}
- return null
}
private fun customTabComplete(command: String): List<String>? {
GetFromSacksTabComplete.handleTabComplete(command)?.let { return it }
- WarpTabComplete.handleTabComplete(command)?.let { return it }
PlayerTabComplete.handleTabComplete(command)?.let { return it }
CollectionTracker.handleTabComplete(command)?.let { return it }
PartyCommands.customTabComplete(command)?.let { return it }
diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt
index 4651040b8..4520aee09 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.commands.tabcomplete
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.jsonobjects.repo.WarpsJson
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.events.TabCompletionEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -17,11 +18,11 @@ object WarpTabComplete {
warps = data.warpCommands
}
- fun handleTabComplete(command: String): List<String>? {
- if (!isEnabled()) return null
- if (command != "warp") return null
-
- return warps
+ @SubscribeEvent
+ fun onTabComplete(event: TabCompletionEvent) {
+ if (event.isCommand("warp")) {
+ event.addSuggestions(warps)
+ }
}
fun isEnabled() = LorenzUtils.inSkyBlock && config.warps