1
0
This commit is contained in:
BlackImpostor 2024-05-14 17:51:42 +03:00 committed by GitHub
parent 86bcfea3d9
commit 5b097c00f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 401 additions and 125 deletions

41
LICENSE
View File

@ -1,21 +1,20 @@
MIT License
Copyright (c) 2023 BlackImpostor
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Copyright © 2024 SkyBuilder1717
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall
be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,13 +1,5 @@
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
@ -37,14 +29,15 @@ if have_spawn_command then
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!"))
minetest.sound_play("error", name)
end
end
minetest.register_chatcommand("setspawn", {
params = "<X>,<Y>,<Z>",
description = "Sets a spawn point.",
privs = {server = true},
func = set_the_spawn,
})
minetest.register_chatcommand("setspawn", {
params = "<X>,<Y>,<Z>",
description = "Sets a spawn point. (BETA)",
privs = {server = true},
func = set_the_spawn,
})
end
-- end
@ -54,14 +47,16 @@ minetest.register_chatcommand("ip", {
privs = {server = true},
func = function(name, param)
if param == "" then
minetest.chat_send_player(name, "Your IP of is ".. minetest.get_player_ip(name))
minetest.chat_send_player(name, "Your IP address 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!"))
minetest.sound_play("error", name)
return
end
minetest.chat_send_player(name, "IP of ".. param .." is ".. minetest.get_player_ip(param))
minetest.chat_send_player(name, "IP address of ".. param .." is ".. minetest.get_player_ip(param))
end,
})
@ -72,14 +67,62 @@ minetest.register_chatcommand("broadcast", {
func = function(name, param)
if param == "" then
core.chat_send_player(name, core.colorize("red", "Message cannot be empty!"))
minetest.sound_play("error", name)
else
core.chat_send_all(core.colorize("#00FFC6", param))
minetest.sound_play("broadcast")
end
end,
})
if enable_damage then
function god_mode(name, param)
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.",
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 = {server = 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
-- god mode
function god_mode_switch(name, param)
if enable_damage then
local player = minetest.get_player_by_name(name)
local ag = player:get_armor_groups()
if not ag["immortal"] then
@ -88,25 +131,30 @@ if enable_damage then
minetest.sound_play("god_enabled", name)
else
ag["immortal"] = nil
core.chat_send_player(name, "God mode diabled")
core.chat_send_player(name, "God mode disabled")
minetest.sound_play("god_disabled", name)
end
player:set_armor_groups(ag)
else
core.chat_send_player(name, core.colorize("red", "\"enable_damage\" is disabled!"))
minetest.sound_play("error", name)
end
minetest.register_chatcommand("god", {
description = "Enable/Disabe the god mode.",
privs = {god = true},
func = god_mode
})
end
minetest.register_chatcommand("god", {
description = "Enable/Disabe the god mode.",
privs = {god_mode = true},
func = god_mode_switch
})
-- 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!"))
minetest.sound_play("error", name)
else
show_ban_menu(name)
end
@ -119,58 +167,173 @@ minetest.register_chatcommand("kick_menu", {
func = function(name, param)
if core.is_singleplayer() then
minetest.chat_send_player(name, core.colorize("red", "You cannot kick in single mode!"))
minetest.sound_play("error", name)
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("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 = "<name>",
description = "Allows the player to find out the position of another player.",
privs = {vip = true},
privs = {server = 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
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 = "<new_name>",
description = "Hide your real name and rename it on fake.",
privs = {},
description = "Show the rename menu.",
privs = {rename_player = true},
func = function(name, param)
hide_names[name] = param
show_rename_menu(name)
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
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
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>",
description = "Sets a color for nickname of any player.",
privs = {server = true},
func = function(name, param)
if not param then
minetest.chat_send_player(name, core.colorize("red", "Please, specify an nickname of player."))
return
end
if minetest.get_player_by_name(param) == nil then
minetest.chat_send_player(name, core.colorize("red", "Thats player offline or doesnt exist!"))
else
minetest.get_player_by_name(othername):set_properties({
nametag = "*".. new_name,
nametag_color = "#AAAAAA"
})
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 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 administrator %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,
})
--[[
minetest.register_chatcommand("v", {
params = "<name>",
description = "Make player invisible",
privs = {server = true},
func = function(name, param)
local player = minetest.get_player_by_name(param)
if param == "" then
if invisibility[name] then
invisible(name, false)
minetest.chat_send_player(name, "Now you are visible!")
elseif not invisibility[name] then
invisible(name, true)
minetest.chat_send_player(name, core.colorize("#AAAAAA", "Now you are invisible!"))
end
elseif not player then
minetest.chat_send_player(name, core.colorize("red", "Player ".. param .." not found!"))
minetest.sound_play("error", name)
else
if invisibility[param] then
invisible(param, false)
minetest.chat_send_player(name, "Now player ".. param .." are visible!")
minetest.chat_send_player(player, "Now you visible from ".. name .."!")
minetest.sound_play("done", player)
elseif not invisibility[param] then
invisible(param, true)
minetest.chat_send_player(name, core.colorize("#AAAAAA", "Now player ".. param .." are invisible!"))
minetest.chat_send_player(name, core.colorize("#AAAAAA", "Now you are invisible from ".. name .."!"))
minetest.sound_play("done", player)
end
end
end
})
]]--

2
depends.txt Normal file
View File

@ -0,0 +1,2 @@
unified_inventory?
spawn_command?

1
description.txt Normal file
View File

@ -0,0 +1 @@
Adds a lot of helpful commands for your server!

View File

@ -1 +1 @@
0.0.1
0.7.1

View File

@ -1,28 +1,80 @@
local version = "0.0.1"
local stat_version = "ALPHA"
local http = minetest.request_http_api()
local version = "0.7.1"
local modpath = minetest.get_modpath(minetest.get_current_modname())
local send_version = true
--local name = player:get_player_name()
essentials = {
a = "Created by SkyBuilder1717 (ContentDB)",
seed = (minetest.settings:get_bool("essentials_seed") or false),
killed_by = (minetest.settings:get_bool("essentials_killed_by") 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")
}
if essentials.watermark == nil then
essentials.watermark = true
end
minetest.log("action", "[Essentials] Mod initialised. Version: ".. version)
minetest.log("action", "\n███████╗░██████╗░██████╗███████╗███╗░░██╗████████╗██╗░█████╗░██╗░░░░░░██████╗\n██╔════╝██╔════╝██╔════╝██╔════╝████╗░██║╚══██╔══╝██║██╔══██╗██║░░░░░██╔════╝\n█████╗░░╚█████╗░╚█████╗░█████╗░░██╔██╗██║░░░██║░░░██║███████║██║░░░░░╚█████╗░\n██╔══╝░░░╚═══██╗░╚═══██╗██╔══╝░░██║╚████║░░░██║░░░██║██╔══██║██║░░░░░░╚═══██╗\n███████╗██████╔╝██████╔╝███████╗██║░╚███║░░░██║░░░██║██║░░██║███████╗██████╔╝\n╚══════╝╚═════╝░╚═════╝░╚══════╝╚═╝░░╚══╝░░░╚═╝░░░╚═╝╚═╝░░╚═╝╚══════╝╚═════╝░\n[Essentials] "..essentials.a)
local function removeLastDot(str)
local lastDotIndex = string.find(str,"%.[^.]*$")
if lastDotIndex then
return string.sub(str,1,lastDotIndex-1)..string.sub(str,lastDotIndex+1)
else
return str
end
end
minetest.after(0, function()
if essentials.check_for_updates then
minetest.log("action", "[Essentials] Checking for updates...")
if not minetest.request_insecure_environment() then
minetest.log("action", "[Essentials] Getting an Github version...")
http.fetch({
url = "https://raw.githubusercontent.com/SkyBuilder1717/essentials/main/gitVersion.txt",
timeout = 15,
method = "GET",
}, function(result)
minetest.log("action", string.format("[Essentials] Github version getted! (v%s)", result.data:gsub("[\n\\]", "")))
local git = tonumber(removeLastDot(result.data:gsub("[\n\\]", "")))
local this = tonumber(removeLastDot(version))
local test = false
if git > this then
test = true
end
--core.chat_send_all(dump(test))
if git > this then
minetest.log("warning", "[Essentials] Versions doesnt match!")
core.chat_send_all("[Essentials] Your server using old version of mod! ("..core.colorize("red", version)..") Old version can have a bugs! Download v"..core.colorize("lime", result.data:gsub("[\n\\]", ""))..".")
else
local _type
if core.is_singleplayer() then
_type = "World"
else
_type = "Server"
end
minetest.log("action", string.format("[Essentials] All ok! %s using lastest version of mod.", _type))
end
end)
else
core.chat_send_all("[Essentials] Please, add mod \'essentials\' to \"secure.trusted_mods\" for checking an updates!")
end
end
end)
--==[[ connections ]]==--
-- 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/watermark.lua")
if essentials.have_unified_inventory then
dofile(modpath.."/unified_inventory.lua")
end
dofile(modpath.."/ui/ban_menu.lua")
dofile(modpath.."/ui/kick_menu.lua")
dofile(modpath.."/ui/mute_menu.lua")
dofile(modpath.."/ui/about.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)
dofile(modpath.."/ui/color_menu.lua")
dofile(modpath.."/ui/rename_me.lua")
dofile(modpath.."/ui/rename_item.lua")

View File

@ -1,5 +1,5 @@
name = essentials
author = SkyBuilder
description = Adds a lot of helpful commands for your Minetest server
author = SkyBuilder1717
description = Adds a lot of helpful commands for your server!
title = Essentials
optional_depends = spawn_command, unified_inventory
optional_depends = spawn_command, unified_inventory

View File

@ -1,17 +1,19 @@
-- 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",
core.register_privilege("rename_player", {
description = "Can rename self.",
give_to_singleplayer = false,
})
core.register_privilege("mute", {
description = "Can mute/unmute players.",
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,
})

17
settingtypes.txt Normal file
View File

@ -0,0 +1,17 @@
# Every session/launch of world/server, mod will be checking for updates
#
# NOTE: Sometimes check for updates feature doesnt work for unknown reasons.
essentials_check_for_updates (Check for updates) bool false
# 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
# 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
essentials_changed_by ("Your name changed by" message) bool true
# Enables watermark on the screen
essentials_watermark (Watermark) bool true

View File

@ -1,7 +1,4 @@
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",
@ -11,7 +8,7 @@ if have_unified_inventory then
if minetest.check_player_privs(name, {ban=true}) then
show_ban_menu(name)
else
core.chat_send_player(name, "You dont have privilege 'ban'!")
core.chat_send_player(name, "You dont have privilege \'ban\'!")
end
end
})
@ -25,22 +22,65 @@ if have_unified_inventory then
if minetest.check_player_privs(name, {kick=true}) then
show_kick_menu(name)
else
core.chat_send_player(name, "You dont have privilege 'kick'!")
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
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
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("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
end
})
]]--