A bunch of changes

master
DonBatman 2016-03-25 11:03:38 -07:00
parent a55a4d8223
commit 65b3c321df
8 changed files with 189 additions and 2 deletions

25
curse.lua Normal file
View File

@ -0,0 +1,25 @@
local bad_words = {
"fuck",
"faggot",
"asshole",
"arsehole",
"dick",
"cunt",
"wtf",
"retard",
"bitch",
"shit",
"bastard",
"nigger",
"nigga"
}
minetest.register_on_chat_message(function(name, message)
if not message then return end
local msg = message:lower()
for _, word in pairs(bad_words) do
if msg:find(word) then
minetest.kick_player(name, "( ** WATCH YOUR LANGUAGE ** )")
return
end
end
end)

1
description.txt Normal file
View File

@ -0,0 +1 @@
Admin tools for servers including Admin picks, curse protection, chat commands and more.

24
extras.lua Normal file
View File

@ -0,0 +1,24 @@
minetest.register_privilege("myadmin_extras", "Need to use the extras")
minetest.register_chatcommand("setbar", {
params = "",
description = "Sets the size of your hotbar. 1 - 16",
privs = {myadmin_extras=true},
func = function(name, param)
if param == "" then
minetest.chat_send_player(name, "Use a number from 1 - 16")
return
end
if type(tonumber(param)) ~= "number" then
minetest.chat_send_player(name, "This is not a number.")
return
end
if tonumber(param) < 1 or tonumber(param) > 16 then
minetest.chat_send_player(name, "The number of slots must be between 1 and 16.")
return
end
local player = minetest.get_player_by_name(name)
player:hud_set_hotbar_itemcount(tonumber(param))
player:hud_set_hotbar_image("")
end,
})

View File

@ -2,3 +2,5 @@ dofile(minetest.get_modpath("myadmin").."/tools.lua")
dofile(minetest.get_modpath("myadmin").."/spawn.lua")
dofile(minetest.get_modpath("myadmin").."/chat.lua")
dofile(minetest.get_modpath("myadmin").."/privs.lua")
dofile(minetest.get_modpath("myadmin").."/curse.lua")
dofile(minetest.get_modpath("myadmin").."/extras.lua")

1
mod.conf Normal file
View File

@ -0,0 +1 @@
name = myadmin

116
npip.lua Executable file
View File

@ -0,0 +1,116 @@
-- Created by Krock to stop mass-account-creators
-- License: WTFPL
ipnames = {}
ipnames.data = {}
ipnames.tmp_data = {}
ipnames.changes = false
ipnames.save_interval = 120
ipnames.save_time = 0
ipnames.file = minetest.get_worldpath().."/ipnames.txt"
ipnames.name_per_ip_limit = minetest.setting_get("max_names_per_ip") or 5
-- Get accounts self:
minetest.register_chatcommand("whois", {
description = "Gets all players who have the same IP as the specified player",
privs = {kick = true},
func = function(name, param)
if not ipnames.data[param] then
minetest.chat_send_player(name, "The player \"" .. param .. "\" did not join yet.")
return
end
local ip = ipnames.data[param]
local names = "";
for k, v in pairs(ipnames.data) do
if v == ip then
if names ~= "" then
names = names .. ", " .. k
else
names = names .. " " .. k
end
end
end
minetest.chat_send_player(name, "Players for IP address " .. ip .. ": " .. names)
end,
})
-- Get IP if player tries to join, ban if there are too much names per IP:
minetest.register_on_prejoinplayer(function(name, ip)
-- Only stop new accounts:
ipnames.tmp_data[name] = ip
if not ipnames.data[name] then
local count = 1
local names = ""
for k, v in pairs(ipnames.data) do
if v == ip then
count = count + 1
names = names .. k .. ", "
end
end
if count <= ipnames.name_per_ip_limit and count > 1 then
minetest.log("action", name .. " now has " .. count .. " accounts. Other accounts: " .. names)
end
if count > ipnames.name_per_ip_limit then
ipnames.tmp_data[name] = nil
if tostring(ip) ~= "127.0.0.1" then
return ("\nYou exceeded the limit of accounts (" .. ipnames.name_per_ip_limit ..
").\nYou already have the following accounts:\n" .. names)
end
end
end
end)
-- Save IP if player joined:
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
ipnames.data[name] = ipnames.tmp_data[name]
ipnames.tmp_data[name] = nil
ipnames.changes = true
end)
function ipnames.load_data()
local file = io.open(ipnames.file, "r")
if not file then
return
end
for line in file:lines() do
if line ~= "" then
local data = line:split("|")
if #data >= 2 then
ipnames.data[data[1]] = data[2]
end
end
end
io.close(file)
end
function ipnames.save_data()
if not ipnames.changes then
return
end
ipnames.changes = false
local file = io.open(ipnames.file, "w")
for i, v in pairs(ipnames.data) do
if v ~= nil then
file:write(i .. "|" .. v .. "\n")
end
end
io.close(file)
end
minetest.register_globalstep(function(t)
ipnames.save_time = ipnames.save_time + t
if ipnames.save_time < ipnames.save_interval then
return
end
ipnames.save_time = 0
ipnames.save_data()
end)
minetest.register_on_shutdown(function() ipnames.save_data() end)
minetest.after(3, function() ipnames.load_data() end)

View File

@ -3,7 +3,7 @@ minetest.register_privilege("myadmin_levels", "Lets person set level of privlege
minetest.register_privilege("myadmin_levels_super", "Lets person set level of privlege people have plus the super level")
minetest.register_chatcommand("myadmin_commands", {
privs = {privs = true},
privs = {myadmin_levels = true},
func = function(name, param)
minetest.chat_send_player(name,"Available commands - /admin, /mod, /helper, /norm, /punish, /unpunish, silence, /ghost")
return true

View File

@ -19,6 +19,8 @@ minetest.register_tool("myadmin:ultimate_tool", {
snappy={times={[1]=0, [2]=0, [3]=0}, uses=0, maxlevel=3},
}
},
on_drop = function(itemstack, dropper, pos)
end
})
minetest.register_tool("myadmin:ultimate_tool_drop", {
description = "Ultimate Tool With Drops",
@ -37,12 +39,28 @@ minetest.register_tool("myadmin:ultimate_tool_drop", {
snappy={times={[1]=0, [2]=0, [3]=0}, uses=0, maxlevel=3},
}
},
on_drop = function(itemstack, dropper, pos)
end
})
minetest.register_on_punchnode(function(pos, node, puncher)
local n = node
if puncher:get_wielded_item():get_name() == "myadmin:ultimate_tool"
and minetest.get_node(pos).name ~= "air" then
and minetest.get_node(pos).name ~= "air"
and minetest.get_player_privs(puncher:get_player_name()).myadmin_levels_super == true then
minetest.remove_node(pos)
end
if puncher:get_wielded_item():get_name() == "myadmin:ultimate_tool"
or puncher:get_wielded_item():get_name() == "myadmin:ultimate_tool_drop"
and minetest.get_node(pos).name ~= "air" then
if minetest.get_player_privs(puncher:get_player_name()).myadmin_levels_super ~= true then
minetest.chat_send_player(puncher:get_player_name(), "You don't have the priv for this tool")
puncher:set_wielded_item("default:stick")
minetest.set_node(pos,{name = node.name})
return
end
end
end)