mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 21:18:37 +01:00
[MODULAR] Adds Manage Player Ranks verb (#7581)
* Adds Manage Player Ranks verb It works for Donators, Mentors and Veterans so far, and it shouldn't be too hard to add some more. * Adds a temporary Cancel button while waiting for /tg/ to add optional X button to tgui_alert * Funny copy-paste moment
This commit is contained in:
@@ -210,7 +210,12 @@ GLOBAL_PROTECT(admin_verbs_debug)
|
||||
)
|
||||
GLOBAL_LIST_INIT(admin_verbs_possess, list(/proc/possess, /proc/release))
|
||||
GLOBAL_PROTECT(admin_verbs_possess)
|
||||
GLOBAL_LIST_INIT(admin_verbs_permissions, list(/client/proc/edit_admin_permissions))
|
||||
/// SKYRAT EDIT BEGIN - Player Rank Manager - ORIGINAL: GLOBAL_LIST_INIT(admin_verbs_permissions, list(/client/proc/edit_admin_permissions))
|
||||
GLOBAL_LIST_INIT(admin_verbs_permissions, list(
|
||||
/client/proc/edit_admin_permissions,
|
||||
/client/proc/manage_player_ranks
|
||||
))
|
||||
/// SKYRAT EDIT END
|
||||
GLOBAL_PROTECT(admin_verbs_permissions)
|
||||
GLOBAL_LIST_INIT(admin_verbs_poll, list(/client/proc/poll_panel))
|
||||
GLOBAL_PROTECT(admin_verbs_poll)
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/// The defines for the appropriate config files
|
||||
#define SKYRAT_DONATOR_CONFIG_FILE "[global.config.directory]/skyrat/donators.txt"
|
||||
#define SKYRAT_MENTOR_CONFIG_FILE "[global.config.directory]/skyrat/mentors.txt"
|
||||
#define SKYRAT_VETERAN_CONFIG_FILE "[global.config.directory]/skyrat/veteran_players.txt"
|
||||
|
||||
/// The list of the available special player ranks
|
||||
#define SKYRAT_PLAYER_RANKS list("Donator", "Mentor", "Veteran")
|
||||
|
||||
/client/proc/manage_player_ranks()
|
||||
set category = "Admin"
|
||||
set name = "Manage Player Ranks"
|
||||
set desc = "Manage who has the special player ranks while the server is running."
|
||||
if(!check_rights(R_PERMISSIONS))
|
||||
return
|
||||
usr.client.holder.manage_player_ranks()
|
||||
|
||||
/// Proc for admins to change people's "player" ranks (donator, mentor, veteran, etc.)
|
||||
/datum/admins/proc/manage_player_ranks()
|
||||
if(!check_rights(R_PERMISSIONS))
|
||||
return
|
||||
|
||||
var/choice = tgui_alert(usr, "Which rank would you like to manage?", "Manage Player Ranks", SKYRAT_PLAYER_RANKS+"Cancel")
|
||||
if(!choice || !(choice in SKYRAT_PLAYER_RANKS))
|
||||
return
|
||||
|
||||
manage_player_rank_in_group(choice)
|
||||
|
||||
/// Proc that helps a bit with repetition, basically an extension of `manage_player_ranks()`
|
||||
/datum/admins/proc/manage_player_rank_in_group(group)
|
||||
if(!(group in SKYRAT_PLAYER_RANKS))
|
||||
CRASH("[key_name(usr)] attempted to add someone to an invalid \"[group]\" group.")
|
||||
|
||||
var/group_title = lowertext(group)
|
||||
|
||||
var/list/choices = list("Add", "Remove")
|
||||
switch(tgui_alert(usr, "What would you like to do?", "Manage [group]s", choices))
|
||||
if("Add")
|
||||
var/name = input(usr, "Please enter the CKEY (case-insensitive) of the person you would like to make a [group_title]:", "Add a [group_title]") as null|text
|
||||
if(!name)
|
||||
return
|
||||
|
||||
var/player_to_be = ckey(name)
|
||||
if(!player_to_be)
|
||||
to_chat(usr, span_warning("\"[name]\" is not a valid CKEY."))
|
||||
return
|
||||
|
||||
switch(group)
|
||||
if ("Donator")
|
||||
for(var/a_donator as anything in GLOB.donator_list)
|
||||
if(player_to_be == a_donator)
|
||||
to_chat(usr, span_warning("\"[player_to_be]\" is already a [group_title]!"))
|
||||
return
|
||||
// Now that we know that the ckey is valid and they're not already apart of that group, let's add them to it!
|
||||
GLOB.donator_list[player_to_be] = TRUE
|
||||
text2file(player_to_be, SKYRAT_DONATOR_CONFIG_FILE)
|
||||
|
||||
if("Mentor")
|
||||
for(var/a_mentor as anything in GLOB.mentor_datums)
|
||||
if(player_to_be == a_mentor)
|
||||
to_chat(usr, span_warning("\"[player_to_be]\" is already a [group_title]!"))
|
||||
return
|
||||
// Now that we know that the ckey is valid and they're not already apart of that group, let's add them to it!
|
||||
new /datum/mentors(player_to_be)
|
||||
text2file(player_to_be, SKYRAT_MENTOR_CONFIG_FILE)
|
||||
|
||||
if ("Veteran")
|
||||
for(var/a_veteran as anything in GLOB.veteran_players)
|
||||
if(player_to_be == a_veteran)
|
||||
to_chat(usr, span_warning("\"[player_to_be]\" is already a [group_title]!"))
|
||||
return
|
||||
// Now that we know that the ckey is valid and they're not already apart of that group, let's add them to it!
|
||||
GLOB.veteran_players[player_to_be] = TRUE
|
||||
text2file(player_to_be, SKYRAT_VETERAN_CONFIG_FILE)
|
||||
|
||||
else
|
||||
return
|
||||
|
||||
message_admins("[key_name(usr)] has granted [group_title] status to [player_to_be].")
|
||||
log_admin_private("[key_name(usr)] has granted [group_title] status to [player_to_be].")
|
||||
|
||||
|
||||
if("Remove")
|
||||
var/name = input(usr, "Please enter the CKEY (case-insensitive) of the person you would like to no longer be a [group_title]:", "Remove a [group_title]") as null|text
|
||||
if(!name)
|
||||
return
|
||||
|
||||
var/player_that_was = ckey(name)
|
||||
if(!player_that_was)
|
||||
to_chat(usr, span_warning("\"[name]\" is not a valid CKEY."))
|
||||
return
|
||||
|
||||
var/changes = FALSE
|
||||
switch(group)
|
||||
if ("Donator")
|
||||
for(var/a_donator as anything in GLOB.donator_list)
|
||||
if(player_that_was == a_donator)
|
||||
GLOB.donator_list -= player_that_was
|
||||
changes = TRUE
|
||||
if(!changes)
|
||||
to_chat(usr, span_warning("\"[player_that_was]\" was already not a [group_title]."))
|
||||
return
|
||||
save_donators()
|
||||
|
||||
if("Mentor")
|
||||
for(var/a_mentor as anything in GLOB.mentor_datums)
|
||||
if(player_that_was == a_mentor)
|
||||
var/datum/mentors/mentor_datum = GLOB.mentor_datums[a_mentor]
|
||||
mentor_datum.remove_mentor()
|
||||
changes = TRUE
|
||||
if(!changes)
|
||||
to_chat(usr, span_warning("\"[player_that_was]\" was already not a [group_title]."))
|
||||
save_mentors()
|
||||
|
||||
if("Veteran")
|
||||
for(var/a_veteran as anything in GLOB.veteran_players)
|
||||
if(player_that_was == a_veteran)
|
||||
GLOB.veteran_players -= player_that_was
|
||||
changes = TRUE
|
||||
if(!changes)
|
||||
to_chat(usr, span_warning("\"[player_that_was]\" was already not a [group_title]."))
|
||||
return
|
||||
save_veteran_players()
|
||||
|
||||
else
|
||||
return
|
||||
message_admins("[key_name(usr)] has revoked [group_title] status from [player_that_was].")
|
||||
log_admin_private("[key_name(usr)] has revoked [group_title] status from [player_that_was].")
|
||||
|
||||
else
|
||||
return
|
||||
|
||||
#undef SKYRAT_DONATOR_CONFIG_FILE
|
||||
#undef SKYRAT_MENTOR_CONFIG_FILE
|
||||
#undef SKYRAT_VETERAN_CONFIG_FILE
|
||||
#undef SKYRAT_PLAYER_RANKS
|
||||
@@ -11,4 +11,11 @@ GLOBAL_LIST(donator_list)
|
||||
continue
|
||||
GLOB.donator_list[ckey(line)] = TRUE //Associative so we can check it much faster
|
||||
|
||||
/proc/save_donators()
|
||||
/// Yes, this is incredibly long, deal with it. It's to keep that cute little comment at the top.
|
||||
var/donators = "###############################################################################################\n# List for people who support us! They get cool loadout items #\n# Case is not important for ckey. #\n###############################################################################################\n"
|
||||
for(var/donator in GLOB.donator_list)
|
||||
donators += donator + "\n"
|
||||
rustg_file_write(donators, DONATORLISTFILE)
|
||||
|
||||
#undef DONATORLISTFILE
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#define SKYRAT_MENTOR_CONFIG_FILE "[global.config.directory]/skyrat/mentors.txt"
|
||||
|
||||
GLOBAL_LIST_EMPTY(mentor_datums)
|
||||
GLOBAL_PROTECT(mentor_datums)
|
||||
|
||||
GLOBAL_VAR_INIT(mentor_href_token, GenerateToken())
|
||||
GLOBAL_PROTECT(mentor_href_token)
|
||||
|
||||
//#define SKYRAT_MENTOR_CONFIG_FILE "[global.config.directory]/skyrat/mentors.txt"
|
||||
|
||||
/datum/mentors
|
||||
var/name = "someone's mentor datum"
|
||||
var/client/owner // the actual mentor, client type
|
||||
@@ -27,6 +31,16 @@ GLOBAL_PROTECT(mentor_href_token)
|
||||
if(!check_rights_for(owner, R_ADMIN,0)) // don't add admins to mentor list.
|
||||
GLOB.mentors[owner] = TRUE
|
||||
|
||||
/datum/mentors/proc/remove_mentor()
|
||||
if(owner)
|
||||
owner.remove_mentor_verbs()
|
||||
GLOB.mentors -= owner
|
||||
owner.mentor_datum = null
|
||||
owner = null
|
||||
log_admin_private("[target] was removed from the rank of mentor.")
|
||||
GLOB.mentor_datums -= target
|
||||
qdel(src)
|
||||
|
||||
/datum/mentors/proc/CheckMentorHREF(href, href_list)
|
||||
var/auth = href_list["mentor_token"]
|
||||
. = auth && (auth == href_token || auth == GLOB.mentor_href_token)
|
||||
@@ -59,13 +73,13 @@ GLOBAL_PROTECT(mentor_href_token)
|
||||
/proc/load_mentors()
|
||||
usr = null
|
||||
GLOB.mentor_datums.Cut()
|
||||
for(var/it in GLOB.mentors)
|
||||
for(var/it as anything in GLOB.mentors)
|
||||
var/client/C = it
|
||||
C.remove_mentor_verbs()
|
||||
C.mentor_datum = null
|
||||
GLOB.mentors.Cut()
|
||||
//if(CONFIG_GET(flag/mentor_legacy_system))//legacy
|
||||
var/list/lines = world.file2list("config/skyrat/mentors.txt")
|
||||
var/list/lines = world.file2list(SKYRAT_MENTOR_CONFIG_FILE)
|
||||
for(var/line in lines)
|
||||
if(!length(line))
|
||||
continue
|
||||
@@ -86,6 +100,34 @@ GLOBAL_PROTECT(mentor_href_token)
|
||||
var/ckey = ckey(query_load_mentors.item[1])
|
||||
new /datum/mentors(ckey)*/
|
||||
|
||||
/// Proc to save the current mentor list into the config, overwriting it.
|
||||
/proc/save_mentors()
|
||||
usr = null
|
||||
var/mentor_list = ""
|
||||
|
||||
// This whole mess is just to create a cache of all the mentors that were in the config already
|
||||
// so that we don't add every admin to the list, which would be a pain to maintain afterwards.
|
||||
var/list/existing_mentor_config = world.file2list(SKYRAT_MENTOR_CONFIG_FILE)
|
||||
var/list/existing_mentors = list()
|
||||
for(var/line in existing_mentor_config)
|
||||
if(!length(line))
|
||||
continue
|
||||
if(findtextEx(line, "#", 1, 2))
|
||||
continue
|
||||
var/existing_mentor = ckey(line)
|
||||
if(!existing_mentor)
|
||||
continue
|
||||
existing_mentors[existing_mentor] = TRUE
|
||||
|
||||
for(var/mentor as anything in GLOB.mentor_datums)
|
||||
// We're doing this check to not add admins to the file, as explained above.
|
||||
if(existing_mentors[mentor] == TRUE)
|
||||
mentor_list += mentor + "\n"
|
||||
rustg_file_write(mentor_list, SKYRAT_MENTOR_CONFIG_FILE)
|
||||
|
||||
|
||||
// new client var: mentor_datum. Acts the same way holder does towards admin: it holds the mentor datum. if set, the guy's a mentor.
|
||||
/client
|
||||
var/datum/mentors/mentor_datum
|
||||
|
||||
#undef SKYRAT_MENTOR_CONFIG_FILE
|
||||
|
||||
@@ -11,6 +11,12 @@ GLOBAL_LIST(veteran_players)
|
||||
continue
|
||||
GLOB.veteran_players[ckey(line)] = TRUE //Associative so we can check it much faster
|
||||
|
||||
/proc/save_veteran_players()
|
||||
var/veteran_list = ""
|
||||
for(var/veteran in GLOB.veteran_players)
|
||||
veteran_list += veteran + "\n"
|
||||
rustg_file_write(veteran_list, VETERANPLAYERS)
|
||||
|
||||
/proc/is_veteran_player(client/user)
|
||||
if(GLOB.veteran_players[user.ckey])
|
||||
return TRUE
|
||||
|
||||
@@ -3925,6 +3925,7 @@
|
||||
#include "modular_skyrat\modules\admin\code\adminhelp.dm"
|
||||
#include "modular_skyrat\modules\admin\code\aooc.dm"
|
||||
#include "modular_skyrat\modules\admin\code\loud_say.dm"
|
||||
#include "modular_skyrat\modules\admin\code\manage_player_ranks.dm"
|
||||
#include "modular_skyrat\modules\admin\code\sooc.dm"
|
||||
#include "modular_skyrat\modules\admin\code\smites\pie.dm"
|
||||
#include "modular_skyrat\modules\advanced_choice_beacons\code\advanced_choice_beacon.dm"
|
||||
|
||||
Reference in New Issue
Block a user