Added event handling
This commit is contained in:
parent
209e5e7f81
commit
9f4d25e90f
@ -1,6 +1,8 @@
|
||||
package de.sh_edraft
|
||||
|
||||
import de.sh_edraft.config.Config
|
||||
import de.sh_edraft.events.OnJoinListener
|
||||
import de.sh_edraft.events.OnLeaveListener
|
||||
import org.bukkit.plugin.java.JavaPlugin
|
||||
|
||||
open class OntimeHandlerPlugin() : JavaPlugin() {
|
||||
@ -12,6 +14,10 @@ open class OntimeHandlerPlugin() : JavaPlugin() {
|
||||
this.config.read("/config.properties", false)
|
||||
this.config.read("/config.${this.config.environment}.properties", true)
|
||||
this.config.read("/config.${this.config.hostName}.properties", true)
|
||||
|
||||
server.pluginManager.registerEvents(OnJoinListener(logger), this)
|
||||
server.pluginManager.registerEvents(OnLeaveListener(logger), this)
|
||||
|
||||
logger.info("OntimeHandlerPlugin enabled :D")
|
||||
}
|
||||
|
||||
|
13
src/main/kotlin/de/sh_edraft/events/OnJoinListener.kt
Normal file
13
src/main/kotlin/de/sh_edraft/events/OnJoinListener.kt
Normal file
@ -0,0 +1,13 @@
|
||||
package de.sh_edraft.events
|
||||
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.player.PlayerJoinEvent
|
||||
import java.util.logging.Logger
|
||||
|
||||
class OnJoinListener(private val logger: Logger) : Listener {
|
||||
@EventHandler
|
||||
fun onPlayerJoin(p: PlayerJoinEvent) {
|
||||
logger.info("Player ${p.player.player?.displayName} joined")
|
||||
}
|
||||
}
|
25
src/main/kotlin/de/sh_edraft/events/OnLeaveListener.kt
Normal file
25
src/main/kotlin/de/sh_edraft/events/OnLeaveListener.kt
Normal file
@ -0,0 +1,25 @@
|
||||
package de.sh_edraft.events
|
||||
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.player.PlayerEvent
|
||||
import org.bukkit.event.player.PlayerKickEvent
|
||||
import org.bukkit.event.player.PlayerQuitEvent
|
||||
import java.util.logging.Logger
|
||||
|
||||
class OnLeaveListener(private val logger: Logger) : Listener {
|
||||
|
||||
private fun handleQuit(p: PlayerEvent) {
|
||||
this.logger.info("Player ${p.player.player?.displayName} leaved")
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
fun onPlayerQuit(p: PlayerQuitEvent) {
|
||||
this.handleQuit(p)
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
fun onPlayerKick(p: PlayerKickEvent) {
|
||||
this.handleQuit(p)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user