[simple_protection] Update to Git commit 2cdb431 & patch 1b924d0:

Commit: https://github.com/SmallJoker/simple_protection/tree/2cdb431
Patch: https://github.com/AntumMT/mod-simple_protection/tree/1b924d0
This commit is contained in:
AntumDeluge 2017-07-08 13:33:45 -07:00
parent 13ba491e8c
commit 02f5a2a935
9 changed files with 374 additions and 52 deletions

View File

@ -85,7 +85,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
* [wardrobe][] ([WTFPL][lic.wtfpl]) -- version: [1.1-2-c48b011 Git][ver.wardrobe] *2015-05-21*
* protection/
* [areas][] ([LGPL][lic.lgpl2.1]) -- version [289d0e6 Git][ver.areas] *2017-06-09*
* [simple_protection][] ([WTFPL][lic.wtfpl]) -- version [23c024f Git][ver.simple_protection] *2017-01-07*
* [simple_protection][] ([WTFPL][lic.wtfpl]) -- version [2cdb431 Git][ver.simple_protection] *2017-07-03* ([patched][patch.simple_protection])
* signs/
* [signs_lib][] ([BSD][lic.signs_lib] / [WTFPL][lic.wtfpl]) -- version: [3e00159 Git][ver.signs_lib] *2017-05-20* ([patched][patch.signs_lib])
* sound/
@ -496,7 +496,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[ver.quartz]: https://github.com/minetest-mods/quartz/tree/00ca4eb
[ver.rainbow_ore]: https://github.com/FsxShader2012/rainbow_ore/tree/6e77693
[ver.signs_lib]: https://github.com/minetest-mods/signs_lib/tree/3e00159
[ver.simple_protection]: https://github.com/SmallJoker/simple_protection/tree/23c024f
[ver.simple_protection]: https://github.com/SmallJoker/simple_protection/tree/2cdb431
[ver.slingshot]: https://github.com/AntumMT/mtmod-slingshot/tree/ef698e8
[ver.sneeker]: https://github.com/AntumMT/mtmod-sneeker/tree/a56b9c2
[ver.snowdrift]: https://github.com/paramat/snowdrift/tree/fcb0537
@ -577,6 +577,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[patch.quartz]: https://github.com/AntumMT/mtmod-quartz/tree/d23dabd
[patch.rainbow_ore]: https://github.com/AntumMT/mtmod-rainbow_ore/tree/0227a86
[patch.signs_lib]: https://github.com/AntumMT/mod-signs_lib/tree/47d3dd0
[patch.simple_protection]: https://github.com/AntumMT/mod-simple_protection/tree/1b924d0
[patch.snowdrift]: https://github.com/AntumMT/mtmod-snowdrift/tree/1b9da4f
[patch.spawneggs]: https://github.com/AntumMT/mtmod-spawneggs/tree/f2cc4cc
[patch.technic]: https://github.com/AntumMT/mp-technic/tree/70ebc1e

View File

@ -0,0 +1,59 @@
--[[
SETTINGS FILE
simple_protection/default_settings.lua
Contains the default settings for freshly created worlds.
Please do not modify in order to not get any configuration-related errors
after updating all other files but this
[world_path]/s_protect.conf
Contains the per-world specific settings.
You may modify thisone but pay attention, as some settings may cause
unwanted side effects when claims were made.
]]
-- Width and length of claims in nodes
-- !! Disorts the claims locations' along the X and Z axis !!
-- Type: Integer, positive, even number
s_protect.claim_size = 16
-- Height of claims in nodes
-- !! Disorts the claims locations' along the Y axis !!
-- Type: Integer, positive
s_protect.claim_height = 80
-- Defines the Y offset where the 0th claim should start in the underground
-- Example of claim (0,0,0): Ymin = -[20], Ymax = 80 - [20] = 60
-- Type: Integer
s_protect.start_underground = 20
-- When set to 'true': Allows very deep underground claiming
-- Will make the protection mod to ignore 's_protect.underground_limit'
-- Type: Boolean
s_protect.underground_claim = false
-- Only allows claiming above this Y value
-- Type: Integer
s_protect.underground_limit = -300
-- Returns the claim stick when unclaiming the area
-- Type: Boolean
s_protect.claim_return = true
-- Players will need to claim the area (or have access to it) to dig
-- Digging will be still allowed in the underground when
-- 's_protect.underground_claim == false'
-- Type: Boolean
s_protect.claim_to_dig = false
-- Allows players to list their areas using '/area list'
-- Type: Boolean
s_protect.area_list = true
-- Limits the amount of claims per player
-- For values < 10: Open [world_path]/world.mt and modify
-- the setting value of 'load_mod_simple_protection' to 'false'
-- This value is doubled for users with the 'simple_protection' privilege
-- Type: Integer
s_protect.max_claims = 100

View File

@ -40,6 +40,10 @@ s_protect.can_access = function(pos, player_name)
if player_name == ":pipeworks" then
return true
end
-- Admin power
if minetest.check_player_privs(player_name, {simple_protection=true}) then
return true
end
-- Data of current area
local data = s_protect.get_data(pos)
@ -75,10 +79,6 @@ s_protect.can_access = function(pos, player_name)
if table_contains(data.shared, "*all") then
return true
end
-- Admin power
if minetest.check_player_privs(player_name, {simple_protection=true}) then
return true
end
return false
end
@ -193,7 +193,7 @@ end
simple_protection = false
s_protect.load_config = function()
-- Load defaults
dofile(s_protect.mod_path.."/settings.conf")
dofile(s_protect.mod_path.."/default_settings.lua")
local file = io.open(s_protect.conf, "r")
if file then
io.close(file)
@ -212,7 +212,7 @@ s_protect.load_config = function()
return
end
-- Duplicate configuration file on first time
local src = io.open(s_protect.mod_path.."/settings.conf", "r")
local src = io.open(s_protect.mod_path.."/default_settings.lua", "r")
file = io.open(s_protect.conf, "w")
while true do

View File

@ -20,8 +20,12 @@ s_protect.gettext = function(rawtext, replacements, ...)
return text
end
if minetest.get_modpath("intllib") then
s_protect.gettext = intllib.Getter()
if minetest.global_exists("intllib") then
if intllib.make_gettext_pair then
s_protect.gettext = intllib.make_gettext_pair()
else
s_protect.gettext = intllib.Getter()
end
end
local S = s_protect.gettext
-- INTTLIB SUPPORT END
@ -31,14 +35,6 @@ dofile(s_protect.mod_path.."/functions.lua")
s_protect.load_config()
dofile(s_protect.mod_path.."/protection.lua")
minetest.register_on_protection_violation(function(pos, player_name)
minetest.chat_send_player(player_name, S("Do not try to modify this area!"))
--PUNISH HIM!!!!
--local player = minetest.get_player_by_name(player_name)
--player:set_hp(player:get_hp() - 1)
end)
minetest.register_privilege("simple_protection", S("Allows to modify and delete protected areas"))
minetest.register_chatcommand("area", {

View File

@ -0,0 +1,87 @@
# Translated by: Krock/SmallJoker
# Privilege description
Allows to modify and delete protected areas = Erlaubt das Abaendern und Entfernen von geschuetzten Gebieten
#### AREA COMMAND ####
# Command description
Manages all of your areas. = Verwaltet alle deine geschuetzten Gebiete
# /area
Available area commands:
Information about this area = Informationen ueber dieses Gebiet:
(Un)share one area = Eine Zugriffs-Berechtigung eines Gebietes hinzufuegen/entfernen
(Un)share all areas = Eine Zugriffs-Berechtigung fuer alle Gebiete hinzufuegen/entfernen
List claimed areas = Geschuetzte Gebiete auflisten
Delete all areas of a player = Alle Gebiete eines Spielers loeschen
Unclaim this area = Den Schutz fuer dieses Gebiet aufheben
# Errors of /area
Unknown command parameter: @1. Check '/area' for correct usage. = Unbekannter Befehls-Parameter: @1. Siehe '/area' fuer die korrekte Anwendung.
No player name given. = Kein Spielernahme gegeben.
Unknown player. = Unbekannter Spieler.
This area is not claimed yet. = Dieses Gebiet ist noch nicht geschuetzt.
You do not own this area. = Du besitzt dieses Gebiet nicht.
# /area show
Vertical area limit from Y @1 to @2 = Senkrechte Weite des Gebietes von Y @1 bis @2
Area status: @1 = Gebiets-Status: @1
Not claimable = Nicht schuetzbar
Unowned (!) = Nicht geschuetzt (!)
Owned by @1 = Von @1 geschuetzt
Players with access: @1 = Spieler mit Zugriff: @1
# /area share <name>
@1 already has access to all your areas. = @1 hat bereits Zugriff auf alle deine Gebiete.
@1 already has access to this area. = @1 hat bereits Zugriff auf dieses Gebiet.
@1 shared an area with you. = Du hast jetzt Zugriff auf ein Gebiet von @1.
@1 has now access to this area. = @1 kann jetzt dieses Gebiet abaendern.
# /area unshare <name>
That player has no access to this area. = Dieser Spieler hat keinen Zugriff auf dieses Gebiet.
@1 unshared an area with you. = Du hast nun keinen Zugriff auf ein Gebiet von @1 mehr.
@1 has no longer access to this area. = @1 kann jetzt dieses Gebiet nicht mehr abaendern.
# /area shareall <name>
You can not share all your areas with everybody. = Du kannst nicht alle Gebiete mit jedem teilen.
@1 already has now access to all your areas. = @1 hat bereits Zugriff auf alle deine Gebiete
@1 shared all areas with you. = @1 hat dir Zufriff auf alle die Gebiete erlaubt.
@1 has now access to all your areas. = @1 kann jetzt alle deine Gebiete abaendern.
# /area unshareall <name>
@1 does not have access to any of your areas. = @1 hat keinen Zugriff auf deine Gebiete.
@1 unshared all areas with you. = @1 hat dir den Zugriff auf die Gebiete verwehrt.
@1 has no longer access to your areas. = @1 kann keines deiner Gebiete mehr abaendern.
# /area unclaim
This area is unowned now. = Dieses Gebiet ist nun nicht mehr geschuetzt.
# /area delete <name>
Missing privilege: @1 = Fehlendes Privileg: @1
Removed = Entfernt
Globally shared areas = Globale Gebietszugiffe
@1 claimed area(s) = @1 geschuetzte(s) Gebiet(e)
@1 does not own any claimed areas. = @1 besitzt keine geschuetzten Gebiete.
# /area list [name]
This command is not available. = Dieser Befehl ist nicht verfuegbar.
Listing all areas of @1. Amount: @2 = Auslistung der Gebiete von @1. Anzahl: @2
#### Protection ####
# Item place information
Area owned by: @1 = Gebiet geschuetzt durch: @1
# Hud text
Area owner: @1 = Gebiets-Besitzer: @1
# Item: Claim stick
Claim stick = Gebiets-Besetzer-Tool
This area is already protected by an other protection mod. = Dieses Gebiet ist bereits durch eine andere Mod geschuetzt.
You can not claim areas below @1. = Du kannst keine Gebiete unterhalb von @1 schuetzen.
This area is already owned by: @1 = @1 besitzt dieses Gebiet bereits.
Congratulations! You now own this area. = Glueckwunsch! Du besitzt dieses Gebiet jetzt.
You can not claim any further areas: Limit (@1) reached. = Du kannst keine weiteren Gebiete schuetzen lassen: Limit (@1) erreicht.
Please claim this area to modify it. = Bitte schuetze das Gebiet um dieses abaendern zu koennen.

View File

@ -0,0 +1,87 @@
# Translated by: BrunoMine
# Privilege description
Allows to modify and delete protected areas = Permitir modificar e deletar areas protegidas
#### AREA COMMAND ####
# Command description
Manages all of your areas. = Gerencia todas as suas areas.
# /area
Available area commands: = Comandos disponiveis:
Information about this area = Dados sobre essa area
(Un)share one area = (Des)compartilha uma area
(Un)share all areas = (Des)compartilha todas areas
#List claimed areas =
#Delete all areas of a player =
Unclaim this area = Desfazer-se dessa area
# Errors of /area
Unknown command parameter: @1. Check '/area' for correct usage. = Parametro de comando desconhecido: @1. Use '/area' para o uso correto.
No player name given. = Nenhum nome de jogador dado.
Unknown player. = Jogador desconhecido.
This area is not claimed yet. = Essa area nao foi reivindicada ainda.
You do not own this area. = Voce nao pode possuir essa area.
# /area show
Vertical area limit from Y @1 to @2 = Limite vertical da area em Y @1 a @2
Area status: @1 = Status da area: @1
Not claimable = Nao reivindicada
Unowned (!) = Sem dono (!)
Owned by @1 = Reivindicada por @1
Players with access: @1 = Jogadores com acesso: @1
# /area share <name>
@1 already has access to all your areas. = @1 ja possui acesso a todas suas areas.
@1 already has access to this area. = @1 ja possui acesso a essa area.
@1 shared an area with you. = @1 compartilhou uma area contigo.
@1 has now access to this area. = @1 agora tem acesso nessa area.
# /area unshare <name>
That player has no access to this area. = Esse jogador nao tem acesso a essa area.
@1 unshared an area with you. = @1 descompartilhou uma area contigo.
@1 has no longer access to this area. = @1 deixou de ter acesso a essa area.
# /area shareall <name>
You can not share all your areas with everybody. = Nao podes compartilhar todas as suas areas com todos.
@1 already has now access to all your areas. = @1 ja possui agora acesso a todas suas areas.
@1 shared all areas with you. = @1 compartilhou todas as areas contigo.
@1 has now access to all your areas. = @1 agora tem acesso a todas suas areas.
# /area unshareall <name>
@1 does not have access to any of your areas. = @1 nao tem acesso a nenhuma de suas areas.
@1 unshared all areas with you. = @1 descompartilhou todas areas contigo.
@1 has no longer access to your areas. = @1 deixou de ter acesso a todas suas areas.
# /area unclaim
This area is unowned now. = Essa area deixou de ser reivindicada agora.
# /area delete <name>
Missing privilege: @1 = Perderam o privilegio: @1
Removed = Removido
Globally shared areas = Areas compartilhadas globalmente
@1 claimed area(s) = @1 area(s) reivindicada(s)
@1 does not own any claimed areas. = @1 nao possui nenhuma area reivindicada.
# /area list [name]
#This command is not available. =
#Listing all areas of @1. Amount: @2 =
#### Protection ####
# Item place information
Area owned by: @1 = Area possuida por: @1
# Hud text
Area owner: @1 = Area de: @1
# Item: Claim stick
Claim stick = Graveto Reivindicador
This area is already protected by an other protection mod. = Essa area ja foi protegida por um outro mod protetor.
You can not claim areas below @1. = Nao podes reivindicar areas abaixo @1.
This area is already owned by: @1 = Essa area ja foi reivindicada por: @1.
Congratulations! You now own this area. = Parabens! Agora reivindicaste essa area.
#You can not claim any further areas: Limit (@1) reached. =
#Please claim this area to modify it. =

View File

@ -0,0 +1,87 @@
# Translated by: <foobar>
# Privilege description
Allows to modify and delete protected areas =
#### AREA COMMAND ####
# Command description
Manages all of your areas. =
# /area
Available area commands:
Information about this area =
(Un)share one area =
(Un)share all areas =
List claimed areas =
Delete all areas of a player =
Unclaim this area =
# Errors of /area
Unknown command parameter: @1. Check '/area' for correct usage. =
No player name given. =
Unknown player. =
This area is not claimed yet. =
You do not own this area. =
# /area show
Vertical area limit from Y @1 to @2 =
Area status: @1 =
Not claimable =
Unowned (!) =
Owned by @1 =
Players with access: @1 =
# /area share <name>
@1 already has access to all your areas. =
@1 already has access to this area. =
@1 shared an area with you. =
@1 has now access to this area. =
# /area unshare <name>
That player has no access to this area. =
@1 unshared an area with you. =
@1 has no longer access to this area. =
# /area shareall <name>
You can not share all your areas with everybody. =
@1 already has now access to all your areas. =
@1 shared all areas with you. =
@1 has now access to all your areas. =
# /area unshareall <name>
@1 does not have access to any of your areas. =
@1 unshared all areas with you. =
@1 has no longer access to your areas. =
# /area unclaim
This area is unowned now. =
# /area delete <name>
Missing privilege: @1 =
Removed =
Globally shared areas =
@1 claimed area(s) =
@1 does not own any claimed areas. =
# /area list [name]
This command is not available. =
Listing all areas of @1. Amount: @2 =
#### Protection ####
# Item place information
Area owned by: @1 =
# Hud text
Area owner: @1 =
# Item: Claim stick
Claim stick =
This area is already protected by an other protection mod. =
You can not claim areas below @1. =
This area is already owned by: @1 =
Congratulations! You now own this area. =
You can not claim any further areas: Limit (@1) reached. =
Please claim this area to modify it. =

View File

@ -5,6 +5,18 @@ minetest.after(1, function()
s_protect.load_shareall()
end)
local function notify_player(pos, player_name)
local data = s_protect.get_data(pos)
if not data and s_protect.claim_to_dig then
minetest.chat_send_player(player_name, S("Please claim this area to modify it."))
elseif not data then
minetest.log("warning", "[simple_protection] Access refused but no area was found "..
"near pos=".. minetest.pos_to_string(pos))
else
minetest.chat_send_player(player_name, S("Area owned by: @1", data.owner))
end
end
s_protect.old_is_protected = minetest.is_protected
minetest.is_protected = function(pos, player_name)
if s_protect.can_access(pos, player_name) then
@ -26,15 +38,17 @@ minetest.item_place = function(itemstack, placer, pointed_thing)
end
end]]
if s_protect.can_access(pointed_thing.above, player_name) or not minetest.registered_nodes[itemstack:get_name()] then
if s_protect.can_access(pointed_thing.above, player_name)
or not minetest.registered_nodes[itemstack:get_name()] then
return old_item_place(itemstack, placer, pointed_thing)
else
local data = s_protect.get_data(pointed_thing.above)
minetest.chat_send_player(player_name, S("Area owned by: @1", data.owner))
return itemstack
end
notify_player(pointed_thing.above, player_name)
return itemstack
end
minetest.register_on_protection_violation(notify_player)
local hud_time = 0
s_protect.player_huds = {}
@ -133,6 +147,26 @@ minetest.register_craftitem("simple_protection:claim", {
S("This area is already owned by: @1", data.owner))
return
end
-- Count number of claims for this user
local claims_count = 0
local claims_max = s_protect.max_claims
if minetest.check_player_privs(player_name, {simple_protection=true}) then
claims_max = claims_max * 2
end
for k, v in pairs(s_protect.claims) do
if v.owner == player_name then
claims_count = claims_count + 1
if claims_count >= claims_max then
minetest.chat_send_player(player_name,
S("You can not claim any further areas: Limit (@1) reached.",
tostring(claims_max)))
return
end
end
end
itemstack:take_item(1)
s_protect.claims[area_pos] = {owner=player_name, shared={}}
s_protect.save()

View File

@ -1,29 +0,0 @@
-- THE "settings.conf" FILE CONTAINS THE DEFAULT SETTINGS
-- FIND THE WORLD-SPECIFIC CONFIGURATION IN THE WORLDS FOLDER
-- Size of claims in nodes, must be an even number <[16]>
s_protect.claim_size = 16
-- Height of claims in nodes <[80]>
s_protect.claim_height = 80
-- Nodes to start in underground, 80 - 20 = 60 nodes above ground <[20]>
-- Change to negative number if the zero-claim should start above 0m
s_protect.start_underground = 20
-- Allow (infinite!) underground claiming by setting to true <[false]>
s_protect.underground_claim = false
-- If disallow underground claims, define the under limit of claims <[-300]>
-- Not accurate number, depends on claim high!
s_protect.underground_limit = -300
-- Return claim stick on "/area unclaim" <[true]>
s_protect.claim_return = true
-- Areas must be claimed to dig in them <[false]>
-- (excluding underground when claiming there is disabled)
s_protect.claim_to_dig = false
-- Allows players to list their areas <[true]>
s_protect.area_list = true