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>
andBaseComponent
without loosing events and formatting on concatenations - Added
Plugin.register(listener)
, a shortcut toplugin.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)
andPlugin.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())
}