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

kr.summitsystems.springbukkit.command.convert.support.PlayerCommandArgumentConverter.kt Maven / Gradle / Ivy

The newest version!
package kr.summitsystems.springbukkit.command.convert.support

import kr.summitsystems.springbukkit.command.CommandArgument
import kr.summitsystems.springbukkit.command.convert.CommandArgumentConverter
import org.bukkit.Server
import org.bukkit.entity.Player

class PlayerCommandArgumentConverter(private val server: Server) : CommandArgumentConverter {
    override fun provideCompletes(): Collection {
        return server.onlinePlayers.map { player ->
            player.name
        }
    }

    override fun convert(source: CommandArgument): Player {
        val value = source.value
        return server.onlinePlayers.single { player ->
            player.name == value
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy