Skip to content

Commit c3a179c

Browse files
author
pybsh
committed
✨ Add pardon player
1 parent cb1cf98 commit c3a179c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/main/kotlin/cc/dashify/plugin/manager/PlayerManager.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.google.gson.Gson
66
import io.ktor.http.*
77
import io.sentry.Sentry
88
import net.kyori.adventure.text.Component.text
9+
import org.bukkit.BanList
910
import java.util.*
1011

1112
/**
@@ -33,6 +34,14 @@ object PlayerManager {
3334
}
3435
)
3536

37+
if (type == "pardon") {
38+
val banlist = plugin.server.getBanList(BanList.Type.NAME)
39+
if(!banlist.isBanned(uuid.toString()))
40+
return Pair(HttpStatusCode.BadRequest, map.apply { this["error"] = "Player not banned" })
41+
banlist.pardon(uuid.toString())
42+
return Pair(HttpStatusCode.OK, map.apply { this["statusCode"] = HttpStatusCode.OK })
43+
}
44+
3645
val player = plugin.server.getPlayer(uuid)
3746
?: return Pair(
3847
HttpStatusCode.BadRequest,

src/main/kotlin/cc/dashify/plugin/router/Dashify.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ fun Application.dashify() {
9292
val (status, result) = PlayerManager.managePlayer("ban", call.parameters["uuid"]!!, call.receiveText())
9393
call.respond(status as HttpStatusCode, result)
9494
}
95+
post("/players/{uuid}/pardon"){
96+
if(isAuthorized(call)) { return@post }
97+
98+
val (status, result) = PlayerManager.managePlayer("pardon", call.parameters["uuid"]!!, call.receiveText())
99+
call.respond(status as HttpStatusCode, result)
100+
}
95101

96102
get("/stats") {
97103
if(isAuthorized(call)) { return@get }

0 commit comments

Comments
 (0)