From 26a844319ba38fa11975aeb237baec9caa0e75e1 Mon Sep 17 00:00:00 2001 From: MichiRecRoom <1008889+LikeLakers2@users.noreply.github.com> Date: Sun, 2 Jun 2024 21:22:51 -0400 Subject: [PATCH] Add a "Kick Player (by ckey)" verb for admins to use (#2124) * Add a "Kick Player (by ckey)" verb for admins to use * Change the tgui alerts in the kick code to regular alerts --- .../~monkestation-helpers/clients.dm | 16 ++++++++++++++++ code/modules/admin/admin_verbs.dm | 1 + code/modules/admin/topic.dm | 10 ++++++++++ .../admin/verbs/kick_player_by_ckey.dm | 19 +++++++++++++++++++ tgstation.dme | 2 ++ 5 files changed, 48 insertions(+) create mode 100644 code/__HELPERS/~monkestation-helpers/clients.dm create mode 100644 monkestation/code/modules/admin/verbs/kick_player_by_ckey.dm diff --git a/code/__HELPERS/~monkestation-helpers/clients.dm b/code/__HELPERS/~monkestation-helpers/clients.dm new file mode 100644 index 000000000000..ea8f6fb6b45f --- /dev/null +++ b/code/__HELPERS/~monkestation-helpers/clients.dm @@ -0,0 +1,16 @@ +/proc/kick_client(client/to_kick) + // Pretty much everything in this proc is copied straight from `code/modules/admin/topic.dm`, + // proc `/datum/admins/Topic()`, href `"boot2"`. If it breaks here, it was probably broken there + // too. + if(!check_rights(R_ADMIN)) + return + if(!to_kick) + to_chat(usr, span_danger("Error: The client you specified has disappeared!"), confidential = TRUE) + return + if(!check_if_greater_rights_than(to_kick)) + to_chat(usr, span_danger("Error: They have more rights than you do."), confidential = TRUE) + return + to_chat(to_kick, span_danger("You have been kicked from the server by [usr.client.holder.fakekey ? "an Administrator" : "[usr.client.key]"]."), confidential = TRUE) + log_admin("[key_name(usr)] kicked [key_name(to_kick)].") + message_admins(span_adminnotice("[key_name_admin(usr)] kicked [key_name_admin(to_kick)].")) + qdel(to_kick) diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 689b585882d6..1412b42594bd 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -47,6 +47,7 @@ GLOBAL_PROTECT(admin_verbs_admin) /datum/admins/proc/view_all_circuits, /datum/admins/proc/open_artifactpanel, /datum/verbs/menu/Admin/verb/playerpanel, /* It isn't /datum/admin but it fits no less */ + /datum/admins/proc/kick_player_by_ckey, //MONKESTATION ADDITION - kick a player by their ckey // Client procs /client/proc/admin_call_shuttle, /*allows us to call the emergency shuttle*/ /client/proc/admin_cancel_shuttle, /*allows us to cancel the emergency shuttle, sending it back to centcom*/ diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 05d71bf4a82c..7a40f7a03d80 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -212,18 +212,28 @@ if(!check_if_greater_rights_than(M.client)) to_chat(usr, span_danger("Error: They have more rights than you do."), confidential = TRUE) return + /* //MONKESTATION EDIT START - Change this tgui alert to a regular alert if(tgui_alert(usr, "Kick [key_name(M)]?", "Confirm", list("Yes", "No")) != "Yes") return + */ //MONKESTATION EDIT ORIGINAL + if(alert(usr, "Kick [key_name(M)]?", "Confirm", "Yes", "No") != "Yes") + return + //MONKESTATION EDIT END if(!M) to_chat(usr, span_danger("Error: [M] no longer exists!"), confidential = TRUE) return if(!M.client) to_chat(usr, span_danger("Error: [M] no longer has a client!"), confidential = TRUE) return + //MONKESTATION EDIT START - Kicking players has been moved to a proc + /* to_chat(M, span_danger("You have been kicked from the server by [usr.client.holder.fakekey ? "an Administrator" : "[usr.client.key]"]."), confidential = TRUE) log_admin("[key_name(usr)] kicked [key_name(M)].") message_admins(span_adminnotice("[key_name_admin(usr)] kicked [key_name_admin(M)].")) qdel(M.client) + */ //MONKESTATION EDIT ORIGINAL + kick_client(M.client) + //MONKESTATION EDIT END else if(href_list["addmessage"]) if(!check_rights(R_ADMIN)) diff --git a/monkestation/code/modules/admin/verbs/kick_player_by_ckey.dm b/monkestation/code/modules/admin/verbs/kick_player_by_ckey.dm new file mode 100644 index 000000000000..c9170b06b468 --- /dev/null +++ b/monkestation/code/modules/admin/verbs/kick_player_by_ckey.dm @@ -0,0 +1,19 @@ +/datum/admins/proc/kick_player_by_ckey() + set name = "Kick Player (by ckey)" + set category = "Admin" + + // Pretty much everything here except the client selection is copied straight from + // `code/modules/admin/topic.dm`, proc `/datum/admins/Topic()`, href `"boot2"`. If it breaks + // here, it was probably broken there too. + if(!check_rights(R_ADMIN)) + return + + var/client/to_kick = input(usr, "Select a ckey to kick.", "Select a ckey") as null|anything in sort_list(GLOB.clients) + if(!to_kick) + return + + var/confirmation = alert(usr, "Kick [key_name(to_kick)]?", "Confirm", "Yes", "No") + if(confirmation != "Yes") + return + + kick_client(to_kick) diff --git a/tgstation.dme b/tgstation.dme index 8d68c36eeb1d..bf6483cc1bb1 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -555,6 +555,7 @@ #include "code\__HELPERS\~monkestation-helpers\announcements.dm" #include "code\__HELPERS\~monkestation-helpers\antags.dm" #include "code\__HELPERS\~monkestation-helpers\atoms.dm" +#include "code\__HELPERS\~monkestation-helpers\clients.dm" #include "code\__HELPERS\~monkestation-helpers\icon_smoothing.dm" #include "code\__HELPERS\~monkestation-helpers\roundend.dm" #include "code\__HELPERS\~monkestation-helpers\time.dm" @@ -5830,6 +5831,7 @@ #include "monkestation\code\modules\admin\smites\dagothstripsmite.dm" #include "monkestation\code\modules\admin\smites\phobia_christian_minecraft.dm" #include "monkestation\code\modules\admin\smites\where_are_your_fingers.dm" +#include "monkestation\code\modules\admin\verbs\kick_player_by_ckey.dm" #include "monkestation\code\modules\aesthetics\airlock\airlock.dm" #include "monkestation\code\modules\aesthetics\items\clothing.dm" #include "monkestation\code\modules\aesthetics\mapping\tilecoloring.dm"