kr.summitsystems.springbukkit.support.paper.PaperTabCompleter.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-bukkit-support Show documentation
Show all versions of spring-bukkit-support Show documentation
Springframework based Bukkit plugin development kit.
package kr.summitsystems.springbukkit.support.paper
import com.destroystokyo.paper.event.server.AsyncTabCompleteEvent
import kr.summitsystems.springbukkit.core.command.CommandTabCompletionProvider
import kr.summitsystems.springbukkit.core.listener.annotation.BukkitListener
class PaperTabCompleter(
private val commandTabCompletionProvider: CommandTabCompletionProvider
) {
@BukkitListener
fun onTabComplete(event: AsyncTabCompleteEvent) {
if (!event.isCommand || event.buffer.indexOf(' ') == -1) {
return
}
val completions = commandTabCompletionProvider.provideTabComplete(event.buffer)
if (completions.isEmpty()) {
return
}
val wrappedCompletions = completions.map { completion ->
AsyncTabCompleteEvent.Completion.completion(completion)
}
event.completions(wrappedCompletions)
event.isHandled = true
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy