File tree Expand file tree Collapse file tree 3 files changed +39
-6
lines changed
src/main/kotlin/cc/modlabs/kpaper Expand file tree Collapse file tree 3 files changed +39
-6
lines changed Original file line number Diff line number Diff line change 1+ package cc.modlabs.kpaper.game
2+
3+ import org.bukkit.entity.Player
4+
5+ interface GamePlayers {
6+
7+ var livingPlayers: MutableList <Player >
8+
9+ var spectators: MutableList <Player >
10+ }
Original file line number Diff line number Diff line change 1+ package cc.modlabs.kpaper.game.countdown
2+
3+ import cc.modlabs.kpaper.game.GamePlayers
4+ import org.bukkit.scheduler.BukkitTask
5+
6+ abstract class Countdown (val game : GamePlayers , val defaultDuration : Int ) {
7+
8+ var duration: Int = defaultDuration
9+
10+
11+ lateinit var countdown: BukkitTask
12+ abstract fun start ()
13+
14+ abstract fun stop ()
15+ }
Original file line number Diff line number Diff line change 11package cc.modlabs.kpaper.utils
22
33import com.google.gson.Gson
4+ import kotlinx.coroutines.CoroutineScope
5+ import kotlinx.coroutines.Dispatchers
46import java.net.URI
57
68class MojangAPI {
79 private val gson = Gson ()
810
911 fun getUser (user : String ): MclSuccessResponse ? {
10- val url = " https://mcl.flawcra.cc/$user "
11- val response = URI .create(url).toURL().readText()
12+ try {
13+ CoroutineScope (Dispatchers .Default ).run {
14+ val url = " https://mcl.flawcra.cc/$user "
15+ val response = URI .create(url).toURL().readText()
1216
13- val errorResponse = gson.fromJson(response, MclErrorResponse ::class .java)
14- if (errorResponse.error != null ) {
17+ val errorResponse = gson.fromJson(response, MclErrorResponse ::class .java)
18+ if (errorResponse.error != null ) {
19+ return null
20+ }
21+
22+ return gson.fromJson(response, MclSuccessResponse ::class .java)
23+ }
24+ } catch (e: Exception ) {
1525 return null
1626 }
17-
18- return gson.fromJson(response, MclSuccessResponse ::class .java)
1927 }
2028}
2129
You can’t perform that action at this time.
0 commit comments