Don't allow /granting unknown privileges
authorPerttu Ahola <celeron55@gmail.com>
Sun, 1 Apr 2012 09:45:38 +0000 (12:45 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Sun, 1 Apr 2012 09:45:38 +0000 (12:45 +0300)
builtin/chatcommands.lua

index d5f448ebb002f0d0697d9124c60039ccde55fce2..570c07b05a77e762d5b67ca2635c3797ef5667bb 100644 (file)
@@ -99,9 +99,17 @@ minetest.register_chatcommand("grant", {
                        grantprivs = minetest.registered_privileges
                end
                local privs = minetest.get_player_privs(grantname)
+               local privs_known = true
                for priv, _ in pairs(grantprivs) do
+                       if not minetest.registered_privileges[priv] then
+                               minetest.chat_send_player(name, "Unknown privilege: "..priv)
+                               privs_known = false
+                       end
                        privs[priv] = true
                end
+               if not privs_known then
+                       return
+               end
                minetest.set_player_privs(grantname, privs)
                minetest.chat_send_player(name, "Privileges of "..grantname..": "..minetest.privs_to_string(minetest.get_player_privs(grantname), ' '))
                if grantname ~= name then