Skip to content

Releases: GameModsBR/KotlinFun

0.2

22 Oct 05:59
Compare
Choose a tag to compare
0.2 Pre-release
Pre-release
  • Added a player data API to Bukkit and Bungee
  • Extended the Bukkit's Metadatable API
  • Added conversion methods between Bungee's and Bukkit's ChatColor
  • Added Spigot support, it inherits and improves all Bukkit's features, it also has some additional features
  • Added support to Bungee's ChatComponent to BungeeCord and Spigot
  • Extended the Chat API to support Array<out BaseComponent> and BaseComponent without loosing events and formatting on concatenations
  • Added Plugin.register(listener), a shortcut to plugin.server.pluginManager.register(listener) and the equivalent on BungeeCord, it can take multiple listeners to register them all at the same time
  • Added Plugin.unregister(listener) and Plugin.unregisterListeners() to BungeeCord

Example usage:

class MyNicePlugin : JavaPlugin() {
    companion object {
        lateinit var instance : MyNicePlugin
    }

    override fun onEnable() {
        instance = this
    }

    override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
        sender as? Player ?: return false
        if(command.name == "silly") {
            val data = SillyPlayerData[sender] ?: return false
            data.silly = !data.silly
            data.tellHim()
            return true
        }
        else {
            return false
        }
    }
}

class SillyPlayerData(player: OfflinePlayer) : PlayerData(player) {
    companion object : AutoDataCompanion<SillyPlayerData>(MyNicePlugin.instance, "SillyPlayer",
            SillyPlayerData::class.java, ::SillyPlayerData
    )

    var silly = false

    fun tellHim() = player?.sendMessage((if(silly) "You are silly!".red() else "You are not silly :)".green()).str())
}

0.1

20 Oct 15:37
Compare
Choose a tag to compare
0.1 Pre-release
Pre-release
  • Provides Kotlin libraries in runtime for others plugins
  • Allows ChatColors to concatenate, example: ChatColor.RED + ChatColor.BOLD + "Red and bold"
  • Simplified color API using extension methods: "Red, bold".red().bold()+" and italic".italic()
  • Any?.str() will return an empty string instead of a "null" text when the variable is null