diff --git a/commands.lua b/commands.lua new file mode 100644 index 0000000..c3aba85 --- /dev/null +++ b/commands.lua @@ -0,0 +1,174 @@ +local have_spawn_command = minetest.get_modpath("spawn_command") +local enable_damage = core.settings:get_bool("enable_damage") +local hide_names = {} + +minetest.register_chatcommand("about_essentials", { + description = "About the 'essentials' mod.", + func = function(name, param) + show_about(name) + end +}) + +-- 'spawn_command' mod +if have_spawn_command then + function set_the_spawn(name, param) + local p = {} + local posmessage = {x = 0, y = 0, z = 0} + local player = minetest.get_player_by_name(name); + local pos = player:get_pos(); + local static_spawnpoint = minetest.setting_get_pos("static_spawnpoint"); + local spawn_pos = vector.round(spawn_command.pos); + p.x, p.y, p.z = string.match(param, "^([%d.~-]+)[, ] *([%d.~-]+)[, ] *([%d.~-]+)$"); + p = core.parse_coordinates(p.x, p.y, p.z, pos); + + if player == nil then + return false + end + + if p and p.x and p.y and p.z then + spawn_command.pos = {x = p.x, y = p.y, z = p.z}; + static_spawnpoint = {x = p.x, y = p.y, z = p.z}; + posmessage = {x = p.x, y = p.y, z = p.z}; + minetest.chat_send_player(name, core.colorize("#00FF06", "Spawn sets successful at ".. posmessage.x .." ".. posmessage.y .." ".. posmessage.z .."!")) + elseif param == "" then + spawn_pos = vector.round(pos); + spawn_command.pos = spawn_pos; + static_spawnpoint = spawnpos; + minetest.chat_send_player(name, core.colorize("#00FF06", "Spawn sets successful at ".. spawn_pos.x .." ".. spawn_pos.y .." ".. spawn_pos.z .."!")) + else + minetest.chat_send_player(name, core.colorize("red", "Wrong position!")) + end + end +minetest.register_chatcommand("setspawn", { + params = ",,", + description = "Sets a spawn point.", + privs = {server = true}, + func = set_the_spawn, +}) +end +-- end + +minetest.register_chatcommand("ip", { + params = "", + description = "Show the IP of a player.", + privs = {server = true}, + func = function(name, param) + if param == "" then + minetest.chat_send_player(name, "Your IP of is ".. minetest.get_player_ip(name)) + return + end + if minetest.get_player_by_name(param) == nil then + minetest.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!")) + return + end + minetest.chat_send_player(name, "IP of ".. param .." is ".. minetest.get_player_ip(param)) + end, +}) + +minetest.register_chatcommand("broadcast", { + params = "", + description = "Send GLOBAL message in chat.", + privs = {server = true}, + func = function(name, param) + if param == "" then + core.chat_send_player(name, core.colorize("red", "Message cannot be empty!")) + else + core.chat_send_all(core.colorize("#00FFC6", param)) + end + end, +}) + +if enable_damage then + function god_mode(name, param) + local player = minetest.get_player_by_name(name) + local ag = player:get_armor_groups() + if not ag["immortal"] then + ag["immortal"] = 1 + core.chat_send_player(name, "God mode enabled") + else + ag["immortal"] = nil + core.chat_send_player(name, "God mode diabled") + end + player:set_armor_groups(ag) + end + + minetest.register_chatcommand("god", { + description = "Enable/Disabe the god mode.", + privs = {god = true}, + func = god_mode + }) +end + +minetest.register_chatcommand("ban_menu", { + description = "Open the ban menu.", + privs = {ban = true}, + func = function(name, param) + if core.is_singleplayer() then + minetest.chat_send_player(name, core.colorize("red", "You cannot ban in single mode!")) + else + show_ban_menu(name) + end + end +}) + +minetest.register_chatcommand("kick_menu", { + description = "Open the kick menu.", + privs = {kick = true}, + func = function(name, param) + if core.is_singleplayer() then + minetest.chat_send_player(name, core.colorize("red", "You cannot kick in single mode!")) + else + show_kick_menu(name) + end + end +}) + +--minetest.register_chatcommand("mute_menu", { +-- description = "Open the mute menu.", +-- privs = {mute = true}, +-- func = function(name, param) +-- if core.is_singleplayer() then +-- minetest.chat_send_player(name, core.colorize("red", "You cannot mute in single mode!")) +-- else +-- show_mute_menu(name) +-- end +-- end +--}) + +minetest.register_chatcommand("getpos", { + params = "", + description = "Allows the player to find out the position of another player.", + privs = {vip = true}, + func = function(name, param) + local player = minetest.get_player_by_name(param); + + if param == "" then + minetest.chat_send_player(name, core.colorize("red", "Player name cannot be empty!")) + return + elseif minetest.get_player_by_name(param) == nil then + minetest.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!")) + return + else + local pos = player:get_pos(); + local round_pos = vector.round(pos); + minetest.chat_send_player(name, "Position of ".. param .." is ".. round_pos.x .." ".. round_pos.y .." ".. round_pos.z) + end + end, +}) + +minetest.register_chatcommand("rename_me", { + params = "", + description = "Hide your real name and rename it on fake.", + privs = {}, + func = function(name, param) + hide_names[name] = param + end +}) + +minetest.register_on_chat_message(function(name, message) + local new_name = hide_names[name] + if new_name then + minetest.chat_send_all("<"..new_name.."> "..message) + return true + end +end) \ No newline at end of file diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..cc8266f --- /dev/null +++ b/depends.txt @@ -0,0 +1,2 @@ +spawn_command? +unified_inventory? \ No newline at end of file diff --git a/description.txt b/description.txt new file mode 100644 index 0000000..55b2590 --- /dev/null +++ b/description.txt @@ -0,0 +1 @@ +Adds a lot of helpful commands for your Minetest server diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..b9413e2 --- /dev/null +++ b/init.lua @@ -0,0 +1,27 @@ +local version = "0.0.1" +local stat_version = "ALPHA" +local modpath = minetest.get_modpath(minetest.get_current_modname()) +local send_version = true +--local name = player:get_player_name() + +-- connections +dofile(modpath.."/commands.lua") +--dofile(modpath.."/settings.lua") +dofile(modpath.."/priveleges.lua") +--dofile(modpath.."/watermark.lua") +dofile(modpath.."/unified_inventory.lua") +dofile(modpath.."/ui/ban_menu.lua") +dofile(modpath.."/ui/kick_menu.lua") +dofile(modpath.."/ui/mute_menu.lua") + +minetest.log("action", "[Essentials] Mod initialised. Version: ".. version) + +minetest.register_on_joinplayer(function(player) + local name = player:get_player_name() + + if send_version == true then + minetest.chat_send_player(name, core.colorize("orange", "Essentials mod installed.").. " " ..core.colorize("#0050b3", "By Builder Mods STUDIO.").. " " ..core.colorize("green", "Version: ".. version .." ".. stat_version)) + elseif send_version == false then + minetest.log("action", "[Essentials] send_version is false. Cant send the message") + end +end) diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..d368e45 --- /dev/null +++ b/mod.conf @@ -0,0 +1,6 @@ +name = essentials +release = 1 +author = SkyBuilder +description = Adds a lot of helpful commands for your Minetest server +title = Essentials +optional_depends = spawn_command, unified_inventory diff --git a/priveleges.lua b/priveleges.lua new file mode 100644 index 0000000..3e57ece --- /dev/null +++ b/priveleges.lua @@ -0,0 +1,17 @@ +-- god mode +if enable_damage then + core.register_privilege("god", { + description = "Can use /god command", + give_to_singleplayer = false, + }) +end + +core.register_privilege("vip", { + description = "Can use vip commands", + give_to_singleplayer = false, +}) + +core.register_privilege("mute", { + description = "Can mute/unmute players.", + give_to_singleplayer = false, +}) \ No newline at end of file diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..fdf8c6c Binary files /dev/null and b/screenshot.png differ diff --git a/unified_inventory.lua b/unified_inventory.lua new file mode 100644 index 0000000..a3ac9f4 --- /dev/null +++ b/unified_inventory.lua @@ -0,0 +1,46 @@ +local have_unified_inventory = minetest.get_modpath("unified_inventory") +local FORMNAME = "essentials:ban_menu" + +if have_unified_inventory then + unified_inventory.register_button("ban_menu", { + type = "image", + image = "unified_inventory_ban.png", + tooltip = "Ban menu", + action = function(player) + local name = player:get_player_name() + if minetest.check_player_privs(name, {ban=true}) then + show_ban_menu(name) + else + core.chat_send_player(name, "You dont have privilege 'ban'!") + end + end + }) + + unified_inventory.register_button("kick_menu", { + type = "image", + image = "unified_inventory_kick.png", + tooltip = "Kick menu", + action = function(player) + local name = player:get_player_name() + if minetest.check_player_privs(name, {kick=true}) then + show_kick_menu(name) + else + core.chat_send_player(name, "You dont have privilege 'kick'!") + end + end + }) + + --unified_inventory.register_button("mute_menu", { + -- type = "image", + -- image = "unified_inventory_mute.png", + -- tooltip = "Mute menu", + -- action = function(player) + -- local name = player:get_player_name() + -- if minetest.check_player_privs(name, {mute=true}) then + -- show_mute_menu(name) + -- else + -- core.chat_send_player(name, "You dont have privilege 'mute'!") + -- end + -- end + --}) +end \ No newline at end of file