diff --git a/init.lua b/init.lua index 805b886..8b3bed9 100644 --- a/init.lua +++ b/init.lua @@ -430,43 +430,32 @@ local function handle_command(name, param) end end elseif action == "chown" then + local target = params[2] + local password = params[3] + local faction_name = params[4] + if not target then + return false, S("Missing player name.") + elseif not password then + return false, S("Missing password.") + end local own_factions = factions.get_administered_factions(name) local number_factions = own_factions and table.getn(own_factions) or 0 - local faction_name = nil - local target = nil - local password = nil if number_factions == 0 then return false, S("You don't own any factions, you can't use this command.") - elseif #params < 3 then - if params[2] ~= nil and minetest.player_exists(params[2]) then - return false, S("Missing password.") - else - return false, S("Missing player name.") - end - elseif number_factions == 1 and #params == 3 then + elseif not faction_name and number_factions == 1 then faction_name = own_factions[1] - target = params[2] - password = params[3] - elseif #params >= 4 then - faction_name = params[4] - target = params[2] - password = params[3] - end - if faction_name == nil then + else return false, S( "You are the owner of multiple factions, you have to choose one of them: @1.", table.concat(own_factions, ", ") ) - elseif target == nil then - return false, S("Missing player name.") - elseif password == nil then - return false, S("Missing password.") - elseif name ~= factions.get_owner(faction_name) and not minetest.get_player_privs(name)[factions.priv] then - return false, S("Permission denied: You are not the owner of that faction, " .. - "and don't have the @1 privilege.", factions.priv) + end + if not is_admin and name ~= factions.get_owner(faction_name) then + return false, S("Permission denied: You are not the owner of that faction, " + .. "and don't have the @1 privilege.", factions.priv) elseif not facts[faction_name].members[target] then - return false, S("@1 isn't in your faction.", target) - elseif not factions.valid_password(faction_name, password) then + return false, S("@1 isn't in faction @2.", target) + elseif not is_admin and not factions.valid_password(faction_name, password) then return false, S("Permission denied: Wrong password.") else if factions.chown(faction_name, target) then @@ -511,11 +500,11 @@ minetest.register_chatcommand("factions", { .."info []: "..S("See information about a faction").."\n" .."player_info []: "..S("See information about a player").."\n" .."join : "..S("Join an existing faction").."\n" - .."chown [faction]: "..S("Transfer ownership of your faction").."\n" .."leave []: "..S("Leave your faction").."\n" .."kick []: "..S("Kick someone from your faction or from the given faction").."\n" .."disband []: "..S("Disband your faction or the given faction").."\n" .."passwd []: "..S("Change your faction's password or the password of the given faction").."\n" + .."chown []: "..S("Transfer ownership of your faction").."\n" .."invite : "..S("Add player to a faction, you need @1 priv", factions.priv).."\n", description = "", diff --git a/locale/playerfactions.fr.tr b/locale/playerfactions.fr.tr index 671baf6..92c46f6 100644 --- a/locale/playerfactions.fr.tr +++ b/locale/playerfactions.fr.tr @@ -7,7 +7,7 @@ @1 is in the following factions: @2.=@1 est dans les factions suivantes : @2. @1 is now a member of faction @2.=@1 est maintenant membre de la faction @2. -@1 isn't in your faction.=@1 n’est pas dans votre faction. +@1 isn't in faction @2.=@1 n’est pas dans la faction @2. Add player to a faction, you need @1 privs=Ajoute un joueur à une faction, nécessite le privilège @1 Allow the use of all playerfactions commands=Autorise l’utilisation de toutes les commandes de playerfactions diff --git a/locale/template.txt b/locale/template.txt index 882ba89..9e9367b 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -7,7 +7,7 @@ @1 is in the following factions: @2.= @1 is now a member of faction @2.= -@1 isn't in your faction.= +@1 isn't in faction @2.= Add player to a faction, you need @1 privs= Allow the use of all playerfactions commands=