It's a plugin for a Spigot Minecraft server to log the time players spend on the server and returns it to them.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

41 lines
1.2 KiB

import commands.PlayTime
import commands.TestCommand
import commands.UpTime
import db.FilePlayerTimeDB
import listener.JoinListener
import listener.QuitListener
import org.bukkit.plugin.java.JavaPlugin
/**
* Entrypoint of the plugin
*
* @property playerService A singleton of the playerService with FilePlayerTimeDB
*/
class Main : JavaPlugin() {
private val playerService = PlayerService(FilePlayerTimeDB())
/**
* Gets executed when ever the server starts
* Sets the command executors and registers the event handlers
*/
override fun onEnable() {
super.onEnable()
this.getCommand("test")?.setExecutor(TestCommand())
this.getCommand("playtime")?.setExecutor(PlayTime(playerService))
this.getCommand("uptime")?.setExecutor(UpTime())
server.pluginManager.registerEvents(JoinListener(playerService), this)
server.pluginManager.registerEvents(QuitListener(playerService), this)
}
/**
* Gets executed when ever the server gets properly shutdown
* It saves all stats to the db
*/
override fun onDisable() {
super.onDisable()
playerService.persistAllPlayer()
}
}