diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-06-16 23:35:11 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-06-16 23:35:11 +0300 |
commit | 57550b2b3d5ce5a8a7616c08b6517dc6fd8e1075 (patch) | |
tree | 01554474769bc97a126505c6c88d32e638d931df /builtin | |
parent | d15d6c4e6bbd64b8f6980b33413b7a8ffb39eb7c (diff) | |
download | minetest-57550b2b3d5ce5a8a7616c08b6517dc6fd8e1075.tar.gz minetest-57550b2b3d5ce5a8a7616c08b6517dc6fd8e1075.tar.bz2 minetest-57550b2b3d5ce5a8a7616c08b6517dc6fd8e1075.zip |
Fix /setpassword and /clearpassword
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/chatcommands.lua | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/builtin/chatcommands.lua b/builtin/chatcommands.lua index eaafe9ee8..9f033aa17 100644 --- a/builtin/chatcommands.lua +++ b/builtin/chatcommands.lua @@ -193,12 +193,27 @@ minetest.register_chatcommand("setpassword", { description = "set given password", privs = {password=true}, func = function(name, param) - if param == "" then - minetest.chat_send_player(name, "Password field required") + local toname, raw_password = string.match(param, "^([^ ]+) +(.+)$") + if not toname then + toname = string.match(param, "^([^ ]+) *$") + raw_password = nil + end + if not toname then + minetest.chat_send_player(name, "Name field required") return end - minetest.set_player_password(name, param) - minetest.chat_send_player(name, "Password set") + local actstr = "?" + if not raw_password then + minetest.set_player_password(toname, "") + actstr = "cleared" + else + minetest.set_player_password(toname, minetest.get_password_hash(toname, raw_password)) + actstr = "set" + end + minetest.chat_send_player(name, "Password of player \""..toname.."\" "..actstr) + if toname ~= name then + minetest.chat_send_player(toname, "Your password was "..actstr.." by "..name) + end end, }) minetest.register_chatcommand("clearpassword", { @@ -206,8 +221,13 @@ minetest.register_chatcommand("clearpassword", { description = "set empty password", privs = {password=true}, func = function(name, param) - minetest.set_player_password(name, '') - minetest.chat_send_player(name, "Password cleared") + toname = param + if not toname then + minetest.chat_send_player(toname, "Name field required") + return + end + minetest.set_player_password(toname, '') + minetest.chat_send_player(name, "Password of player \""..toname.."\" cleared") end, }) |