All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kr.summitsystems.springbukkit.support.paper.PaperTabCompleter.kt Maven / Gradle / Ivy

There is a newer version: 0.0.9-beta2
Show newest version
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