s_server.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. Minetest
  3. Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. #include "cpp_api/s_base.h"
  18. #include <set>
  19. class ScriptApiServer
  20. : virtual public ScriptApiBase
  21. {
  22. public:
  23. // Calls on_chat_message handlers
  24. // Returns true if script handled message
  25. bool on_chat_message(const std::string &name, const std::string &message);
  26. // Calls when mods are loaded
  27. void on_mods_loaded();
  28. // Calls on_shutdown handlers
  29. void on_shutdown();
  30. // Calls core.format_chat_message
  31. std::string formatChatMessage(const std::string &name,
  32. const std::string &message);
  33. /* auth */
  34. bool getAuth(const std::string &playername,
  35. std::string *dst_password,
  36. std::set<std::string> *dst_privs,
  37. s64 *dst_last_login = nullptr);
  38. void createAuth(const std::string &playername,
  39. const std::string &password);
  40. bool setPassword(const std::string &playername,
  41. const std::string &password);
  42. /* dynamic media handling */
  43. static u32 allocateDynamicMediaCallback(lua_State *L, int f_idx);
  44. void freeDynamicMediaCallback(u32 token);
  45. void on_dynamic_media_added(u32 token, const char *playername);
  46. private:
  47. void getAuthHandler();
  48. void readPrivileges(int index, std::set<std::string> &result);
  49. };