aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/commands
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-04-28 12:16:58 +0200
committerGitHub <noreply@github.com>2024-04-28 12:16:58 +0200
commitcf72b7981903814f1a6afb5c1f9edcb9e1b7024a (patch)
tree363cd8446b98eb11f21ed76369bb8039c84419ff /src/main/java/at/hannibal2/skyhanni/features/commands
parent7467e9f16f84f7e1f77b5a91914c54d3a34c5097 (diff)
downloadskyhanni-cf72b7981903814f1a6afb5c1f9edcb9e1b7024a.tar.gz
skyhanni-cf72b7981903814f1a6afb5c1f9edcb9e1b7024a.tar.bz2
skyhanni-cf72b7981903814f1a6afb5c1f9edcb9e1b7024a.zip
Fix party tab completion (#1571)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/commands')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt2
-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
3 files changed, 13 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt
index 5196b08db..b323bb73d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt
@@ -90,7 +90,7 @@ object PartyCommands {
if (command == "p" || command == "party") {
val friends = if (config.tabComplete.friends) {
- FriendAPI.getAllFriends().filter { it.bestFriend || config.tabComplete.onlyBestFriends }.map { it.name }
+ FriendAPI.getAllFriends().filter { it.bestFriend || !config.tabComplete.onlyBestFriends }.map { it.name }
} else {
emptyList<String>()
}
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