Compare commits
No commits in common. "6be72af82cfdffbd4fe5afc20a8ea40123326d15" and "1076047ad36b46935b6ad71624adadc83f4f0b43" have entirely different histories.
6be72af82c
...
1076047ad3
7 changed files with 77 additions and 47 deletions
89
init.lua
89
init.lua
|
@ -1,3 +1,6 @@
|
|||
-- License: WTFPL
|
||||
|
||||
|
||||
rules = {}
|
||||
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
@ -27,7 +30,7 @@ local items = {
|
|||
S("Failure to follow these rules may result in a kick or ban"),
|
||||
S(" (temp or permanent) depending on severity."),
|
||||
"",
|
||||
S("Created by rubenwardy. Hosted by philipmi."),
|
||||
S("Developed by rubenwardy, hosted by philipmi"),
|
||||
S("Moderators")..": philipmi",
|
||||
"",
|
||||
S("Though the server owner will not actively read private messages or disclose"),
|
||||
|
@ -53,9 +56,16 @@ if minetest.global_exists("sfinv") then
|
|||
})
|
||||
end
|
||||
|
||||
local function need_to_accept(pname)
|
||||
local function can_grant_interact(player)
|
||||
local pname = player:get_player_name()
|
||||
return not minetest.check_player_privs(pname, { interact = true }) and
|
||||
not minetest.check_player_privs(pname, { shout = true })
|
||||
not minetest.check_player_privs(pname, { fly = true })
|
||||
end
|
||||
|
||||
local function has_password(pname)
|
||||
local handler = minetest.get_auth_handler()
|
||||
local auth = handler.get_auth(pname)
|
||||
return auth and not minetest.check_password_entry(pname, auth.password, "")
|
||||
end
|
||||
|
||||
function rules.show(player)
|
||||
|
@ -63,7 +73,11 @@ function rules.show(player)
|
|||
local fs = "size[12,8.6]bgcolor[#080808BB;true]" ..
|
||||
"textlist[0,0;12,7.9;msg;" .. rules.txt .. ";-1;true]"
|
||||
|
||||
if not need_to_accept(pname) then
|
||||
if not has_password(pname) then
|
||||
fs = fs .. "box[4,8.1;3.1,0.7;#900]"
|
||||
fs = fs .. "label[4.2,8.2;Please set a password]"
|
||||
fs = fs .. "button_exit[0.5,7.6;3.5,2;ok;Okay]"
|
||||
elseif not can_grant_interact(player) then
|
||||
fs = fs .. "button_exit[0.5,7.6;7,2;ok;Okay]"
|
||||
else
|
||||
local yes = minetest.formspec_escape("Yes, let me play!")
|
||||
|
@ -76,6 +90,18 @@ function rules.show(player)
|
|||
minetest.show_formspec(pname, "rules:rules", fs)
|
||||
end
|
||||
|
||||
function rules.show_pwd(pname, msg)
|
||||
msg = msg or "You must set a password to be able to play"
|
||||
|
||||
minetest.show_formspec(pname, "rules:pwd", [[
|
||||
size[8,3]
|
||||
no_prepends[]
|
||||
bgcolor[#600]
|
||||
pwdfield[0.8,1.5;7,1;pwd;Password]
|
||||
button[0.5,2;7,2;setpwd;Set]
|
||||
label[0.2,0.2;]] .. minetest.formspec_escape(msg) .. "]")
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("rules", {
|
||||
func = function(pname, param)
|
||||
if param ~= "" and
|
||||
|
@ -97,38 +123,63 @@ minetest.register_on_newplayer(function(player)
|
|||
local pname = player:get_player_name()
|
||||
|
||||
local privs = minetest.get_player_privs(pname)
|
||||
privs.shout = nil
|
||||
privs.interact = nil
|
||||
if privs.interact and privs.fly then
|
||||
privs.interact = false
|
||||
minetest.set_player_privs(pname, privs)
|
||||
end
|
||||
|
||||
rules.show(player)
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
if need_to_accept(player:get_player_name()) then
|
||||
if not has_password(pname) then
|
||||
privs.shout = false
|
||||
privs.interact = false
|
||||
privs.kick = false
|
||||
privs.ban = false
|
||||
minetest.set_player_privs(pname, privs)
|
||||
rules.show_pwd(pname)
|
||||
elseif can_grant_interact(player) then
|
||||
rules.show(player)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, form, fields)
|
||||
if form ~= "rules:rules" then return end
|
||||
|
||||
if form == "rules:pwd" then
|
||||
local pname = player:get_player_name()
|
||||
if not need_to_accept(pname) then
|
||||
if fields.setpwd then
|
||||
local handler = minetest.get_auth_handler()
|
||||
if not fields.pwd or fields.pwd:trim() == "" then
|
||||
rules.show_pwd(pname)
|
||||
elseif #fields.pwd < 5 then
|
||||
rules.show_pwd(pname, "Needs at least 5 characters")
|
||||
else
|
||||
handler.set_password(pname,
|
||||
minetest.get_password_hash(pname, fields.pwd))
|
||||
rules.show(player)
|
||||
end
|
||||
else
|
||||
minetest.kick_player(pname,
|
||||
"You need to set a password to play on this server.")
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
if fields.no then
|
||||
if form ~= "rules:rules" then
|
||||
return
|
||||
end
|
||||
|
||||
local pname = player:get_player_name()
|
||||
if not can_grant_interact(player) or not has_password(pname) then
|
||||
return true
|
||||
end
|
||||
|
||||
if fields.msg then
|
||||
return true
|
||||
elseif not fields.yes or fields.no then
|
||||
minetest.kick_player(pname,
|
||||
"You need to agree to the rules to play on this server. " ..
|
||||
"Please rejoin and confirm another time.")
|
||||
return true
|
||||
end
|
||||
|
||||
if not fields.yes then
|
||||
return true
|
||||
end
|
||||
|
||||
local privs = minetest.get_player_privs(pname)
|
||||
privs.shout = true
|
||||
privs.interact = true
|
||||
|
|
21
license.txt
21
license.txt
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2022 MT-CTF
|
||||
|
||||
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.
|
|
@ -20,7 +20,7 @@ Excessive camping near the enemy base is also considered spawnkilling!=Übermä
|
|||
10. Moderator decisions are final.=10. Entscheidungen der Moderatoren sind endgültig.
|
||||
Failure to follow these rules may result in a kick or ban=Solltest du diese Regeln brechen kann das durchaus zu einem Kick (Rauswurf)
|
||||
(temp or permanent) depending on severity.=oder Ban (Bann) führen, (temporär oder permanent) je nach Schweregrad des Verstoßes.
|
||||
Created by rubenwardy. Hosted by philipmi.=Erstellt von rubenwardy. Gehostet von philipmi.
|
||||
Developed by rubenwardy, hosted by philipmi=Entwickelt von rubenwardy, gehostet von philipmi
|
||||
Moderators=Moderatoren
|
||||
Though the server owner will not actively read private messages or disclose=Auch wenn der Server Besitzer normalerweise nicht aktiv private Nachrichten lesen
|
||||
their content outside the mod team, random checks will be done to make sure=oder deren deren Inhalte außerhalb des Moderatoren Teams veröffentlichen
|
||||
|
|
|
@ -20,7 +20,7 @@ Excessive camping near the enemy base is also considered spawnkilling!=¡La acam
|
|||
10. Moderator decisions are final.=10. Las desiciones de los moderadores son lo final.
|
||||
Failure to follow these rules may result in a kick or ban=El incumplimiento de estas reglas puede resultar en una expulsión o prohibición
|
||||
(temp or permanent) depending on severity.=(temporal o permanente) dependiendo de la severidad.
|
||||
Created by rubenwardy. Hosted by philipmi.=Creado por rubenwardy. Hospedado por philipmi.
|
||||
Developed by rubenwardy, hosted by philipmi=Desarrollado por rubenwardy, hospedado por philipmi
|
||||
Moderators=Moderadores
|
||||
Though the server owner will not actively read private messages or disclose=Aunque el dueño del servidor no va a leer activamente los mensajes privados ni divulgará
|
||||
their content outside the mod team, random checks will be done to make sure=su contenido fuera del equipo de mods, se realizarán comprobaciones aleatorias para asegurarse
|
||||
|
|
|
@ -20,7 +20,7 @@ Excessive camping near the enemy base is also considered spawnkilling!=Le fait d
|
|||
10. Moderator decisions are final.=10. Les décisions de moderateurs sont irrévocables.
|
||||
Failure to follow these rules may result in a kick or ban=Manquement aux règles peut se résulter d'un kick ou ban
|
||||
(temp or permanent) depending on severity.=(temporaire ou permanent) dépendant de la sévérité.
|
||||
Created by rubenwardy. Hosted by philipmi.=Créé par rubenwardy. Hébergé par philipmi.
|
||||
Developed by rubenwardy, hosted by philipmi=Développé par rubenwardy, hébergé par philipmi
|
||||
Moderators=Moderateurs
|
||||
Though the server owner will not actively read private messages or disclose=Même si le propriétaire du serveur ne lira pas activement des messages
|
||||
their content outside the mod team, random checks will be done to make sure=privés ou révélera leur contenu à personne sauf aux moderateurs,
|
||||
|
|
|
@ -20,7 +20,7 @@ Excessive camping near the enemy base is also considered spawnkilling!=Anche il
|
|||
10. Moderator decisions are final.=10. Le decisioni dei moderatori sono definitive.
|
||||
Failure to follow these rules may result in a kick or ban=Mancato rispetto di queste regole può comportare una cacciata (kick) o un'esclusione completa (ban) dal gioco,
|
||||
(temp or permanent) depending on severity.=(temporaneamente o permanente) a seconda della gravità.
|
||||
Created by rubenwardy. Hosted by philipmi.=Creato da rubenwardy. Ospitato da philipmi.
|
||||
Developed by rubenwardy, hosted by philipmi=Sviluppato da rubenwardy, ospitato da philipmi
|
||||
Moderators=Moderatori
|
||||
Though the server owner will not actively read private messages or disclose=Anche se il proprietario del server non leggerà attivamente i messaggi privati o divulgherà
|
||||
their content outside the mod team, random checks will be done to make sure=il loro contenuto fuori del team dei moderatori, verranno effettuati controlli casuali per assicurarsi
|
||||
|
|
|
@ -20,7 +20,7 @@ Excessive camping near the enemy base is also considered spawnkilling!=Overdadig
|
|||
10. Moderator decisions are final.=10. Beslissingen van moderators zijn onherroepelijk.
|
||||
Failure to follow these rules may result in a kick or ban=Het falen om deze regels te volgen kan resulteren in een kick of ban
|
||||
(temp or permanent) depending on severity.=(tijdelijk of permanent), afhangend van de ernstigheid.
|
||||
Created by rubenwardy. Hosted by philipmi.=Gemaakt door rubenwardy. Gehost door philipmi.
|
||||
Developed by rubenwardy, hosted by philipmi=Ontworpen door rubenwardy, gehost door philipmi
|
||||
Moderators=Moderators
|
||||
Though the server owner will not actively read private messages or disclose=Ook al zal de server eigenaar niet actief privéberichten lezen of
|
||||
their content outside the mod team, random checks will be done to make sure=hun inhoud onthullen buiten het mod team, toch zullen willekeurige
|
||||
|
|
Loading…
Reference in a new issue