Skip to content

Commit

Permalink
feat: add suggestion-methods with tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Oct 13, 2024
1 parent 034e064 commit e66da09
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mineinabyss.idofront.commands.brigadier

import com.mojang.brigadier.Message
import com.mojang.brigadier.context.CommandContext
import com.mojang.brigadier.suggestion.SuggestionsBuilder
import io.papermc.paper.command.brigadier.CommandSourceStack
Expand All @@ -20,19 +21,61 @@ data class IdoSuggestionsContext(
suggestions.suggest(name)
}

/** Add a suggestion with a tooltip */
fun suggest(name: String, tooltip: () -> String) {
suggestions.suggest(name, tooltip)
}

/** Add a suggestion with a tooltip */
fun suggest(name: String, tooltip: Message) {
suggestions.suggest(name, tooltip)
}

/** Add a list of suggestions. */
fun suggest(list: List<String>) {
list.forEach { suggest(it) }
}

/** Add a list of suggestions with a tooltip. */
fun suggest(list: List<String>, tooltip: () -> String) {
list.forEach { suggest(it, tooltip) }
}

/** Add a list of suggestions with a tooltip. */
fun suggest(list: List<String>, tooltip: Message) {
list.forEach { suggest(it, tooltip) }
}

/** Add a suggestion, filtering it as the user types. */
fun suggestFiltering(name: String) {
if (name.startsWith(argument, ignoreCase = true))
suggest(name)
}

/** Add a suggestion with a tooltip, filtering it as the user types. */
fun suggestFiltering(name: String, tooltip: () -> String) {
if (name.startsWith(argument, ignoreCase = true))
suggest(name, tooltip)
}

/** Add a suggestion with a tooltip, filtering it as the user types. */
fun suggestFiltering(name: String, tooltip: Message) {
if (name.startsWith(argument, ignoreCase = true))
suggest(name, tooltip)
}

/** Add a list of suggestions, filtering them as the user types. */
fun suggestFiltering(list: List<String>) {
list.forEach { suggestFiltering(it) }
}

/** Add a list of suggestions with a tooltip, filtering them as the user types. */
fun suggestFiltering(list: List<String>, tooltip: () -> String) {
list.forEach { suggestFiltering(it, tooltip) }
}

/** Add a list of suggestions with a tooltip, filtering them as the user types. */
fun suggestFiltering(list: List<String>, tooltip: Message) {
list.forEach { suggestFiltering(it, tooltip) }
}
}

0 comments on commit e66da09

Please sign in to comment.