From 1f10fd9e22bdc5e6853a63da06041bd1aab60e0c Mon Sep 17 00:00:00 2001 From: MinetestSam <42088654+MinetestSam@users.noreply.github.com> Date: Mon, 25 Nov 2019 13:05:45 +0530 Subject: [PATCH] Remove unused team ownership code; improve team listing (#512) --- mods/ctf/ctf/teams.lua | 18 --------- mods/ctf/ctf_chat/init.lua | 77 ++++++-------------------------------- 2 files changed, 11 insertions(+), 84 deletions(-) diff --git a/mods/ctf/ctf/teams.lua b/mods/ctf/ctf/teams.lua index 478e904..c46a758 100644 --- a/mods/ctf/ctf/teams.lua +++ b/mods/ctf/ctf/teams.lua @@ -237,24 +237,6 @@ function ctf.clean_player_lists() end end --- Sees if the player can change stuff in a team -function ctf.can_mod(player,team) - local privs = minetest.get_player_privs(player) - - if privs then - if privs.ctf_admin == true then - return true - end - end - - if player and ctf.teams[team] and ctf.teams[team].players and ctf.teams[team].players[player] then - if ctf.teams[team].players[player].auth == true then - return true - end - end - return false -end - -- Automatic Allocation function ctf.autoalloc(name, alloc_mode) alloc_mode = alloc_mode or ctf.setting("allocate_mode") diff --git a/mods/ctf/ctf_chat/init.lua b/mods/ctf/ctf_chat/init.lua index 941289e..e4172a1 100644 --- a/mods/ctf/ctf_chat/init.lua +++ b/mods/ctf/ctf_chat/init.lua @@ -53,8 +53,6 @@ local function team_console_help(name) minetest.chat_send_player(name, "/team remove - add a team called name (ctf_admin only)") end if privs and privs.ctf_team_mgr == true then - minetest.chat_send_player(name, "/team lock - closes a team to new players (ctf_team_mgr only)") - minetest.chat_send_player(name, "/team unlock - opens a team to new players (ctf_team_mgr only)") minetest.chat_send_player(name, "/team bjoin - Command is * for all players, playername for one, !playername to remove (ctf_team_mgr only)") minetest.chat_send_player(name, "/team join - add 'player' to team 'team' (ctf_team_mgr only)") minetest.chat_send_player(name, "/team removeply - add 'player' to team 'team' (ctf_team_mgr only)") @@ -67,8 +65,6 @@ minetest.register_chatcommand("team", { local test = string.match(param, "^player ([%a%d_-]+)") local create = string.match(param, "^add ([%a%d_-]+)") local remove = string.match(param, "^remove ([%a%d_-]+)") - local lock = string.match(param, "^lock ([%a%d_-]+)") - local unlock = string.match(param, "^unlock ([%a%d_-]+)") local j_name, j_tname = string.match(param, "^join ([%a%d_-]+) ([%a%d_]+)") local b_tname, b_pattern = string.match(param, "^bjoin ([%a%d_-]+) ([%a%d_-%*%! ]+)") local l_name = string.match(param, "^removeplr ([%a%d_-]+)") @@ -99,58 +95,26 @@ minetest.register_chatcommand("team", { else return false, "You are not a ctf_admin!" end - elseif lock then - local privs = minetest.get_player_privs(name) - if privs and privs.ctf_team_mgr then - local team = ctf.team(lock) - if team then - team.data.allow_joins = false - return true, "Locked team to new members" - else - return false, "Unable to find that team!" - end - else - return false, "You are not a ctf_team_mgr!" - end - elseif unlock then - local privs = minetest.get_player_privs(name) - if privs and privs.ctf_team_mgr then - local team = ctf.team(unlock) - if team then - team.data.allow_joins = true - return true, "Unlocked team to new members" - else - return false, "Unable to find that team!" - end - else - return false, "You are not a ctf_team_mgr!" - end elseif param == "all" then ctf.list_teams(name) elseif ctf.team(param) then - minetest.chat_send_player(name, "Team "..param..":") - local count = 0 - for _, value in pairs(ctf.team(param).players) do - count = count + 1 - if value.auth then - minetest.chat_send_player(name, count .. ">> " .. value.name - .. " (team owner)") - else - minetest.chat_send_player(name, count .. ">> " .. value.name) - end + local i = 0 + local str = "" + local team = ctf.team(param) + local tcolor = "#" .. ctf.flag_colors[team.data.color]:sub(3, 8) + for pname, tplayer in pairs(team.players) do + i = i + 1 + str = str .. " " .. i .. ") " .. minetest.colorize(tcolor, pname) .. "\n" end + str = "Team " .. minetest.colorize(tcolor, param) .. " (" .. i .. ") :\n" .. str + minetest.chat_send_player(name, str) elseif ctf.player_or_nil(param) or test then if not test then test = param end if ctf.player(test).team then - if ctf.player(test).auth then - return true, test .. - " is in team " .. ctf.player(test).team.." (team owner)" - else - return true, test .. - " is in team " .. ctf.player(test).team - end + return true, test .. + " is in team " .. ctf.player(test).team else return true, test.." is not in a team" end @@ -274,25 +238,6 @@ minetest.register_chatcommand("ctf_ls", { end }) -minetest.register_chatcommand("team_owner", { - params = "player name", - description = "Make player team owner", - privs = {ctf_admin=true}, - func = function(name, param) - if ctf and ctf.players and ctf.player(param) and ctf.player(param).team and ctf.team(ctf.player(param).team) then - if ctf.player(param).auth == true then - ctf.player(param).auth = false - return true, param.." was downgraded from team admin status" - else - ctf.player(param).auth = true - return true, param.." was upgraded to an admin of "..ctf.player(name).team - end - else - return false, "Unable to do that :/ "..param.." does not exist, or is not part of a valid team." - end - end -}) - minetest.register_chatcommand("t", { params = "msg", description = "Send a message on the team channel",