forked from chanbakjsd/TerraOceanPlugin
kotlin: query user, kickall on WS fail, rename Strings class, and handle sync command
parent
0cb7f55d63
commit
e9d5730300
@ -1,10 +0,0 @@
|
|||||||
package com.terraocean.plugin.bridge
|
|
||||||
|
|
||||||
import com.terraocean.plugin.instance
|
|
||||||
import hazae41.minecraft.kutils.bukkit.schedule
|
|
||||||
|
|
||||||
fun reportPlayerActivity(username: String, activity: Long) {
|
|
||||||
instance.schedule(async = true) {
|
|
||||||
socket.send("active $username $activity")
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.terraocean.plugin.bridge
|
||||||
|
|
||||||
|
import com.terraocean.plugin.instance
|
||||||
|
import hazae41.minecraft.kutils.bukkit.schedule
|
||||||
|
|
||||||
|
fun queryUserJoin(username: String) {
|
||||||
|
sendToSocket("query $username")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun reportPlayerActivity(username: String, activity: Long) {
|
||||||
|
sendToSocket("active $username $activity")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun sendToSocket(msg: String) {
|
||||||
|
if (!socketActive) return
|
||||||
|
instance.schedule(async = true) { socket.send(msg) }
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.terraocean.plugin.afk
|
package com.terraocean.plugin.listeners
|
||||||
|
|
||||||
import com.terraocean.plugin.bridge.reportPlayerActivity
|
import com.terraocean.plugin.bridge.reportPlayerActivity
|
||||||
import org.bukkit.event.player.PlayerMoveEvent
|
import org.bukkit.event.player.PlayerMoveEvent
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.terraocean.plugin.listeners
|
||||||
|
|
||||||
|
import com.terraocean.plugin.Messages
|
||||||
|
import com.terraocean.plugin.bridge.socketActive
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent
|
||||||
|
|
||||||
|
fun onPlayerJoin(e: PlayerJoinEvent) {
|
||||||
|
if (!socketActive) {
|
||||||
|
e.player.kickPlayer(Messages.botConnectionLost)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.terraocean.plugin.listeners
|
||||||
|
|
||||||
|
import com.terraocean.plugin.bridge.queryUserJoin
|
||||||
|
import org.bukkit.event.player.AsyncPlayerPreLoginEvent
|
||||||
|
|
||||||
|
fun onPlayerPreLogin(e: AsyncPlayerPreLoginEvent) {
|
||||||
|
queryUserJoin(e.name)
|
||||||
|
}
|
Loading…
Reference in New Issue