Skip to content

Commit

Permalink
Develop (#137)
Browse files Browse the repository at this point in the history
* fix typo

* change minecraft player api respond body
  • Loading branch information
xiaoyv404 authored Mar 24, 2024
1 parent cd7e0b4 commit e5538fc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ISU : NfApp(), IFshApp {

override fun getAppDescription() = "我的世界玩家状态监控"

override fun getCommands() = arrayOf("-玩家状态", "-有妖怪在线吗", "-桃呢", "-有无妖怪", "-有妖怪在线吗")
override fun getCommands() = arrayOf("-玩家状态", "-有妖怪在线吗", "-桃呢", "-有无妖怪", "-有妖怪在吗")

override fun getOptions() = NfOptions().apply {
addOption("m", "more", false, "获取更多信息")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,31 @@ fun Route.player() {
val data = MinecraftServerPlayer {
this.id = id
}.findById() ?: error(WebApi.requestError)
call.respond(NfResult.success(data))
val apiModel = data.let {
MinecraftPlayerApiModel(
it.name,
it.id,
it.lastLoginTime.toString(),
it.lastLoginServer,
it.permissions
)
}
call.respond(NfResult.success(apiModel))
}

get("/players/search") {
val name = call.request.queryParameters["name"] ?: error(WebApi.requestError)
val data = MinecraftServerPlayer {
this.name = name
}.findByName()
}.findByName().map {
MinecraftPlayerApiModel(
it.name,
it.id,
it.lastLoginTime.toString(),
it.lastLoginServer,
it.permissions
)
}
call.respond(NfResult.success(data))
}
get("/players/online") {
Expand Down

0 comments on commit e5538fc

Please sign in to comment.