init.lua 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. if not minetest.global_exists("serveressentials") then serveressentials = {} end
  2. serveressentials.modpath = minetest.get_modpath("serveressentials")
  3. -- Outback's reset timeout in realtime days.
  4. serveressentials.reset_timeout = 30
  5. serveressentials.midfeld_reset_timeout = 30*2
  6. -- Can be gotten once only, at load time.
  7. if not serveressentials.modstorage then
  8. serveressentials.modstorage = minetest.get_mod_storage()
  9. end
  10. dofile(serveressentials.modpath .. "/outback.lua")
  11. dofile(serveressentials.modpath .. "/gaterealm.lua")
  12. dofile(serveressentials.modpath .. "/rebuild.lua")
  13. dofile(serveressentials.modpath .. "/acacia.lua")
  14. dofile(serveressentials.modpath .. "/utility.lua")
  15. dofile(serveressentials.modpath .. "/whereis.lua")
  16. dofile(serveressentials.modpath .. "/teleport.lua")
  17. dofile(serveressentials.modpath .. "/recall.lua")
  18. dofile(serveressentials.modpath .. "/suicide.lua")
  19. dofile(serveressentials.modpath .. "/gag.lua")
  20. function serveressentials.do_rename(pname, param)
  21. local tokens = param:split(" ")
  22. if #tokens ~= 2 then
  23. minetest.chat_send_player(pname, "# Server: Invalid usage.")
  24. return
  25. end
  26. rename.rename_player(rename.grn(tokens[1]), tokens[2], pname)
  27. end
  28. if not serveressentials.registered then
  29. -- Overriding the teleport chat-command is necessary in order to let admins
  30. -- use realm-relative coordinates. It also prevents admins from accidentally
  31. -- teleporting into "unallocated" parts of the world, which can damage* the
  32. -- map and possibly require use of WorldEdit to fix.
  33. --
  34. -- *I.e. cause to be generated chunks that shouldn't be generated, which can
  35. -- cause a cascade of lighting issues that ruin any terrain below. Note that
  36. -- this works in concert with the 'rc' (RealmControl) code.
  37. assert(minetest.registered_chatcommands["teleport"])
  38. minetest.override_chatcommand("teleport", {
  39. func = function(name, param)
  40. wield3d.on_teleport()
  41. local result, str = serveressentials.do_teleport(name, param)
  42. minetest.chat_send_player(name, "# Server: " .. str)
  43. end,
  44. })
  45. minetest.register_privilege("whereis", {
  46. description = "Player may use the /whereis command to locate other players.",
  47. give_to_singleplayer = false,
  48. })
  49. minetest.register_chatcommand("whereis", {
  50. params = "[<player>]",
  51. description = "Locate a player or the caller.",
  52. privs = {whereis=true},
  53. func = function(...)
  54. return serveressentials.whereis(...)
  55. end
  56. })
  57. minetest.register_chatcommand("rename", {
  58. params = "<player> <alias>",
  59. description = "Rename a player.",
  60. privs = {server=true},
  61. func = function(...)
  62. return serveressentials.do_rename(...)
  63. end
  64. })
  65. local c = "serveressentials:core"
  66. local f = serveressentials.modpath .. "/init.lua"
  67. reload.register_file(c, f, false)
  68. dofile(serveressentials.modpath .. "/defenestrate.lua")
  69. serveressentials.registered = true
  70. end