diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
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 |